Repository navigation
Open
Description
Bug description
espflash flash --ram has three problems that together make RAM loading hard to use from the CLI:
--monitorresets the RAM application away. The monitor runs its reset (reset_after_flash,monitor/mod.rs:112) unlessno_resetis set.skip_monitor_reset_after_flashis only called on the flash path, and--after no-resetdoesn't change this. The chip then boots the application in flash, so the RAM application can't be monitored with espflash.- There's no check for overlap with the flash stub. With the stub (the default), a RAM segment that overlaps the stub's text, data or BSS overwrites the running stub. espflash then reports
Timeout while running MemEnd command. esptool refuses up front inmem_begin: "Stub flasher is resident at 0x…-0x…. Can't load binary at overlapping address range 0x…-0x…. Either change binary loading address, or disable the stub flasher." The stub TOML files already containtext_start,data_startandbss_start. The regions are large, e.g. ESP32-C61 BSS0x40810000..0x40822e34and ESP32-C5 BSS0x40840000..0x40852fe4, so a RAM application linked at the start of SRAM is likely to hit them. - The ESP-IDF app descriptor is required.
flashrunscheck_idf_bootloader(espflash.rs:273) before branching on--ram. A RAM image never goes through the second-stage bootloader, so it needs--ignore-app-descriptorfor no reason. The check also runs after connecting (seeflashresets the device before checking the ELF file #1133).
- I have searched the existing issues (closed & open) to make sure the issue hasn't already been reported
- Check this box if you would like to work on a fix
To Reproduce
The test images are minimal bare-metal programs that write RAMOK to UART0 and to USB-Serial-JTAG in a loop, with all segments in SRAM.
- Monitor (ESP32-C5, USB-Serial-JTAG):
espflash flash --ram --ignore-app-descriptor -M ram_c5.elf(image at0x40810000, clear of the C5 stub).RAMOKis printed until the monitor resets the chip, and then the flash application runs:The result is the same withINFO ] Using flash stub 13 RAMOK 1 rst:0x15 (USB_UART_HPSYS),boot:0x18 (SPI_FAST_FLASH_BOOT) 12 INFO - Hello world!--after no-reset, and on ESP32-C2 over a CP2102N. - Stub overlap: the same image on ESP32-C61 (UART), where
0x40810000is the start of the stub's BSS:The same happens on ESP32-C2 with an image atError: × Communication error while flashing device ╰─▶ Timeout while running MemEnd command0x40380000(the stub'stext_start), and on ESP32-C5 with an image at0x40800000. With--no-stub, the same images load and run. - Without
--ignore-app-descriptor:Error: × ESP-IDF App Descriptor (...) missing in your`esp-idf` application.
- I have reproduced the bug in main branch too
Without -M, the RAM application keeps running after espflash exits (checked on ESP32-C2, C5, C61 and S3), so the post-operation reset isn't the problem.
Expected behavior
flash --ram --monitormonitors the RAM application without resetting it. esptool'sload-ramdeliberately doesn't reset afterwards ("Exiting immediately").- Loading a segment that overlaps the running stub fails before anything is written, with esptool's error and a hint to use
--no-stubor move the image. - The app descriptor check is skipped for
--ram.
Environment
- OS: macOS 27.2.1 (Apple silicon)
- espflash/cargo-espflash version:
mainat 466dab5 (4.7.0) - Target: ESP32-C2 (CP2102N), ESP32-C61 (CP2102N), ESP32-C5 (USB-Serial-JTAG), ESP32-S3 (USB-Serial-JTAG)
Activity