Unable to flash ESP32

So I got myself an ESP32 and flashed it as a bluetooth proxy via the webtools (ESPHome Bluetooth Proxy)

This all worked nicely but then I decided I wanted to redo the device so installed ESP Home docker and have tried to flash it again with an updated definition.

However now the device just won’t flash and things just sit there stuck on preparing installation (I have left it for an hour) and no matter what I try it just won’t flash or respond to just about anything now.

Possibly not the wisest of moves but I attempted to follow a factory resett based on this (ESP32 Factory Reset, Erase EEPROM and Repair Bootloader using Online ESPtool- Most Easiest Way - YouTube) but even when using the Espressif tools it connects but then times out almost instantly

esptool.js v0.1-dev
Serial port WebSerial VendorID 0x10c4 ProductID 0xea60
Connecting.......
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision 3)
Features: Wi-Fi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: xx:xx:xx:xx:xx:xx
Uploading stub...
Running stub...
Stub running...
Changing baudrate to 115200
Changed
Erasing flash (this may take a while)...
Error: Timeout
Erasing flash (this may take a while)...
Error: Timeout
Erasing flash (this may take a while)...
Error: Timeout
Erasing flash (this may take a while)...
Chip erase completed successfully in 0.002s
``
where first timeout was instant, second took about 10 seconds, third was instant and then it instantly told me the erase was complete.

If I look in logs in ESP Home I just get

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
ets Jul 29 2019 12:21:46

repeated thousands of times with the same timestamp.   I have let it run for about 20 minutes and it is still repeating but it is starting to cause Chrome to lock up due to the size of the log.

Any suggestions on how I can get the controller back into the same state as when it was shipped so I can actually flash it?

How did you try to reflash? OTA? Serial? You should do serial ESPHome 2022.12.0 - 14th December 2022 — ESPHome

Serial (USB). Not sure what I did but I ended up being able to flash it at like the 100th time last night and is working.

I am going to have another play later on to see if I can replicate it (Although may use a spare ESP32 board this time…)

1 Like

If you power it through the serial connection during flashing, then the power might be too unstable and especially the erasing requires a lot of stable power, so that is usually the time of failure.

Did you ever find out how you fixed the issue? I seem to having the same symptoms.

Edit: I plugged a fresh ESP32 in to the computer and it worked as expected. Now I am struggling to “fix” the first one that is giving me these issues.

I think I deleted the build folder from ESP home and it then worked

I have unbricked a few devices with these:

// most basic, always useful
esptool.py erase_flash
// this unbricked a lot of third-party ESP-s which sometimes got a wrong header address at OTA
esptool.py write_flash_status --non-volatile 0
// might be useful
espefuse.py set_flash_voltage 3.3V
// clearly define what to write and where
esptool.py --chip esp32 --baud 921600 --before default_reset --after hard_reset write_flash -z 0x0 xx.bin --flash_mode dio --flash_freq 80m --flash_size detect

Also useful to make sure you have adequate USB power behind it, remove all peripherals from GPIO, and power from high quality source. My Mac dock usb-C to USB sometimes isn’t enough…

2 Likes