ESP32 boot loop: “invalid header: 0xffffffff” or “flash read err”

The ROM bootloader could not read a valid program from flash. Either flash holds no valid image, or a strapping pin was held in the wrong state at reset and changed how the chip boots.

What the message means

At every reset the ESP32 reads a few strapping pins to decide how to start. If a wired part pulls one of them the wrong way, the chip may read flash badly or not at all, and the log shows invalid header values or flash read errors.

Fix it in this order

  1. Unplug everything from the GPIO pins and reset. If it boots, a connected part is pulling a strapping pin.
  2. Keep GPIO 0, 2, 5, 12 and 15 free of loads that pull them at start-up. GPIO 12 held high at reset is a known cause of flash errors on boards with 3.3 V flash.
  3. Erase the flash completely with your upload tool, then upload the sketch again.
  4. Check the partition scheme and flash size under Tools match the module.
  5. Check the supply. A brownout during flashing leaves a damaged image.
  6. If it still fails after an erase, suspect the module itself.

Why it happens

These messages mean the chip could not read a valid program from flash. The usual causes are a corrupted upload, the wrong flash mode or size settings, or a weak supply during the write.

Erase the flash and upload again. With esptool you can run erase_flash, or choose the erase option in your tool. Use a good cable and supply, and check the board settings in the Tools menu.

If you see this, do this

You seeDo this
It boots with the pins disconnectedA strapping pin was loaded. Re-route that signal.
It fails right after an uploadErase flash and upload again over a better cable.
It never boots even bareThe module or its flash may be faulty.

ESP32 pinout for robotics, ESP32 failed to connect.

Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.

Why this happens

When the ESP32 resets, the ROM code reads a small header from the start of the program area in flash. On the classic ESP32 the second-stage bootloader lives at offset 0x1000, and its first byte should be 0xE9. Erased flash reads as all ones, so a header of 0xffffffff means that location is blank or could not be read at all.

Two different things produce that result. Either nothing valid was written, for example after an interrupted upload or a wrong flash setting, or flash exists but the chip cannot talk to it, which is where strapping pins and supply voltage come in. Splitting these two cases is the whole job.

How to confirm the cause

  • Disconnect everything from the GPIO pins and power the board from USB only. If it now boots, one of your parts is pulling a strapping pin at reset.
  • Run esptool flash_id. If it prints the chip type, flash size and manufacturer, the chip and flash talk to each other. If it fails to detect the flash, suspect hardware or supply.
  • Read the first bytes at 0x1000 and look at the first byte. 0xE9 means a bootloader is present; 0xFF means blank flash.
  • Watch the 3.3 V pin with a multimeter while uploading. A dip below about 3.0 V suggests a weak cable or port.
  • Try another USB cable and port. A charge-only or thin cable is a common cause of broken uploads.

Worked example

These commands assume the board is on COM5. Newer versions of esptool also accept hyphenated names such as flash-id; esptool.py works too.

esptool.py --port COM5 flash_id
esptool.py --port COM5 erase_flash
esptool.py --port COM5 read_flash 0x1000 16 head.bin
# Windows: Format-Hex head.bin
# first byte E9 = bootloader present, FF = blank flash

After erase_flash, a blank read of FF is expected until you upload again. If a fresh upload completes and the first byte at 0x1000 is E9 but the board still loops, look at strapping pins and supply, not the image.

Common mistakes

  • Erasing and re-uploading over and over without testing the cable or supply.
  • Leaving a motor driver, button or sensor on GPIO 12 or GPIO 0 during reset.
  • Choosing a flash size in the board menu that is larger than the module really has.
  • Using a different chip’s bootloader offset, since newer variants such as the S3 and C3 use 0x0 not 0x1000.

If this did not fix it

  • Wrong partition scheme: choose one that fits the real flash size.
  • Supply brownout: see the ESP32 brownout page’s checks for current and capacitor.
  • Damaged flash on a clone module: flash_id will fail or give nonsense, and replacing the module is the fix.