Thanks brad for explaining your use case.
braddd wrote: ↑Wed Feb 10, 2021 6:05 pm
I can now flash the whole chip but it appears the ROM loader just can't erase past 200000. But you can write the remainder as 0xFF so it's no big deal.
I was curious about this, but I can't reproduce it. I can generate 4MB of random data and flash it with esptool via the ROM loader, no problems.
Code: Select all
$ dd if=/dev/urandom of=random.bin bs=1MB count=4
4+0 records in
4+0 records out
4000000 bytes (4.0 MB, 3.8 MiB) copied, 0.0876904 s, 45.6 MB/s
$ esptool.py --no-stub -p /dev/ttyUSB1 -b 921600 write_flash -fs 4MB 0x0 random.bin
esptool.py v3.1-dev
Serial port /dev/ttyUSB1
Connecting.....
Detecting chip type... ESP32
Chip is ESP32-D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, VRef calibration in efuse, BLK3 partially reserved, Coding Scheme 3/4
Crystal is 40MHz
MAC: 30:ae:a4:5b:5a:28
Changing baud rate to 921600
Changed.
Enabling default SPI flash mode...
Configuring flash size...
Erasing flash...
Took 9.39s to erase flash block
Wrote 4000768 bytes at 0x00000000 in 125.0 seconds (256.0 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
However, I can reproduce your results if I don't pass the "-fs 4MB" argument to esptool, which causes it to skip sending the command to configure the SPI flash parameters (this is something we should fix in esptool). The ROM default flash chip size (if no parameters are sent) is 2MB, so any attempt to erase past 2MB fails in exactly the way you describe (the command 0x02 "flash begin" command returns an error result with error code 6 if it thinks the erase goes outside the bounds of the flash chip).
The configuration only needs to be done once because it saves the settings. That's why you can't enter any more commands after configuring. You don't really need to
That's not quite right, "settings" aren't saved anywhere persistent by the ROM loader itself (the "spi parameters" command updates a structure in RAM.) In the case of esptool, this command is sent when it prints "Configuring flash size..." which sets the paramters before it issues all of the flashing commands. There must be something not quite right about the format of this command (either the structure on the wire, or the contents of the fields) which causes the ROM loader to go into a bad state.