Reading from the UICR / OTP registers on the nRF5340 during runtime

Looking at this forum post from 11 months ago, and I'm confused about the guidance given.
https://devzone.nordicsemi.com/f/nordic-q-a/99083/reading-uicr-value-at-runtime-for-nrf53

  1. Is it possible to read from the UICR using the build target nRF5340dk_nrf5340_cpuapp (instead of the nRF5340dk_nrf5340_cpuapp_ns build target)
  2. If so, is there guidance or a sample on how to read from the UICR within the application? I believe it might involve the key-management subsystem?
On the nRF5340, I can use nrfjprog.exe to write our public BLE MAC address to the first six bytes of the "OTP" registers of the UICR, but the application cannot read these registers. No matter what, my application reads 0xdeaddead despite the value being clearly written in the "OTP" registers:
[00000000.546] read_from_uicr() | start=0x00FF8000, offset=0x100 >> reg=0x00FF8100
[00000000.546] read_from_uicr() | AD DE AD DE  AD DE AD DE  AD DE AD DE  AD DE AD DE
[00000000.546] read_from_uicr() | AD DE AD DE  AD DE AD DE  AD DE AD DE  AD DE AD DE


Here's the output of nrfjprog.exe that shows those registers are written on my nRF5340 (and definitely not equal to 0xdeaddead):
cal@AF-X-Dev-W002:~$ nrfjprog.exe --snr 1050018178 --memrd 0x00FF8100 --w 16 --n 128
0x00FF8100: 0455 0000 2211 4433 FFFF FFFF FFFF FFFF   |U...."3D........|
0x00FF8110: FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF   |................|

 
Parents
  • Hello, 

    I'm not aware of any limitations with reading the UICR register when you run the code in secure mode (i.e., built for the nRF5340dk_nrf5340_cpuapp target). Please try the attached code below and see if you get the same result.

    hello_world_uicr.zip

    I first set the OTP register with nrfjprog:

    nrfjprog --memwr 0x00FF8100 --val 0x12345
    

    Then I ran the example and received the following log output:

    *** Booting nRF Connect SDK v2.5.2 ***
    NRF_UICR->OTP[0] : 0x12345

    Best regards,

    Vidar

Reply
  • Hello, 

    I'm not aware of any limitations with reading the UICR register when you run the code in secure mode (i.e., built for the nRF5340dk_nrf5340_cpuapp target). Please try the attached code below and see if you get the same result.

    hello_world_uicr.zip

    I first set the OTP register with nrfjprog:

    nrfjprog --memwr 0x00FF8100 --val 0x12345
    

    Then I ran the example and received the following log output:

    *** Booting nRF Connect SDK v2.5.2 ***
    NRF_UICR->OTP[0] : 0x12345

    Best regards,

    Vidar

Children
Related