Problem Uploading sketch to ESP32-C3 custom board

Hello!Greetings to all and hope everyone is doing good :hugs:

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:

  1. Board: ESP32-C3 Dev Module
  2. Upload speed: 115200
  3. CPU Freq: 40MHz
  4. Flash Freq: 40MHz
  5. Flash Size: 4MB

I have pads exposed on PCB where I have soldered some wires to upload the sketch to this PCB.

  1. TX

  2. RX

  3. CH-PD(EN)

  4. GPIO9

  5. VCC3.3

  6. GND

  7. Of this TX goes to Rx of the CP2102 Module.

  8. Rx goes to the Tx of CP2102 Module.

  9. CHPD goes to the one end of tactile switch(A). Other end goes to GND

  10. GPIO goes to one end of tactile switch(B). Other end goes to GND

  11. VCC3.3 Goes to 3.3V out of CP2102 Module

  12. GND made common to all

Now, I have following guesses as to why the code might not getting uploaded:

  1. I do not have the "Two transistor" Auto-program circuit included anywhere that usually comes with all development boards
  2. Not enough power
  3. 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?
  4. 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)

Any other details that I have failed to mention here? Please let me know

Update:

  1. 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:

invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff

If I initiate the button press sequence (GPIO9 Pressed and hold down, EN pressed, hold and released and then GPIO9 released) I see this:

ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x1 (POWERON),boot:0x0 (USB_BOOT)
wait usb download

So does it mean my ESP32-C3 is entering into bootmode properly?

I have zero experience with the ESP32-C3

I quogled it and found these links

https://docs.espressif.com/projects/esptool/en/latest/esp32c3/troubleshooting.html

https://www.visualmicro.com/forums/YaBB.pl?num=1648728959/5

making a custom made pcb is adding additional riscs of not functioning

So I would do a lot of steps inbetween from a well known system like an ESP32-nodeCMU
until using a custom made PCB

best regards Stefan

Thanks for the reply. I have fortunately got it working after several attempts. I only needed to time the switches at the right moment and it worked!

Thanks for taking time and writing back to me! :hugs:

I received a ESP32 Lolin Pico C3, recently. In order to let Arduino send sketches to the device I found out this following manipulation to work fine:

  1. with pico NOT plugged, press button 9.
  2. while button still pressed, plug USB cable
  3. Once connection established, button can be released
  4. select the comm port
  5. upload the sketch
  6. when finished, press the RESET button to make it run

Not too friendly, but at least it works

Why would I buy a single-core ESP32 type ESP32-C3
when I can have a ESP32-S3

ESP32-S3[ESP32-S3]

  • Dual-core Xtensa LX7 CPU, up to 240 MHz[10]
    • Added instructions to accelerate machine learning applications
  • 512 KiB SRAM, 384 KiB ROM, and 16 KiB RTC SRAM
  • WiFi 2.4 GHz (IEEE 802.11 b/g/n)[11]
  • Bluetooth 5 (LE)

like this
https://de.aliexpress.com/item/32821603622.html
which does uploading code right out of the box

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

Thanks in advance for any help!

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:

aside from programming the application binary, have you also programmed
the 2nd stage bootloader and the partition table binaries? invalid header: 0xffffffff possibly indicates that the 2nd stage bootloader is not written into Flash.
(Programming ESP32-C3-MINI-1 module using JTAG (OCD-390) · Issue #168 · espressif/openocd-esp32 · GitHub)

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.)

what is the key press sequence you followed? I have made another baord and facing the issues again.

This is what I do:

  1. Press and hold down EN and GPIO
  2. Plug in the CP2102 module to which my PCB is connected
  3. Hit Upload.
  4. Wait for "Connecting..." To appear
  5. Release the EN and then after a short while release the GPIO9

Is this sequence correct?

Also one change that I made this time is that I didn't include the flash chip would it be the reason?

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)

ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x1 (POWERON),boot:0xd (SPI_FAST_FLASH_BOOT)

If you're booting into download mode:

ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x1 (POWERON),boot:0x5 (DOWNLOAD(USB/UART0/1))

note the last line boot value.

If you're not seeing a difference when you reset, then you have a problem with your circuitry.

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

Schematic Prints.PDF (226.4 KB)
This is the schematics of the custom board I'm using

It appears to me that the ESP32-C3 needs a external flash chip for it to function. Can anyone please confirm this?

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