Skip to content

fw/nrf52: Use UICR to simulate OTP on nRF5 platforms. [FIRM-35] #177

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jwise
Copy link

@jwise jwise commented Apr 26, 2025

nRF5 doesn't actually have true one-time programmable memory, but it does have some memory that is separate from the user program and some memory that is separate from the external SPI flash, called UICR. UICR can still be erased, and it is vaguely possible to accidentally erase it with OpenOCD's nrf52_recover command... but all that said, this is probably the most reasonable place to put serial numbers. (Pebble serial numbers are neither read-protected nor forgery-proof: they are not signed at manufacture. So if a user wants to mess with their hardware in a way that might need nrf52_recover'ing, then it may not be a bad idea in the future to provide a tool in this repository to back up and restore the UICR.)

Tested by building PRF and using 'serial read', 'pcbaserial write', 'hwver write' commands. Note that since asterix is still treated as IS_BIGBOARD, main.c tries to assign it a serial number on boot!

nRF5 doesn't actually have true one-time programmable memory, but it
does have some memory that is separate from the user program and some
memory that is separate from the external SPI flash, called UICR.  UICR
can still be erased, and it is vaguely possible to accidentally erase it
with OpenOCD's nrf52_recover command... but all that said, this is
probably the most reasonable place to put serial numbers.  (Pebble
serial numbers are neither read-protected nor forgery-proof: they are
not signed at manufacture.  So if a user wants to mess with their
hardware in a way that might need nrf52_recover'ing, then it may not be
a bad idea in the future to provide a tool in this repository to back up
and restore the UICR.)

Tested by building PRF and using 'serial read', 'pcbaserial write',
'hwver write' commands.  Note that since asterix is still treated as
IS_BIGBOARD, main.c tries to assign it a serial number on boot!

Signed-off-by: Joshua Wise <[email protected]>
@jwise jwise requested a review from gmarull April 26, 2025 04:58
@gmarull
Copy link
Collaborator

gmarull commented Apr 27, 2025

Thanks for the PR on this, initially looks good. I’ll take some time to analyze what we need to store, if something is missing, etc. before merging.

@gmarull
Copy link
Collaborator

gmarull commented Apr 29, 2025

I've found that our QSPI flash has true OTP registers (see security registers here https://www.gigadevice.com.cn/Public/Uploads/uploadfile/files/20220714/DS-00619-GD25LE255E-Rev1.2.pdf). I think it'll be safer to use those so stuff like S/N can never be erased from a unit.

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.

2 participants