Fixing esptool read_flash above 2MB on some cheap ESP32 boards
esptool
, the Espressif SoC serial bootloader utility, tends to dislike cheap Flash chips attached to the various incarnations of the ESP32 chip family. And it seems to dislike them even more when running esptool
on Linux than on other OSs.
The common error mode is seeing it break at the 2MB barrier when trying to dump (esptool read_flash
) a 4MB flash configuration.
will fail with
esptool.py v4.7.0 Serial port /dev/ttyUSB0 Connecting.... Detecting chip type... ESP32 Chip is ESP32-D0WD-V3 (revision v3.1) Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None Crystal is 40MHz [..] Detected flash size: 4MB [..] 2097152 (50 %) A fatal error occurred: Failed to read flash block (result was 01090000: CRC or checksum was invalid)
typically at the 2MB barrier.
I found the solution in a rather unrelated esptool Github issue:
Create an esptool.cfg
file in the project directory (from where you will run esptool
):
timeout = 30
max_timeout = 240
erase_write_timeout_per_mb = 40
mem_end_rom_timeout = 0.2
serial_write_timeout = 10
The timeout = 30
is the setting that fixed reading flash memory via esptool read_flash
for me.
When your esptool.cfg
is read, esptool
will tell you so in its second line of output:
esptool.py v4.7.0 Loaded custom configuration from /home/dl/[..]/Embedded_dev/ESP-32_Wemos/esptool.cfg Found 1 serial ports Serial port /dev/ttyUSB0 Connecting...... [..]
Thank you Radim Karnis and wibbit from the Github issue linked above.
Comments
Display comments as Linear | Threaded
AlexeyMak on :
Thank you very much!