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.