Move humility flash to a library#699
Conversation
| #[clap(long, short = 'F')] | ||
| force: bool, | ||
|
|
||
| /// if using OpenOCD, do not actually flash, but show commands and retain |
There was a problem hiding this comment.
These arguments were only used for OpenOCD, which is no longer used.
There was a problem hiding this comment.
I purposely didn't want to break command line feature when I removed openocd but it's been so long since anyone really used it it's probably fine
There was a problem hiding this comment.
Yeah, I figured that anyone is using those flags they should be able to figure it out right quick.
| /// 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. |
There was a problem hiding this comment.
RIP to the most confusing function semantics in Humility
| pub metadata: HubrisFlashMeta, | ||
| pub elf: Vec<u8>, | ||
| pub chip: Option<String>, | ||
| } |
There was a problem hiding this comment.
This is no longer used as a single object; I've exposed helper functions to get both the elf and chip data individually.
| "cmd/validate", | ||
| "cmd/vpd", | ||
| "cmd/writeword", | ||
| "xtask", "humility-log", |
There was a problem hiding this comment.
Dunno what was going on here, but I fixed it.
| mod unattached; | ||
|
|
||
| pub use probe_rs::ProbeCore; | ||
| pub use probe_rs::{LoadError, ProbeCore}; |
There was a problem hiding this comment.
This is newly public because ProgramImageError::LoadFailed wraps it.
labbott
left a comment
There was a problem hiding this comment.
Want to take another pass but generally LGTM
| #[clap(long, short = 'F')] | ||
| force: bool, | ||
|
|
||
| /// if using OpenOCD, do not actually flash, but show commands and retain |
There was a problem hiding this comment.
I purposely didn't want to break command line feature when I removed openocd but it's been so long since anyone really used it it's probably fine
| core.load(&elf).map_err(ProgramImageError::LoadFailed)?; | ||
|
|
||
| // | ||
| // On Gimlet Rev B, the BOOT0 pin is unstrapped -- and during a flash, |
There was a problem hiding this comment.
are there still gimlet-b's around we care about?
There was a problem hiding this comment.
It's still built in Hubris, so I think we should keep it around.
(I was also trying to minimize behavior changes while moving logic into the library crate)
db23c59 to
ba970f3
Compare
This PR moves the bulk of
humility flashinto a library crate. There are two main entry points:get_image_statetells us whether the current image matches or notprogram_imageflashes 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::chipnow returns aResult<String>(instead of anOption<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).