madhusudanlive logo
Stay Zen!

[Solved] ESP32 header packet-timeout issue

While programming ESP32, you may have encountered the header packet-timeout issue. here is how you can fix this.
[Solved] ESP32 header packet-timeout issue

Hey guys, I'm Krypton, in this article, I will tell you how you can fix the ESP32 program uploading issue. So basically, while programming ESP32, you may have encountered the following error:

esptool.py v2.6
Serial port /dev/ttyUSB0
Connecting........**\_**.....\_
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
MAC: XX:XX:XX:XX:XX:XX
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Warning: Could not auto-detect Flash size (FlashID=0x0, SizeID=0x0), defaulting to 4MB
Compressed 8192 bytes to 47...
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 7370.2 kbit/s)...

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

The problem

screenshot: Timed out waiting for packet header
ESP32 Packet Header Issue

First of all, there is no proper documentation available for this error, so rectifying it becomes tough, but this is not a programming or compilation error even with a blank sketch, you may encounter this error. some issues on github say that pressing the reset button while holding the boot button solves this, but probably that's not the solution, I have tried on 2 of my boards but doing so boots my device into download mode and this is what I get on the serial monitor rst:0x1 (POWERON_RESET),boot:0x3 DOWNLOAD_BOOT(UART0/UART1/SDIO_REI_REO_V2)) waiting for download` I'm not sure about this one probably it is something related to boot-loader but this is definitely what we want.

Solution

So before moving towards the solution:

  • first of all clear all the connections of ESP32
  • Make sure that there are no connections at least to the RX0, and TX0.
  • Hit the upload button on Arduino IDE or platformIO
  • when you see the Connecting..................____... message just hold the BOOT button and that's it
  • it will automatically detect the ESP32 hardware and start flashing it, you'll be displayed messages like Writing at 0x00008000... (100 %) on your screen
  • Once you see that screen you can release the BOOT button. ESP32: Code flashed successfully ESP32: Code flashed successfully
Screenshot of ESP32 upload success
ESP32 upload success

Note: This will fix the issue but even if you are not able to flash the code then there is something wrong with your configuration, check your board, there are several ESP32 variants available in Arduino so chances are that you might have selected the wrong board than your hardware

Conclusion

From my observation, I guess this error is caused due to the usage of UART pins while flashing, I was able to successfully flash the code when I removed the connections of RX & TX. that's all! thank you for visiting my site, keep visiting for the latest posts!!!


photo of Madhusudan Babar
Say Hello

Thanks for visiting my site, if you have any questions or just want to say hello, feel free to reach out to me. You can also mail me directly at krypton@madhusudan.live