Skip to content

Two helper functions to allow easier validation of NVRAM table by OEMs#538

Merged
madeleyneVaca merged 3 commits intoOpenDevicePartnership:mainfrom
madeleyneVaca:mavaca/rtc_nvram_helpers
Jan 9, 2026
Merged

Two helper functions to allow easier validation of NVRAM table by OEMs#538
madeleyneVaca merged 3 commits intoOpenDevicePartnership:mainfrom
madeleyneVaca:mavaca/rtc_nvram_helpers

Conversation

@madeleyneVaca
Copy link
Contributor

@madeleyneVaca madeleyneVaca commented Jan 7, 2026

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

Copilot AI review requested due to automatic review settings January 7, 2026 04:08
Copy link
Contributor

Copilot AI left a 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 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.

@madeleyneVaca madeleyneVaca force-pushed the mavaca/rtc_nvram_helpers branch from e482b1d to 26260fd Compare January 7, 2026 04:50
@madeleyneVaca madeleyneVaca changed the title two helper functions to allow easier manipulation of NVRAM table by OEMs Two helper functions to allow easier validation of NVRAM table by OEMs Jan 7, 2026
@madeleyneVaca madeleyneVaca changed the title Two helper functions to allow easier validation of NVRAM table by OEMs [RFC] Two helper functions to allow easier validation of NVRAM table by OEMs Jan 7, 2026
@madeleyneVaca madeleyneVaca force-pushed the mavaca/rtc_nvram_helpers branch from 26260fd to 6d74239 Compare January 7, 2026 21:16
@madeleyneVaca madeleyneVaca marked this pull request as ready for review January 7, 2026 21:49
@madeleyneVaca madeleyneVaca requested a review from a team as a code owner January 7, 2026 21:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@madeleyneVaca madeleyneVaca force-pushed the mavaca/rtc_nvram_helpers branch from bb4a024 to 84f115b Compare January 8, 2026 02:08
Copilot AI review requested due to automatic review settings January 8, 2026 02:08
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@williampMSFT
Copy link
Contributor

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?

madeleyneVaca added a commit to OpenDevicePartnership/embedded-mcu that referenced this pull request Jan 9, 2026
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.
@madeleyneVaca madeleyneVaca force-pushed the mavaca/rtc_nvram_helpers branch from 84f115b to 1f4db74 Compare January 9, 2026 20:29
Copilot AI review requested due to automatic review settings January 9, 2026 21:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@madeleyneVaca madeleyneVaca merged commit a5aad0d into OpenDevicePartnership:main Jan 9, 2026
17 checks passed
@jerrysxie jerrysxie changed the title [RFC] Two helper functions to allow easier validation of NVRAM table by OEMs Two helper functions to allow easier validation of NVRAM table by OEMs Jan 9, 2026
@jerrysxie jerrysxie added the enhancement New feature or request label Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants