Skip to content

Move humility flash to a library#699

Open
mkeeter wants to merge 5 commits into
masterfrom
mkeeter/humility-flash
Open

Move humility flash to a library#699
mkeeter wants to merge 5 commits into
masterfrom
mkeeter/humility-flash

Conversation

@mkeeter

@mkeeter mkeeter commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

This PR moves the bulk of humility flash into a library crate. There are two main entry points:

  • get_image_state tells us whether the current image matches or not
  • program_image flashes an image (and auxflash)

As always, things are fully documented and use strong error types.

The logic is broadly the same as before, but has been tightened in a few places. For example, in the old implementation, any error while checking image state (e.g. a probe error) would lead to Humility trying to reflash the image; our new implementation distinguishes between "image matches / doesn't match" and Humility-level errors.

There's one small API change: HubrisArchive::chip now returns a Result<String> (instead of an Option<String>). In 2026, we should never be trying to flash / reset an archive which does not include the chip name (and this isn't used in post-mortem debugging, so it's fine to be less backwards-compatible).

@mkeeter mkeeter requested review from adamlouis and labbott June 10, 2026 19:31
Comment thread cmd/flash/src/lib.rs
#[clap(long, short = 'F')]
force: bool,

/// if using OpenOCD, do not actually flash, but show commands and retain

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 arguments were only used for OpenOCD, which is no longer used.

Comment thread cmd/flash/src/lib.rs
Comment on lines -75 to -81
/// If `subargs.check` is true, returns `Ok(())` on a clean check and `Err(..)`
/// otherwise; the core is left running.
///
/// If `subargs.check` is false, returns `Ok(())` if the check _fails_ (meaning
/// we should reflash), and `Err(..)` if all checks pass (meaning we should
/// _not_ reflash). The core is left halted if we should reflash and is running
/// otherwise.

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.

RIP to the most confusing function semantics in Humility

pub metadata: HubrisFlashMeta,
pub elf: Vec<u8>,
pub chip: Option<String>,
}

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 no longer used as a single object; I've exposed helper functions to get both the elf and chip data individually.

Comment thread Cargo.toml
"cmd/validate",
"cmd/vpd",
"cmd/writeword",
"xtask", "humility-log",

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.

Dunno what was going on here, but I fixed it.

mod unattached;

pub use probe_rs::ProbeCore;
pub use probe_rs::{LoadError, ProbeCore};

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 newly public because ProgramImageError::LoadFailed wraps it.

This comment was marked as resolved.

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