-
Notifications
You must be signed in to change notification settings - Fork 9
Expand NVRAM trait with integrity validation helpers #11
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
Expand NVRAM trait with integrity validation helpers #11
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR extends the Nvram trait with two helper methods to support integrity validation workflows: dump_storage for obtaining a read-only snapshot of NVRAM contents, and clear_storage for resetting storage to a default state when validation fails.
- Added
dump_storage()method to obtain a snapshot of all storage cells for validation - Added
clear_storage()method to reset storage cells to their default state
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
williampMSFT
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May want to check if copilot is right on the copy thing, I'm not 100% sure, but other than that, looks good to me
…by OEMs (#538) In the event that an OEM is using the RTC NVRAM table for something more complicated than a few flags, integrity validation becomes necessary. The `storage()` API in the `Nvram` trait returns a mutable reference and ensures we can't double borrow. Great for safety but makes it difficult to get the values for validation (and potential erasure if invalid) and then also deconstruct the NVRAM table, so that they can be passed off the values to whichever service needs them, as that would constitute a double borrow. This PR introduces two helper functions which 1) dumps the current u32 values of the registers, rather than allowing for another handle to the RTC peripheral. The OEM can then perform their validation logic and if something is iffy, they can 2) erase the contents of the table through the object that has the handle before splitting up the entries as the OEM desires. Related PRs: OpenDevicePartnership/embedded-mcu#11
Related to OpenDevicePartnership/embassy-imxrt#538. This PR adds two helper functions to the NVRAM trait which makes it easy for a user to obtain the contents of an NVRAM table for validation and then clear them if found to be invalid