This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Unique serial number persistence storage

Hello there,

I would like to have my device serial number be set over uart and stored persistently via the nrf52840's SRAM in a ROM fashion. Is this possible? If so, where could I store this information?

I would also like for this persistence to occur when the device is off, and when the device is programmed (i.e. erase all is selected via segger studio and then device is reprogrammed). Is there a way to change the memory space in the "Set Section Placement Macros" so that segger studio doesn't touch the memory address where I store said information?

Thank you,

Nick

Parents
  • I dont know how well this screenshot shows up but I'm guessing the UICR is what I'm looking for. Will this stay persistent through power off and erasing the memory + reprogramming?

  • The UICR is like a smaller secondary flash bank. It is non-volatile (data is preserved when device is off), but it is not ROM (it can be erased, though not by erasing the flash).

    The following rules apply:

    - Flash sectors can be erased using NVMC->ERASEPAGE. This will have no effect on the UICR.

    - The UICR can be erased with NVMC->ERASEUICR. This will have no effect on the flash.

    - Using NVMC->ERASEALL will force a quick erase of both the flash and UICR. This returns the chip to its "fresh off the production line" state.

    An ERASEALL command can also be issued using nrfjprog, however this is generally only needed if you set the NVMC->APPPROTECT register to lock the chip, in which case an ERASEALL operation is required to restore it to unlocked state again.

    When programming just the flash (i.e. to load new software), you do not need to perform an ERASEALL operation. You can just erase individual flash sectors instead. This is normally what most programming tools do. Note that this means "erase all the flash" where the ERASEALL command in particular means "erase the entire chip." So you may be able to treat the UICR region as though it's ROM since you shouldn't need to touch just to flash the device with new software.

    There is an FICR region which is permanent (not affected by ERASEALL) but it's set by Nordic when the chip is manufactured. This actually contains a per-chip unique device ID at FICR->DEVICEID[0] and FICR->DEVICEID[1]. This is basically the serial number Nordic has assigned to the chip. If you really need a permanent per-device identifier, maybe you could use this.

    -Bill

Reply
  • The UICR is like a smaller secondary flash bank. It is non-volatile (data is preserved when device is off), but it is not ROM (it can be erased, though not by erasing the flash).

    The following rules apply:

    - Flash sectors can be erased using NVMC->ERASEPAGE. This will have no effect on the UICR.

    - The UICR can be erased with NVMC->ERASEUICR. This will have no effect on the flash.

    - Using NVMC->ERASEALL will force a quick erase of both the flash and UICR. This returns the chip to its "fresh off the production line" state.

    An ERASEALL command can also be issued using nrfjprog, however this is generally only needed if you set the NVMC->APPPROTECT register to lock the chip, in which case an ERASEALL operation is required to restore it to unlocked state again.

    When programming just the flash (i.e. to load new software), you do not need to perform an ERASEALL operation. You can just erase individual flash sectors instead. This is normally what most programming tools do. Note that this means "erase all the flash" where the ERASEALL command in particular means "erase the entire chip." So you may be able to treat the UICR region as though it's ROM since you shouldn't need to touch just to flash the device with new software.

    There is an FICR region which is permanent (not affected by ERASEALL) but it's set by Nordic when the chip is manufactured. This actually contains a per-chip unique device ID at FICR->DEVICEID[0] and FICR->DEVICEID[1]. This is basically the serial number Nordic has assigned to the chip. If you really need a permanent per-device identifier, maybe you could use this.

    -Bill

Children
  • Thank you so much Bill for your detailed response. Do you think the UCIR would still be erased if I only reprogram my device and not use erase all? I haven't seen any information on using segger studio and skipping memory addresses during firmware burn.

    Initially I did use the device address in the FICR for my unique identifier but I was told it needed to be changed for the sake of usability.

  • Do you think the UCIR would still be erased if I only reprogram my device and not use erase all?

    No. Although the UICR storage is like flash, it's technically separate from the flash, and the workflow for just reprogramming the device only touches the flash, not the UICR. I use OpenOCD/GDB to program my devices rather than Segger Studio, but even there, the "load" command which flashes a new firmware image only ever affects the flash bank. I have to jump through a number of additional hoops to also erase the UICR.

    As previously mentioned, it is possible to use Segger Studio do perform a full chip erase (ERASEALL), however that should be a different workflow from normal programming. So as long as you avoid the full erase workflow in your provisioning/programming framework, I think you should be fine.

    -Bill

Related