Skip to content

Introduce humility-vpd-lib#670

Open
labbott wants to merge 31 commits into
mkeeter/subcommand-enumfrom
vpd_lib
Open

Introduce humility-vpd-lib#670
labbott wants to merge 31 commits into
mkeeter/subcommand-enumfrom
vpd_lib

Conversation

@labbott
Copy link
Copy Markdown
Contributor

@labbott labbott commented May 19, 2026

It's useful to be able to call VPD functions from Rust code

@labbott labbott requested a review from adamlouis May 19, 2026 17:10
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

license-eye has totally checked 102 files.

Valid Invalid Ignored Fixed
100 2 0 0
Click to see the invalid file list
  • humility-vpd-lib/examples/list.rs
  • humility-vpd-lib/examples/read.rs

Comment thread humility-vpd-lib/examples/list.rs Outdated
Comment thread humility-vpd-lib/examples/read.rs Outdated
Comment thread humility-vpd-lib/src/lib.rs Outdated
Comment thread humility-vpd-lib/src/lib.rs Outdated

pub enum VpdTarget {
Device(usize),
Loopback(fs::File),
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.

I'm waffling if we should just remove the loopback testing code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was confused why all these functions needed to pass a &mut VpdTarget; it's because functions mutate the fs::File inside the Loopback variant. That weirdness is another point in favor of just removing it.

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.

I just removed it but kept the VpdTarget (maaaybe that should just be a straight usize?)

@labbott labbott requested review from hawkw and mkeeter May 19, 2026 19:06
Comment thread cmd/vpd/Cargo.toml
Comment thread humility-vpd-lib/examples/list.rs Outdated
let probe = std::env::var("HUMILITY_PROBE").unwrap();

let hubris = RawHubrisArchive::load(&hubris).unwrap();
let hubris = HubrisArchive::load(hubris, None).unwrap();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This suggests that we're missing a HubrisArchive::from_archive(path: FilePath). How about adding that function, then removing the pub export of RawHubrisArchive?

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.

Comment thread humility-vpd-lib/examples/list.rs Outdated

let core = &mut *humility_probes_core::attach_to_chip(
&probe,
Some("STM32H753ZITx"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we get the chip from the manifest?

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.

#675 we can make this one step with an extension trait

Comment thread humility-vpd-lib/src/lib.rs Outdated
err: std::io::Error,
},
#[error("tlvc: {0:?}")]
Tlvc(TlvcReadError<core::convert::Infallible>),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Opened oxidecomputer/tlvc#11 to make this better

Comment thread humility-vpd-lib/src/lib.rs Outdated
Comment thread humility-vpd-lib/src/lib.rs Outdated
Comment thread humility-vpd-lib/src/lib.rs Outdated
Comment thread humility-vpd-lib/src/lib.rs Outdated
/// across hubris releases
pub ndx: usize,
/// Raw i2c data about the device
pub device: HubrisI2cDevice,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Vibes: this is a moderately large value type. When I was poking at humility validate-as-a-library, I found it was possible to borrow instead (e.g. add a lifetime to VpdEntry and have pub device: &'a HubrisI2cDevice); check and see how that goes?

Comment thread humility-vpd-lib/src/lib.rs Outdated
Comment thread humility-vpd-lib/src/lib.rs Outdated
Comment thread humility-vpd-lib/src/lib.rs Outdated
Comment thread humility-vpd-lib/src/lib.rs Outdated
Comment thread humility-vpd-lib/src/lib.rs Outdated
Comment thread humility-vpd-lib/src/lib.rs Outdated
Comment thread humility-vpd-lib/src/lib.rs Outdated
Comment thread humility-vpd-lib/src/lib.rs Outdated
Comment thread humility-vpd-lib/src/lib.rs Outdated
Comment thread humility-vpd-lib/src/lib.rs Outdated
let mut offset = 0;

// Do we want to make this an argument for optionally not having
// a progress bar?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We'll eventually want something like trait HumilityProgress, but that doesn't need to happen now...

Comment thread humility-vpd-lib/src/lib.rs Outdated
Comment thread humility-vpd-lib/src/lib.rs Outdated
Comment thread humility-vpd-lib/src/lib.rs Outdated
@labbott
Copy link
Copy Markdown
Contributor Author

labbott commented May 20, 2026

Open question: we will probably grow more humility-lib crates. Do we want to keep them all at the root for now and make cleanup a problem for Future Us or try some organization now?

@mkeeter mkeeter force-pushed the mkeeter/subcommand-enum branch 2 times, most recently from 9474cbb to 8c8ab59 Compare May 20, 2026 20:09
Comment on lines +82 to +83
/// Reading out the VPD can be very slow and can be omitted
pub data: VpdData,
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.

I don't love this but it takes almost 15 seconds to do a list when reading all the VPD

@mkeeter mkeeter force-pushed the mkeeter/subcommand-enum branch from 4c980ca to 4665ca1 Compare May 21, 2026 18:22
@mkeeter mkeeter force-pushed the mkeeter/subcommand-enum branch 3 times, most recently from f49aa94 to 20d913b Compare May 21, 2026 20:50
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