Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xtask: Include expected measurement for hubris images in build archive. #1491

Merged
merged 2 commits into from
Sep 7, 2023

Conversation

flihp
Copy link
Contributor

@flihp flihp commented Aug 14, 2023

This implementation is currently limited to stm32h7 images for the SP. This was tested on a gimletlet by comparing the FWID value calculated by xtask with the value calculated by the sp_measure build.rs.

@flihp flihp linked an issue Aug 14, 2023 that may be closed by this pull request
build/xtask/src/dist.rs Outdated Show resolved Hide resolved
Comment on lines 596 to 599
let mut file = File::create(&cfg.img_file("final.fwid", image_name))?;
writeln!(file, "{}", hex::encode(&digest))?;

archive.add_file("img/final.fwid", digest.as_bytes())?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not quite sure why we're creating the file twice, is the hubris one not sufficient? Aren't the two files different since one is hex encoded and the other is the raw bytes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah that's a good catch: I had intended for the contents of these two files to be identical. I'll fix that up. As to why I create a file on disk and one in the archive: the final.bin is manipulated / caboosed in the archive after creation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just pushed a change to make the final.fwid files on disk and in the archive identical: both now contain the hex encoded digest.

@flihp flihp force-pushed the measure-sp-at-build branch 2 times, most recently from 614898a to 176c94d Compare August 16, 2023 19:02
@flihp flihp requested a review from cbiffle as a code owner August 25, 2023 21:10
Comment on lines 558 to 559
// can we use lpc55-romapi
const LPC55_FLASH_PAGE_SIZE: usize = 512;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmmmm, I think what we actually want is like lpc55-rom-constants or something similar (currently running into this with some of the CMPA/CFPA reading as well). Probably not worth blocking for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a new commit addressing this feedback. Only the constant used here by xtask was moved to the new lpc55-rom-data crate. Others can migrate on demand. I'll squash all of this down once the PR is ready. LMK if this wasn't what you were after.

Comment on lines +30 to +31
#[serde(default)]
fwid: bool,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be easier to make this no_fwid so only boards that we probably aren't going to care about can opt out? I was trying to go through the mental list to make sure we hit all the boards we care about.

Copy link
Contributor Author

@flihp flihp Sep 7, 2023

Choose a reason for hiding this comment

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

I went back and forth on this a few times. The current approach, as you point out, is error prone & requires we update more toml files. Doing this with negative logic would require fewer toml changes but might end up on the wrong side of the law of least surprise when folks add new boards and they get build errors until they figure out that they need to add fwid = false. There are good reasons for going either way. I'm happy to defer to your judgement.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Eh, let's keep it as is for now.

Comment on lines +604 to +605
// after we've appended a newline fwid is immutable
let mut fwid = hex::encode(&digest);
writeln!(fwid, "").context("appending newline to FWID")?;
let fwid = fwid;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the newline just for ease of reading or is there some deeper meaning?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No deeper meaning, just gives better output when the file is dumped to the console.

@flihp flihp requested a review from labbott September 7, 2023 19:41
This gives us a place to put data relevant to the LPC55 ROM API that we
need in software built for the host.
Include the FWID / expected measurement for hubris images in the build
archive 'img/final.fwid'.
@flihp flihp merged commit 47b79ac into master Sep 7, 2023
71 checks passed
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.

calculate FWID @ build time
2 participants