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

> Fix an ESP32 that boot-loops with invalid header 0xffffffff or flash read err 1000: strapping pins, erase and reflash, and power.

Canonical: https://roboticsengineering.in/fix/esp32-invalid-header-flash-read-err/ | Published: 2026-11-03 | Updated: 2026-11-03

**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 see | Do this |
| --- | --- |
| It boots with the pins disconnected | A strapping pin was loaded. Re-route that signal. |
| It fails right after an upload | Erase flash and upload again over a better cable. |
| It never boots even bare | The module or its flash may be faulty. |

## Related

[ESP32 pinout for robotics](https://roboticsengineering.in/esp32-pinout-for-robotics/), [ESP32 failed to connect](https://roboticsengineering.in/fix/esp32-failed-to-connect-timed-out-waiting-for-packet-header/).

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.
