Skip to content

Load ELF data directly using probe_rs#690

Open
mkeeter wants to merge 1 commit into
mkeeter/only-load-with-a-probefrom
mkeeter/probe-that-elf
Open

Load ELF data directly using probe_rs#690
mkeeter wants to merge 1 commit into
mkeeter/only-load-with-a-probefrom
mkeeter/probe-that-elf

Conversation

@mkeeter
Copy link
Copy Markdown
Contributor

@mkeeter mkeeter commented Jun 3, 2026

(staged on #689)

Now that we are using probe-rs for everything, we don't need to convert to IHEX / SREC. This lets us remove a bunch of dependencies. I also switched ProbeCore::load to return a strong error type, while I was poking at it.

This is a building block for a humility flash library.

Bidding a fond farewell to the best docstring in the codebase, describing elf_chunks:

While it may sound like the impetus for an OSHA investigation at the North Pole...

@mkeeter mkeeter requested review from hawkw, jamesmunns and labbott June 3, 2026 14:25
@mkeeter
Copy link
Copy Markdown
Contributor Author

mkeeter commented Jun 3, 2026

I flashed both the SP and RoT on Grapefruit, and everything looks fine.

Comment thread cmd/rebootleby/Cargo.toml
humility-cli = { workspace = true }
clap = { workspace = true }
anyhow = { workspace = true }
parse_int = { workspace = true }
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were unused dependencies that I happened to notice while pruning.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the flashing workflow to load ELF data directly via probe-rs instead of converting ELF to IHEX/SREC first, reducing dependencies and simplifying the flash pipeline. It also introduces a dedicated LoadError type for ProbeCore::load.

Changes:

  • Switch ProbeCore::load to accept in-memory ELF bytes and program flash via probe-rs’s ELF loader/flash loader APIs.
  • Remove IHEX/SREC/tempfile-related conversion code and associated dependencies from the flash and rebootleby commands.
  • Prune workspace dependencies (ihex, srec, tempfile, path-slash, etc.) and update lockfile accordingly.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
humility-probes-core/src/probe_rs.rs Introduces LoadError and changes ProbeCore::load to program ELF bytes directly via probe-rs.
cmd/flash/src/lib.rs Updates flash command to pass ELF bytes directly to core.load.
cmd/flash/Cargo.toml Removes now-unneeded dependencies related to ELF→IHEX/SREC conversion.
cmd/rebootleby/Cargo.toml Removes dependencies no longer used by the command.
Cargo.toml Removes workspace-level dependencies that are no longer required.
Cargo.lock Reflects dependency graph changes after removing IHEX/SREC/tempfile/etc.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +246 to +248
/// Loading is not allowed when `can_flash = false`
#[error("ProbeCore was constructed with can_flash = false")]
NotAllowed,
Comment on lines 287 to +292
let erase_style = ProgressStyle::default_bar()
.template("humility: erasing [{bar:30}] {bytes}/{total_bytes}")?;
.template("humility: erasing [{bar:30}] {bytes}/{total_bytes}")
.unwrap();
let flash_style = ProgressStyle::default_bar()
.template("humility: flashing [{bar:30}] {bytes}/{total_bytes}")?;
.template("humility: flashing [{bar:30}] {bytes}/{total_bytes}")
.unwrap();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is deliberate; the progress bar can only fail if it's given an invalid template string, and we won't do that (or will catch it quickly, because it's a loud failure mode).

@mkeeter mkeeter force-pushed the mkeeter/only-load-with-a-probe branch from b2d785b to dd14be6 Compare June 3, 2026 20:31
@mkeeter mkeeter force-pushed the mkeeter/probe-that-elf branch from 024eac3 to 869db6f Compare June 3, 2026 20:31
@mkeeter mkeeter force-pushed the mkeeter/probe-that-elf branch from 869db6f to fe3045b Compare June 3, 2026 20:35
@mkeeter mkeeter force-pushed the mkeeter/only-load-with-a-probe branch from dd14be6 to e4e0918 Compare June 3, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants