Repository navigation
Make flash --ram usable with the monitor and the stub - #1149
Open
SergioGasquez wants to merge 2 commits into
Open
SergioGasquez wants to merge 2 commits into
SergioGasquez wants to merge 2 commits into
Conversation
SergioGasquez
force-pushed
the
fix/flash-ram
branch
from
November 20, 2026 14:09
3515495 to
f3d56d2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #1134.
Three changes to
flash --ram(espflash and cargo-espflash):--monitorno longer resets the RAM application away. The monitor's reset booted the application in flash instead. After loading to RAM, the monitor now starts without a reset, like esptool'sload-ram, which doesn't reset afterwards either.MonitorConfigArgs::no_resetis now public so that both binaries can set it.Timeout while running MemEnd command.Flasher::load_elf_to_ramnow checks every RAM segment against the stub's BSS and data (bss_start..data_start + data.len()) and its text, the same ranges esptool checks inmem_begin. It fails with the newError::RamSegmentOverlapsStub:FlashStubnow readsbss_startfrom the stub TOML files, and the stub selection (by chip and ESP32-P4 revision) moved fromload_stubtoFlasher::stubso that the check uses the same stub.--ram. A RAM image doesn't go through the second-stage bootloader, so--ignore-app-descriptorisn't needed anymore.As in esptool, the overlap check compares addresses only. On chips where IRAM and DRAM alias the same memory at different addresses (ESP32, ESP32-S2, ESP32-S3), a segment linked at the other alias of the stub's memory isn't detected.
The app descriptor check still runs after connecting; moving it before
connectis #1133.An AI tool generated a significant part of this change. It is tested on the HIL rig, see Testing.
Testing
ESP32-C6 (revision v0.2) on the HIL rig, with two minimal bare-metal programs that print
RAMOKto UART0 and USB-Serial-JTAG in a loop: one linked at0x40820000, clear of the stub (text0x40800000..0x408018f0, BSS and data0x40840000..0x40852e54), and one at0x40800000, overlapping the stub's text.mainflash --ram <clear>flash --ram --ignore-app-descriptor -M --non-interactive <clear>, USB-Serial-JTAGRAMOKlines, thenrst:0x15 (USB_UART_HPSYS)RAMOKlines in 20 s, no resetRAMOKlines in 25 s, no resetflash --ram --ignore-app-descriptor <overlap>Timeout while running MemEnd commandespflash::ram_segment_overlaps_stubbefore writingflash --ram --no-stub -M --non-interactive <overlap>RAMOKlinescheck_stub_encodingsnow also checks that every stub's BSS precedes its data, so that one range covers both.cargo +nightly fmt --check,cargo clippy --all-targets -- -D warnings,cargo clippy -p espflash --no-default-features [--features cli|serialport] -- -D warningsandcargo test -p espflash --lib.cargo espflash flash --ramon hardware (the same change as in espflash), Xtensa chips, the interactive monitor (which doesn't reset before monitoring anyway), and the ESP32-P4 stub selection, which moved but is unchanged.Suggested HIL:
/hil quick. The HIL tests don't cover--ram, but the stub loading code they exercise moved.