SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
User avatar
By SidPrice
#192751
I am trying to use esptool.py to connect to my new ESP32 Thing and I keep getting a timeout error, the error says:

"A fatal error occurred: Failed to connect to Espressif device: Timed out waiting for packet header.

The command I am executing is:

esptool.py --port COM15 chip_id

I have tried several other commands and they all result in the same error.

While a command is running the blue led pulses off for a short time.

Any clue what is happening? Is my eSP32 Thing dead?
Sid
By flodis
#198490
I am also trying to figure out why the esptool.py upload is unstable and works for low baud rates only.

At least the esptool.py has an, extremely, unusually, detailed documentation at : https://github.com/espressif/esptool

Anyway, setting the baudrate parameter of the esptool.py commands to something stupidly low like '-b 9600' worked for me. As soon as I get to '-b 38400' there are all sorts of random success uploading.

I have two ESP32 Thing boards and they both work the same.

Here is a typical slow upload using baud rate 19200 that works using precompiled binaries from Espressif IDF examples for bootloader, application and partition table files being uploaded. The %IDF_PATH% is a system variable pointing to the ESP-IDF root folder.

After upload the ESP32 Thing should blink its blue LED 1s ON, 1s OFF

From a Windows terminal window with python installed:
Code: Select all
C:>esptool.py --chip esp32 --port "COM58" --baud 19200 --before "default_reset" --after "hard_reset" write_flash -z --flash_mode "dio" --flash_ freq "40m" --flash_size "detect" 0x1000 "%IDF_PATH%/examples/get-started\blink/build/bootloader/bootloader.bin" 0x10000 "%IDF_PATH%/examples/get-started/blink/build/blink.bin" 0x8000 "%IDF_PATH%/examples/get-started/blink/build/partitions_singleapp.bin"
esptool.py v2.2
Connecting........__
Chip is ESP32D0WDQ6 (revision 1)
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Flash params set to 0x0220
Compressed 15776 bytes to 9172...
Wrote 15776 bytes (9172 compressed) at 0x00001000 in 4.8 seconds (effective 26.0
 kbit/s)...
Hash of data verified.
Compressed 182560 bytes to 54317...
Wrote 182560 bytes (54317 compressed) at 0x00010000 in 28.7 seconds (effective 5
0.9 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 82...
Wrote 3072 bytes (82 compressed) at 0x00008000 in 0.1 seconds (effective 307.2 k
bit/s)...
Hash of data verified.

Leaving...
Hard resetting...
Slow :(

Runing the exact same upload on an ESP32 Lolin lite board you can use baud rates of 460800!
Code: Select all
esptool.py --chip esp32 --port "COM57" --baud [b]460800[/b] --before "default_reset" --after "hard_reset" write_flash --compress --flash_mode "dio" --flash_freq "40m" --flash_size detect 0x1000 %IDF_PATH%/examples/get-started\blink/build/bootloader/bootloader.bin 0x10000 %IDF_PATH%/examples/get-started/blink/build/blink.bin 0x8000 %IDF_PATH%/examples/get-started/blink/build/partitions_singleapp.bin
With the speedy result upload time < 2 seconds!:
Code: Select all
esptool.py v2.2
Connecting....
Chip is ESP32D0WDQ6 (revision 1)
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Flash params set to 0x0220
Compressed 15776 bytes to 9172...
Wrote 15776 bytes (9172 compressed) at 0x00001000 in 0.2 seconds (effective 603.
8 kbit/s)...
Hash of data verified.
Compressed 182560 bytes to 54317...
Wrote 182560 bytes (54317 compressed) at 0x00010000 in 1.7 seconds (effective 84
1.2 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 82...
Wrote 3072 bytes (82 compressed) at 0x00008000 in 0.0 seconds (effective 4914.9
kbit/s)...
Hash of data verified.

Leaving...
Hard resetting...
(The Lolin32 has the blue inverted and attached LED to GPIO_NUM_22 instead of GPIO_NUM_5 so you need to compile your own blink code)

Notice - Once you uploaded the bootloader and the partition table you can modify and upload your application *.bin only. Compiler .elf to .bin conversion is also supplied by esptool.py.

Fast :)


Wonder how to get the ESP32 Thing up to speed?


For Windows users - I used Visual Studio Community Edition 2017 and VisualGDB 5.3 for the experiments. Fortunately Sysprogs have hinted they will release an ESP-IDF parser within weeks to be able to use unmodified ESP32-ISP libraries directly. That makes it easy for Win People to compile and upload ESP-32 without having to hang with the compiler nerds. If you come from the warm Arduino world you will feel a bit lost and stupid in the ESP32 one. It is improving with great speed though https://bbs.espressif.com/