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

  • 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

  • Hi,

    Using the UICR is the best option here, but it will not be persistent across a full chip erase. That should not be a problem for an end product though since a full flash erases is typically not done after the device leaves the production line. You cannot write your own data to the FICR, so that is not an option.

  • 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.

  • Thank you so much for your response Einar. I asked this question to Bill above but I will ask you as well. For production line purposes, my company wants to be able to reprogram these for possible future firmware upgrades so there is a possibility that the device may be reprogrammed but we need the UCIR information to stay (unless manufacturing goes back in to change the UCIR information via uart). If I reprogrammed a device via segger studio, would this UCIR information be wiped out? If so, how could I change segger studio and skip this memory address during reprogramming?

Related