Skip to content

flash --ram: the monitor resets the RAM application, no check for overlap with the flash stub, app descriptor required #1134

Open

Description

@SergioGasquez

Bug description

espflash flash --ram has three problems that together make RAM loading hard to use from the CLI:

  1. --monitor resets the RAM application away. The monitor runs its reset (reset_after_flash, monitor/mod.rs:112) unless no_reset is set. skip_monitor_reset_after_flash is only called on the flash path, and --after no-reset doesn't change this. The chip then boots the application in flash, so the RAM application can't be monitored with espflash.
  2. 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 in mem_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 contain text_start, data_start and bss_start. The regions are large, e.g. ESP32-C61 BSS 0x40810000..0x40822e34 and ESP32-C5 BSS 0x40840000..0x40852fe4, so a RAM application linked at the start of SRAM is likely to hit them.
  3. The ESP-IDF app descriptor is required. flash runs check_idf_bootloader (espflash.rs:273) before branching on --ram. A RAM image never goes through the second-stage bootloader, so it needs --ignore-app-descriptor for no reason. The check also runs after connecting (see flash resets 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.

  1. Monitor (ESP32-C5, USB-Serial-JTAG): espflash flash --ram --ignore-app-descriptor -M ram_c5.elf (image at 0x40810000, clear of the C5 stub). RAMOK is printed until the monitor resets the chip, and then the flash application runs:
    INFO ] Using flash stub
      13 RAMOK
       1 rst:0x15 (USB_UART_HPSYS),boot:0x18 (SPI_FAST_FLASH_BOOT)
      12 INFO - Hello world!
    
    The result is the same with --after no-reset, and on ESP32-C2 over a CP2102N.
  2. Stub overlap: the same image on ESP32-C61 (UART), where 0x40810000 is the start of the stub's BSS:
    Error:   × Communication error while flashing device
      ╰─▶ Timeout while running MemEnd command
    
    The same happens on ESP32-C2 with an image at 0x40380000 (the stub's text_start), and on ESP32-C5 with an image at 0x40800000. With --no-stub, the same images load and run.
  3. 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 --monitor monitors the RAM application without resetting it. esptool's load-ram deliberately 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-stub or move the image.
  • The app descriptor check is skipped for --ram.

Environment

  • OS: macOS 27.2.1 (Apple silicon)
  • espflash/cargo-espflash version: main at 466dab5 (4.7.0)
  • Target: ESP32-C2 (CP2102N), ESP32-C61 (CP2102N), ESP32-C5 (USB-Serial-JTAG), ESP32-S3 (USB-Serial-JTAG)

Activity

  1. added
    bug
    CLI
    on Nov 16, 2026
  2. moved this from Todo to Review in esp-rs on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIbug

    Type

    No type

    Projects

    • Status
      Review

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions