Issue with programming/flashing ESP32

evanfahy
Posts: 4
Joined: Fri Mar 13, 2020 9:27 am

Issue with programming/flashing ESP32

Postby evanfahy » Fri Mar 13, 2020 2:00 pm

Hi guys,

I'm working with an inherited custom board which is using an esp32-d0wdq6. When programming I get an error stating "Failed to connect to ESP32: Timed out waiting for packet header" and "ESP32 Chip sync error esp_sync_blocking".

I have tried various programming tools to flash the chip such as Arduino(esptool.exe), esptool.py, flash_download_tools_v3.6.8. Also, I am using a TTL-232R-3V3 USB to TTL converter to interface with the board. I've had previous experience with programming an esp32-PICO in another project which was in-circuit and I've programmed with this method and experienced no issues. All I had to do was hold GPIO0 LOW and toggle the RST and it flashed perfectly

The esp32 is placed in circuit to be programmed via USB, however I have bypassed this and connected directly to the chip's I/O pins and powering directly via PSU (because the chip is currently not programmed and the USB is not being detected). I can't share any circuit schematics but I can detail the strapping pins I have configured for downloading (Although I believe the circuit is very similar to that of the esp32-DEVKIT).

I have read many forums stating how to configure the strapping pins and I think I have done so correctly:

GPIO0 - held at 0V
GPIO2 - floating
MTDI - held at 0V
CHIP_PU - Toggled manually 0V to VCC to enter programming mode

Toggling the CHIP_PU from LOW to HIGH I get an output of the following seen on PUTTY:
  1. ets Jun  8 2016 00:22:57
  2.  
  3. rst:0x1 (POWERON_RESET),boot:0x3 (DOWNLOAD_BOOT(UART0/UART1/SDIO_REI_REO_V2))
  4. waiting for download
When I attempt to program the chip I get a timeout consistently.

I have an older version of the circuit which is in production, and programmable through the USB. There's been no changes in the current hardware design to affect the programming. I tried flashing the old circuit with the direct connection method via the USB to TTL converter, I get the same issue.

Reverting back to programming the old circuit with USB, it programs successfully. I monitored the GPIO0 and CHIP_PU lines during a successful program by the Arduino IDE and I caught the following:
scope_33.png
Yellow ch: GPIO0
Green ch: CHIP_PU
scope_33.png (19.73 KiB) Viewed 20792 times


This sequence of toggling seems quite complicated and it isn't stacking up with what I'm reading on the internet. Is it a matter of holding GPIO0 at LOW and toggling CHIP_PU? Or is it much more complicated sequence of handshakes? Is it possible to piggy back off an esp programmer or a devkit?

I hope you can help out :D

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Issue with programming/flashing ESP32

Postby WiFive » Sat Mar 14, 2020 8:54 am

If you get "waiting for download" you're doing the strapping correctly. Could be a problem with the tx of your usb adapter.

chegewara
Posts: 2207
Joined: Wed Jun 14, 2017 9:00 pm

Re: Issue with programming/flashing ESP32

Postby chegewara » Sat Mar 14, 2020 9:28 pm

Try MTDI pull HIGH. When MTDI is wrongly pulled then you can enter download mode:
"waiting for download"
but you wont be able to upload code, it will end up with something like that:

Code: Select all

Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Warning: Could not auto-detect Flash size (FlashID=0xffffff, SizeID=0xff), defaulting to 4MB
Compressed 8192 bytes to 47...

A fatal error occurred: Timed out waiting for packet content
A fatal error occurred: Timed out waiting for packet content
If you wont get this, then MTDI most likely is fine:
Warning: Could not auto-detect Flash size (FlashID=0xffffff, SizeID=0xff), defaulting to 4MB
https://github.com/espressif/esptool/wi ... -Selection

evanfahy
Posts: 4
Joined: Fri Mar 13, 2020 9:27 am

Re: Issue with programming/flashing ESP32

Postby evanfahy » Mon Mar 16, 2020 11:02 am

WiFive wrote:
Sat Mar 14, 2020 8:54 am
If you get "waiting for download" you're doing the strapping correctly. Could be a problem with the tx of your usb adapter.
I did a quick check of the Tx of the USB adaptor, using a serial monitor and shorting the Tx and Rx. I'm echoing back all transmits so I think the Tx is functional?

evanfahy
Posts: 4
Joined: Fri Mar 13, 2020 9:27 am

Re: Issue with programming/flashing ESP32

Postby evanfahy » Mon Mar 16, 2020 11:09 am

chegewara wrote:
Sat Mar 14, 2020 9:28 pm
Try MTDI pull HIGH. When MTDI is wrongly pulled then you can enter download mode:
"waiting for download"
but you wont be able to upload code, it will end up with something like that:

Code: Select all

Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Warning: Could not auto-detect Flash size (FlashID=0xffffff, SizeID=0xff), defaulting to 4MB
Compressed 8192 bytes to 47...

A fatal error occurred: Timed out waiting for packet content
A fatal error occurred: Timed out waiting for packet content
If you wont get this, then MTDI most likely is fine:
Warning: Could not auto-detect Flash size (FlashID=0xffffff, SizeID=0xff), defaulting to 4MB
https://github.com/espressif/esptool/wi ... -Selection
I tried your suggestion of pulling MDTI HIGH and I got the same error. When using Arduino to download the program this is the error I see everytime:

Code: Select all

Sketch uses 1276061 bytes (60%) of program storage space. Maximum is 2097152 bytes.
Global variables use 67936 bytes (20%) of dynamic memory, leaving 259744 bytes for local variables. Maximum is 327680 bytes.
C:\Users\alank\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\2.6.1/esptool.exe --chip esp32 --port COM7 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0xe000 C:\Users\alank\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.3/tools/partitions/boot_app0.bin 0x1000 C:\Users\alank\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.3/tools/sdk/bin/bootloader_dio_80m.bin 0x10000 C:\WINDOWS\TEMP\arduino_build_448199/AGC_v1.ino.bin 0x8000 C:\WINDOWS\TEMP\arduino_build_448199/AGC_v1.ino.partitions.bin 
esptool.py v2.6
Serial port COM7
Connecting........_____....._____....._____....._____....._____....._____....._____

A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header
A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header

chegewara
Posts: 2207
Joined: Wed Jun 14, 2017 9:00 pm

Re: Issue with programming/flashing ESP32

Postby chegewara » Thu Mar 19, 2020 5:51 pm

I see here progress. This is not the same error:
Connecting........_____....._____....._____....._____....._____....._____....._____

A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header
A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header
Usually this means that you need to use EN and BOOT buttons to enter download mode. Usually which does not mean its your case, but worth to try.

rufus477
Posts: 1
Joined: Mon Mar 23, 2020 5:41 am

Re: Issue with programming/flashing ESP32

Postby rufus477 » Mon Mar 23, 2020 5:48 am

Some ESP32 development boards don’t go into flashing/uploading mode automatically when uploading a new code.

When you try to upload a sketch to the ESP32, the Arduino IDE fails to connect to your board, and you get the following error message:
Fatal Error Occurred: “Failed to connect to ESP32: Timed out waiting for packet header”

There is a link below to an article on how to fix this issue by adding a 10 uF electrolytic capacitor between the EN pin and GND

https://randomnerdtutorials.com/solved- ... et-header/

This should help alleviate the issue.

evanfahy
Posts: 4
Joined: Fri Mar 13, 2020 9:27 am

Re: Issue with programming/flashing ESP32

Postby evanfahy » Thu Apr 02, 2020 10:13 am

All sorted guys. It was a hardware issue. Thanks to all! :D

halilarkl07
Posts: 10
Joined: Thu May 07, 2020 9:09 am

Re: Issue with programming/flashing ESP32

Postby halilarkl07 » Mon Nov 30, 2020 11:51 am

Hi,
I have a similar problem, could you share your solution pls?

sdg123
Posts: 3
Joined: Tue Nov 02, 2021 4:58 pm

Re: Issue with programming/flashing ESP32

Postby sdg123 » Tue Aug 01, 2023 8:04 pm

evanfahy wrote:
Thu Apr 02, 2020 10:13 am
All sorted guys. It was a hardware issue. Thanks to all! :D
HI, What was the hardware issue? How did you fix it?

Who is online

Users browsing this forum: No registered users and 56 guests