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

Add ReadRot message for CMPA / CFPA #116

Merged
merged 2 commits into from
Sep 13, 2023
Merged

Add ReadRot message for CMPA / CFPA #116

merged 2 commits into from
Sep 13, 2023

Conversation

mkeeter
Copy link
Contributor

@mkeeter mkeeter commented Aug 31, 2023

This PR adds a new ReadRot top-level message, for all of our RoT reading needs (right now, just CMPA / CFPA).

The CMPA / CFPA results are a fixed size of 512 bytes, but I'm still putting them in the trailing data buffer to avoid blowing up SpResponse::MAX_SIZE.

This PR should be left open until the Hubris side is also done, in case we discover the need for further changes (e.g. new error variants)

@@ -70,15 +70,15 @@ fn host_request() {
let request =
MgsRequest::ReadSensor(SensorRequest { kind, id: 0x1234 });
let mut expected = vec![
38, // SpResponse::ReadSensor
38, // MgsRequest::ReadSensor
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changes in this file are typo fixes, unrelated to the rest of the PR

@@ -814,6 +816,24 @@ impl SingleSp {
}),
}
}

pub async fn read_rot_cmpa(&self) -> Result<[u8; 512]> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

One nit and one question:

  • Could we add a constant (or possibly two, for naming clarity? I'm ambivalent about this bit) for the CMPA / CFPA size? As written I think clients of this crate will also need to create some [u8; 512]s, and constants would probably be friendlier.
  • How is a client (MGS, or possibly the client of MGS) supposed to interpret the returned blob? Will hubtools take this as input for some kind of "display what we know about this" or "compare against a known list" operation?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the interpretation depends on what problems we are actually trying to solve. We can use this with the verify operation in lpc55_sign to validate a particular Hubris image will work with a particular CMPA/CFPA combination.

The constant is the LPC55 flash page size. We have that defined in a driver but I don't know the best place to put it for other not-LPC55 software. We could also cheat and use the block_size call to get the same answer.

Copy link
Contributor Author

@mkeeter mkeeter Sep 7, 2023

Choose a reason for hiding this comment

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

I added an ROT_PAGE_SIZE constant in db88706.

I agree with @labbott that we'd probably pass the pages into hubtools directly, since that's the existing API.

Comment on lines 234 to 248
/// Specific CFPA page
#[derive(
Debug, Clone, Copy, PartialEq, Eq, SerializedSize, Serialize, Deserialize,
)]
pub enum CfpaPage {
/// Currently active page
Active,
/// Page that will become active on reset
Pending,
// We could add variants for ping/pong/scratch pages here if needed
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should be more explicit to cover all cases

enum CfpaPage {
     Active, // HIghest version between ping/pong
     Alternate, // Lower version between ping/pong
     Scratch, // Data to be applied on next reboot
}

Given the difficulty in getting data out of the RoT, I'd like to guarantee we can actually get all possible data we want and then leave interpretation of that elsewhere. My fear is that the RoT tries to calculate what will happen with "pending", something goes wrong and then we're stuck with confusing data when it doesn't get applied.

Copy link
Contributor Author

@mkeeter mkeeter Sep 7, 2023

Choose a reason for hiding this comment

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

Sure, I can make those changes. Do you want Active / Alternate, or should we get even more manual and report Ping / Pong (leaving the host to interpret which one is active)?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think Active vs Inactive is better defined than ping and pong and it's easy to add that logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, switched to Active / Inactive / Scratch in 39455d6

@mkeeter mkeeter enabled auto-merge (squash) September 13, 2023 17:02
@mkeeter mkeeter merged commit 7f0bdd5 into main Sep 13, 2023
10 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.

3 participants