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 documentation for Image Loading #48

Merged
merged 6 commits into from
Dec 13, 2024
Merged

Conversation

mlvisaya
Copy link
Collaborator

@mlvisaya mlvisaya commented Dec 5, 2024

No description provided.

docs/src/image_loading.md Outdated Show resolved Hide resolved
docs/src/image_loading.md Outdated Show resolved Hide resolved
docs/src/image_loading.md Outdated Show resolved Hide resolved
docs/src/image_loading.md Outdated Show resolved Hide resolved
docs/src/image_loading.md Outdated Show resolved Hide resolved
docs/src/image_loading.md Outdated Show resolved Hide resolved
docs/src/image_loading.md Outdated Show resolved Hide resolved
docs/src/image_loading.md Outdated Show resolved Hide resolved
docs/src/image_loading.md Outdated Show resolved Hide resolved
docs/src/image_loading.md Show resolved Hide resolved
Marco Visaya added 4 commits December 6, 2024 16:41
- Update images
- Add detailed steps for the image loading
- Remove extra code
- Use async in the interface methods
- Changed APIs
- Added sequence diagram
- Changed example SOC design
- Add detailed steps
- update the steps in image loading
- update the SOC sample
4. Caliptra RT indicates to Recovery I/F that it is ready for the SOC manifest image (refer to [Caliptra Subsystem Recovery Sequence](https://github.com/chipsalliance/Caliptra/blob/main/doc/Caliptra.md#caliptra-subsystem-recovery-sequence) for the detailed steps).
5. Retrieve SOC Manifest

1. If image is coming from BMC, BMC FW transfers manifest to Recovery I/F
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor: It might be better to rephrase as "If image is coming from BMC, SoC manifest is retrieved from Recovery I/F", since we don't need to define BMC FW behavior in our spec.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think you're right about not mentioning BMC FW. Although the for the Flash use case, the SoC manifest is also retrieved from Recovery I/F.

Should I just say BMC Recovery Agent and follow the wording in step 11 of https://github.com/chipsalliance/Caliptra/blob/main/doc/Caliptra.md#subsystem-boot-flow ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, it's good to reword as BMC's Recovery Agent.

/// # Returns
/// - `Ok()`: Image has been loaded and authorized succesfully.
/// - `Err(DynError)`: Indication of the failure to load or authorize the image.
async fn load_and_authorize(&self, image_id: u32, address: u64) -> Result<(), DynError>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason that we define load_and_authorize as one function instead splitting into two?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that is how we typically do it. We generally do both steps as once to reduce back and forth, since we aren't really going to want to do one without the other, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

On one hand, splitting them to 2 might offer some flexibility to the user, but I can't think of a use-case where the user just loads it and not authorize it immediately. I think the advantage of 1 function is just it's simpler to use, and as Chris said reduces back and forth with the application. Also i'd like to prevent them from calling authorize() first before calling load(), so making it atomic just ensures these 2 steps are followed in sequence.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was thinking from the perspective of interface definition, usually one function just does one specific job.
I agree that reducing back-and-forth interaction with app in our scenario is a valuable point. Let's keep it as it is.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I have a few suggestions on modifying the diagram:

  1. Let's use flash controller rather than SPI to represent flash interface consistently.
  2. Flash storage should be connected to flash controller.
  3. It might be better to replace the box BMC with something like PLDM -T5 FW package for streaming boot. BMC is not on the equivalent position of flash storage.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ack. How about "PLDM FW Update Agent" instead of BMC?

docs/src/image_loading.md Outdated Show resolved Hide resolved
docs/src/image_loading.md Outdated Show resolved Hide resolved
docs/src/image_loading.md Outdated Show resolved Hide resolved
docs/src/image_loading.md Outdated Show resolved Hide resolved
docs/src/image_loading.md Outdated Show resolved Hide resolved
docs/src/image_loading.md Outdated Show resolved Hide resolved
11. Caliptra RT FW will instruct Caliptra HW to read MCU SRAM and generate the hash (Caliptra HW will use the SHA accelerator)
12. Caliptra RT FW will use this hash and verify it against the hash in the SOC manifest.
13. Once digest is verified, the EXEC/GO bit is set
14. The EXEC/GO bit sets a Caliptra wire to MCU (as a consequence of setting the EXEC/GO bit in the previous step)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably you could combine 14, 15, and maybe even 16.

Comment on lines 64 to 65
15. MCU ROM detects Caliptra'go' wire to the MCU got set.
16. MCU ROM passes a parameter using the FW HandOff table to indicate the image source (i.e. the image source where it booted from)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
15. MCU ROM detects Caliptra'go' wire to the MCU got set.
16. MCU ROM passes a parameter using the FW HandOff table to indicate the image source (i.e. the image source where it booted from)
15. MCU ROM detects Caliptra 'go' wire to the MCU got set.
16. MCU ROM passes a parameter using the FW HandOff table to indicate the image source (i.e., the image source where it booted from)

/// # Returns
/// - `Ok()`: Image has been loaded and authorized succesfully.
/// - `Err(DynError)`: Indication of the failure to load or authorize the image.
async fn load_and_authorize(&self, image_id: u32, address: u64) -> Result<(), DynError>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that is how we typically do it. We generally do both steps as once to reduce back and forth, since we aren't really going to want to do one without the other, right?

- Updated Diagram (renamed BMC to PLDM Update Agent, remove SOC Config,
replaced SPI with Flash Controller)
- Updated Sequence Diagram
- Various enhancement on the step description
Copy link
Collaborator

@swenson swenson left a comment

Choose a reason for hiding this comment

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

LGTM

@mlvisaya
Copy link
Collaborator Author

Thanks!!

@mlvisaya mlvisaya merged commit d90b2fb into main Dec 13, 2024
1 check passed
@mlvisaya mlvisaya deleted the mlvisaya/doc-image-loading branch December 13, 2024 21:53
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