ESP32 Flash Read Error
Troubleshoot and resolve flash read errors on ESP32 boards, including corrupted memory, incorrect flash settings, and unstable power. Learn how to identify, erase, and recover from SPI flash failures during boot or after upload.
Common Causes
- ๐พ
Corrupted Flash Memory
Flash contents can become corrupted due to interrupted writes, failed uploads, or poor power quality during flash operations.
- โ๏ธ
Incorrect Flash Settings
Wrong flash mode (e.g., QIO vs. DIO), size, or frequency in the IDE can prevent the ESP32 from reading its own firmware correctly.
- ๐ง
Hardware Fault in Flash or ESP32 Module
Faulty onboard flash chips or a damaged ESP32 SoC can cause read failures or prevent proper firmware execution.
- ๐
Power Supply Instability During Flash Access
Flash memory is sensitive to voltage dips during read/write operations. An unstable or inadequate power supply may cause intermittent or repeatable read errors.
Symptoms
Boot Fails with Flash Read Error
Serial monitor shows messages like
SPI_FLASH_READ ERROR
Invalid head of packet
or continuous reboots after startup.
Upload Completes but Code Doesnโt Run
Firmware appears to upload normally, but the board either resets repeatedly or shows corrupted output during boot.
Works with Minimal Sketch but Not with Larger Ones
Simple code may run, but sketches with more flash usage fail to boot, suggesting marginal stability or flash size setting issues.
Solutions
Check and Adjust Flash Settings in IDE
Verify the correct flash mode, frequency, and size are set in the Arduino IDE or PlatformIO. Try lowering the flash frequency (e.g., from 80 MHz to 40 MHz).
Perform a Full Erase Before Uploading
Use esptool.py
or your IDEโs โErase Flashโ option to fully wipe the chip before uploading new firmware. This removes any remnants of corrupt or mismatched data.
Use a Stable Power Supply
Ensure your ESP32 is powered from a clean, <a href="/troubleshooting/issues/power/brownout-reset/">regulated 5V source with sufficient current, especially during flashing or heavy I/O operations.
Test with a Different Board
If problems persist after checking settings and power, try uploading the same code to another ESP32 to rule out hardware faults.
More Details
ESP32 Flash Read Error #
If your ESP32 fails to boot and shows flash-related errors in the serial monitor โ like
SPI_FLASH_READ ERROR
or
Invalid head of packet
itโs likely having trouble accessing its flash memory.
This can happen due to configuration issues, corrupted flash contents, power instability, or even hardware damage.
Common Situations #
- The ESP32 reboots immediately after reset or upload
- Serial monitor shows cryptic errors involving SPI flash
- Your code uploads fine, but never runs
- Larger sketches fail while minimal ones work
- Issues appear after a brownout or power loss
Why It Happens #
๐ง Corrupted Flash #
Interrupted writes or failed uploads can leave the flash in an inconsistent state. If the bootloader or firmware header is damaged, the ESP32 may reset endlessly trying to read it.
โ๏ธ Wrong Flash Settings #
The ESP32โs flash mode (QIO/DIO), frequency (80/40 MHz), or size must match the actual flash chip. Misconfigured settings may work intermittently or not at all.
๐ง Flash Hardware Issues #
Cheap boards may use lower-quality flash chips or may be physically damaged. Excessive reflows or ESD damage can silently kill flash reliability.
๐ Power Instability #
Voltage dips during flashing or boot-up can corrupt reads or writes. Flash chips are sensitive to these drops, especially during high current draw like Wi-Fi startup.
How to Fix It #
โ
1. Recheck Flash Settings in IDE
In Arduino IDE:
- Go to Tools > Flash Frequency โ try lowering to 40MHz
- Check Flash Mode โ use DIO if QIO fails
- Ensure Flash Size matches your board (e.g., 4MB)
โ
2. Perform a Full Chip Erase
Using the command line:
esptool.py --chip esp32 --port COMx erase_flash
Or, in Arduino IDE:
Use the Erase Flash: All Flash Contents option before uploading.
โ
3. Use a Stable Power Source
Unstable 5V or USB power can cause flashing errors. Use:
- A known-good USB cable
- A wall adapter instead of a laptop port
- Capacitors near the ESP32โs 3.3V line
โ
4. Swap Boards to Isolate Hardware
Upload the same sketch to another ESP32. If it works there, your original board may have faulty flash or a weak regulator.
Serial Monitor Example #
rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
invalid header: 0x00
flash read err, 1000
ets_main.c 371
This suggests the bootloader failed to read the firmware header from flash.
Summary #
Flash read errors are frustrating but often solvable. Start with software: erase the chip and double-check settings. If problems persist, suspect power or hardware.

Quick Navigation
Additional Resources
Still Stuck with an ESP32 Issue? Let's solve it together.
Our interactive troubleshooting wizard will guide you through common ESP32 problems and their solutions, step by step.