esp-serial-flasher: Writing >= 16MB addresses not working (ESF-106)
Port
USER_DEFINED
Target chip
ESP32-S3
Hardware Configuration
Custom ESP32-S3 board connected via USB CDC
Log output
Found 2 serial ports
Connecting to ttyACM0
Found esp32s3
Flash will be erased from 0x0 to 0x5fff
Flash size detection failed, falling back to default
Writing at 0x400... (4%)
Writing at 0xc00... (14%)
Writing at 0x1400... (23%)
Writing at 0x1c00... (33%)
Writing at 0x2400... (42%)
Writing at 0x2c00... (52%)
Writing at 0x3400... (61%)
Writing at 0x3c00... (71%)
Writing at 0x4400... (80%)
Writing at 0x4c00... (90%)
Flash will be erased from 0x10000 to 0x164fff
Flash size detection failed, falling back to default
Writing at 0x10400... (0%)
Writing at 0x32400... (10%)
Writing at 0x54400... (20%)
Writing at 0x76400... (30%)
Writing at 0x98400... (40%)
Writing at 0xba400... (50%)
Writing at 0xdc400... (60%)
Writing at 0xfe400... (70%)
Writing at 0x120400... (80%)
Writing at 0x142800... (90%)
Writing at 0x1644e0... (100%)
Flash will be erased from 0x1010000 to 0x1ffffff
Flash size detection failed, falling back to default
Error:
COMMAND_FAILED
Erasing flash failed (ESP_LOADER_ERROR_INVALID_RESPONSE)
Cannot connect to target (ESP_LOADER_ERROR_INVALID_RESPONSE)
More Information
I’ve written a small native CLI/GUI application much like the Espressif Flash Download Tool to make downloading multiple binaries easier. So far I’ve tested this app with the hello_world example on various Espressif demo boards. Uploading the example (consisting of bootloader, app and partition table) works flawlessly.
Thinking that my app works I’ve moved on to trying to flash my current project on a custom ESP32-S3 board. The projects flash files are
"flash_files" : {
"0x0" : "bootloader/bootloader.bin",
"0x10000" : "WULF.bin",
"0x8000" : "partition_table/partition-table.bin",
"0xa000" : "ota_data_initial.bin",
"0x1010000" : "storage.bin",
"0x810000" : "nvs.bin"
}
As you can probably guess some of those binaries are bigger than the hello_world example
# ESP-IDF Partition Table
# Name, Type, SubType, Offset, Size, Flags
phy_init, data, phy, , 4K,
otadata, data, ota, , 8K,
ota_0, app, ota_0, , 4M,
ota_1, app, ota_1, , 4M,
nvs, data, nvs, , 8M,
storage, data, spiffs, , 16320K,
Uploading those bigger binaries does not work. I’m getting the following output from the library (see full log above)
Error:
COMMAND_FAILED
I assume that for some reason the library can’t handle certain memory region or binary sizes (yet)? This might also be related to #23? Any suggestions? Is this a known issue?
About this issue
- Original URL
- State: open
- Created 6 months ago
- Comments: 41 (24 by maintainers)
If you only need to support the chips which are mass-produced, then you don’t have to worry about the
-betaones. Those are engineering samples used internally in Espressif for a limited amount of time (until the final version of the chip gets produced) and sometimes delivered to a limited number of customers.@higaski Continuing the discussion at https://github.com/espressif/esp-idf/issues/8365#issuecomment-2003119377, here are some pointers about the flasher stub.
The stub source code is available in https://github.com/espressif/esptool/tree/master/flasher_stub. I think you probably don’t need to build the stub from source in this particular case, and it is simpler to get the compiled stubs from https://github.com/espressif/esptool/tree/master/esptool/targets/stub_flasher. Each of the JSON files contains base64-encoded .text and .data segments, as well as their load addresses. There is also the entry point address. The flasher tool needs to upload the .text and .data segments to the correct addresses, then instruct the ROM loader to jump to the entry point.
I think what might help you is to run
esptool.py read_macwith the--traceoption and see the commands sent by esptool.py betweenUploading stub...andStub running...messages.Another implementation of uploading the stub can be found in esptool-js project, in case it helps: https://github.com/espressif/esptool-js/blob/7ed57e18642088675bec01b8e34ba196d5e135af/src/esploader.ts#L1142-L1188.
Hello @higaski , it appears the flasher stub used by
esptooland other flashing tools we provide has special logic for chips of 16MB or more in size. It will take me some time probably to investigate how we can adaptesp-serial-flasherto do the same and test it.Good spot, it seems that is the reason
loader_spi_parameters()sends wrong info. I will investigate this, in the meantime, try manually setting the parameters for your flash chip and trying to flash that way.