Page 1 of 1

esptool read_flash fails with too-short read

Posted: Tue Apr 25, 2023 1:48 am
by banjoluck
Using esptool 4.5.1 on MacOS, I get something like the following message from three different modules when I attempt to read flash:

( /opt/homebrew/bin/esptool.py --chip auto --port /dev/tty.usbserial-DU0CLKHM --baud 460800 \
read_flash 0x9000 0x6000 nvs.bin )
esptool.py v4.5.1
Serial port /dev/tty.usbserial-DU0CLKHM
Connecting....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting....
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision v3.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: c0:49:ef:eb:9c:28
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.

A fatal error occurred: Corrupt data, expected 0x1000 bytes but received 0xf6c bytes
gmake: *** [Makefile:153: nvs] Error 2

Re: esptool read_flash fails with too-short read

Posted: Tue Apr 25, 2023 3:28 am
by ESP_Sprite
Your baud rate may be too fast. Try a slower baud rate.

Re: esptool read_flash fails with too-short read

Posted: Tue Apr 25, 2023 4:54 pm
by banjoluck
That was the issue. Setting the baudrate to 230400 works.

The espressif documentation has this as an explicit example:

Code: Select all

esptool.py -p PORT -b 460800 read_flash 0 0x200000 flash_contents.bin
See https://docs.espressif.com/projects/esp ... read-flash.

Re: esptool read_flash fails with too-short read

Posted: Wed Apr 26, 2023 1:41 am
by ESP_Sprite
Yeah, the max baud rate you can use depends on the setup (usb-serial chip, connection wires etc). On a devboard, that baudrate probably works fine, but on unknown hardware, all bets are off.