Two helper functions to allow easier validation of NVRAM table by OEMs#538
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds two helper functions to the RtcNvram implementation to facilitate OEM manipulation of NVRAM tables, particularly for scenarios requiring integrity validation. These functions address the double borrow problem that occurs when OEMs need to both validate the NVRAM contents and then deconstruct the table for use by different services.
- Adds
clear_storage()method to erase all NVRAM storage cells - Adds
dump_storage()method to read all NVRAM contents into an array for validation/CRC checks
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e482b1d to
26260fd
Compare
26260fd to
6d74239
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bb4a024 to
84f115b
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I think these seem reasonable to me, but since they're just methods on the imxrt implementation, you'll need to know the concrete type of your backing storage to use them. It might make sense to have these be trait methods on the Nvram trait so you can reuse code that leverages them against different platforms - thoughts? |
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.
84f115b to
1f4db74
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 4 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 theNvramtrait 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