Hello!Greetings to all and hope everyone is doing good
Recently I designed a custom PCB based on ESP32-C3 (Schematics attached below). I'm having troubles uploading sketch to it thru Arduino IDE. I get the following error
esptool.py v3.3
Serial port COM3
Connecting......................................
A fatal error occurred: Failed to connect to ESP32-C3: Invalid head of packet (0x45): Possible serial noise or corruption.
For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html
the selected serial port For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html
does not exist or your board is not connected
Following are the settings for the ESP32-C3 board in Arduino IDE:
Board: ESP32-C3 Dev Module
Upload speed: 115200
CPU Freq: 40MHz
Flash Freq: 40MHz
Flash Size: 4MB
I have pads exposed on PCB where I have soldered some wires to upload the sketch to this PCB.
TX
RX
CH-PD(EN)
GPIO9
VCC3.3
GND
Of this TX goes to Rx of the CP2102 Module.
Rx goes to the Tx of CP2102 Module.
CHPD goes to the one end of tactile switch(A). Other end goes to GND
GPIO goes to one end of tactile switch(B). Other end goes to GND
VCC3.3 Goes to 3.3V out of CP2102 Module
GND made common to all
Now, I have following guesses as to why the code might not getting uploaded:
I do not have the "Two transistor" Auto-program circuit included anywhere that usually comes with all development boards
Not enough power
The tactile switches are pressed at wrong time or for wrong duration. I press and hold the GPIO9 switch and the EN switch down. Then insert the CP2102 module into my computer and hit upload button, then I release the EN switch keeping the GPIO9 switch hold down. When I see the IDE saying uploading... I release the GPIO9 switch as well. IS this the correct way to do it?
Lack of Caps on 3.3V line
Please let me know which of the above factors might be causing the problem. Also let me know if there are any other reasons that might be causing this problem.
Below is the attached PDF of my schematics.
Any suggestions are valuable and precious to me. Thanks in advance Schematic Prints.PDF (142.5 KB)
I added a pull-up resistor of 1K on the EN pin which I forgot to put earlier. I also added a 10uF capacitor ELC on EN pin. After that the error changed to something like this:
esptool.py v3.3
Serial port COM3
Connecting......................................
A fatal error occurred: Failed to connect to ESP32-C3: No serial data received.
For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html
the selected serial port For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html
does not exist or your board is not connected
Does the ESP32-C3 chip needs a bootloader of some sort? as in case of AVRs to use it with Arduino we need to have a bootloader in it. Is it same with the ESP32-C3?
If I open the serial monitor I see a long of this:
Hello, I am having the exact same issue you described. What was the timing of your switches that made it work? I can't seem to get a combination where it uploads the sketch. I have been pulling GPIO 9 Low, then pull EN low, then release EN. wait a few ms. Then release GPIO 9. I have tried to do this before hitting upload and while the Connecting... is going.
I keep getting: A fatal error occurred: Failed to connect to ESP32-C3: No serial data received.
But if I connect and look at the serial monitor, I can get the ESP32-C3 to output:
ESP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0x1 (POWERON),boot:0x0 (USB_BOOT)
wait usb download
So, I don't think this will be particularly helpful, but I wanted to chime in here because I am experiencing the same problem. It took me a little while to get to this point, because I'd missed some critical components in my PCB design (the 10uF cap on EN pin, the Pullup on EN, and although the booting mode table in the esp32-c3 docs says IO2 has to be high, I can't get my boot to stablize unless it's low.)
Anyway, I'm at virtually the same place you are:
ESP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0x1 (POWERON),boot:0x0 (USB_BOOT)
wait usb download
While reading through GitHub issues, I came across this:
which suggests to me that there might need to be another (or different) bootloader flashed to our chips. I'm really not sure about that though. Will continue to investigate.
All right, so more learning and experiments later, I have found the problem that my board was experiencing, and I suspect this will help some folks in the future:
The issue that I was running into (and I suspect that @cclose above is experiencing) was that my GPIO8 was bridged to my GPIO9. Both pins affect the boot mode, and the documentation states this:
GPIO8 must also be driven High, in order to enter the serial bootloader reliably. The strapping combination of GPIO8 = 0 and GPIO9 = 0 is invalid and will trigger unexpected behavior.
In normal boot mode (GPIO9 high), GPIO8 is ignored.
Additionally, GPIO9 has a pullup on it. So if your IO8 and 9 are bridged. When IO9 is high (and 8 is also high), your board boots normally. If you pull IO9 down to boot into download mode, you are (unknowingly) pulling IO8 down as well. As noted above this results in unexpected behavior. In my case it was going into 'USB_BOOT'.
This problem is exacerbated by the fact that the pins are under the module, and you can't see if you have a bridge. I have test points on my board and that's how I discovered the problem. I used some flux and a hot-air rework station to reflow the solder. If you don't have a hot-air station, you might be able to put some flux on the edge of the board where IO8 and IO9 are, and put a soldering iron on, that might transfer enough heat to reflow it. I suspect this is an unfortunate side effect of module design coupled with at-home reflow practices (too much solder paste, unaligned stencil, imperfect reflow temperatures, etc.)
I hope this helps anyone else who runs into the problem.
Thanks for the information! Once you reflowed it were you able to successfully upload to it? It sounds like it but you didn't explicitly say.
Also after you reflowed it, did you leave IO8 floating?
I got my boards from JLCPCB pre-assembled. I have only tried one of them, I can try another later to see if maybe that one board's IO8 was bridged to IO9.
Yes, my board is now programmable, and I've successfully programmed it.
My IO8 pin is pulled high on my board with a 10k resistor, which of course allowed it to be pulled low by the bridged IO9 that had no resistance. IO8 MUST be HIGH in order for the board to boot into download mode.
Again, in case anyone doesn't understand the docs:
To be in download mode, when the chip is reset:
GPIO-9 must be LOW
GPIO-8 must be HIGH
GPIO-2 must be HIGH
Also, Espressif recommends that you have a 1-10uf capacitor and a a Pull-up resistor on the EN pin. (The EN pin is the pin you use to reset the chip.)
You will want to release both EN and GPIO9 before you hit upload. Holding EN keeps the chip turned off, essentially. You can release GPIO9 at any point - it just needs to be held at GND when the chip comes out of reset.
If you have RXD AND TXD lines connected up to your CP2102, you should see some distinctive messages on coming out of reset which will clarify which mode you're in.
If you're booting into "normal" mode (You're running firmware from flash)
Sketch uses 935764 bytes (71%) of program storage space. Maximum is 1310720 bytes.
Global variables use 39484 bytes (12%) of dynamic memory, leaving 288196 bytes for local variables. Maximum is 327680 bytes.
esptool.py v4.2.1
Serial port COM3
Connecting....
Chip is ESP32-C3 (revision 3)
Features: Wi-Fi
Crystal is 40MHz
MAC: 7c:df:a1:bf:c1:3c
Uploading stub...
Running stub...
Stub running...
WARNING: Failed to communicate with the flash chip, read/write operations will fail. Try checking the chip connections or removing any other hardware connected to IOs.
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00002fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x000fbfff...
Compressed 12144 bytes to 8811...
A fatal error occurred: Packet content transfer stopped (received 8 bytes)
Failed uploading: uploading error: exit status 2
This is the error message I get
I do not have that additional flash chip in my design right now
It appears to me that the ESP32-C3 needs a external flash chip for it to function. Can anyone please confirm this?
It shouldn't. There's no external flash on the ESP32-C3-Mini, for instance. The Flash is all onboard the chip package.
Your schematic is similar to MakerMoekoe's PicoClick C3T, there may be some hints in that repo about programming over USB (GitHub - makermoekoe/Picoclick-C3)
I took the question to the ESP32 forum and found that there are two variants for ESP32-C3. One with flash and one without built in flash. and it seems that I have used the one without flash and hence it is not accepting the sketches.
Thanks everyone for the input. If I have any other leads on this topic I'll keep posting