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

Storing Device Serial/Identifier

We'd like to be able to store a few items including mutable keys, and unique identifier in each device that is generated on initial boot of the product. I'm just starting out with research but I'm wondering if there is any documentation/guidance from Nordic regarding how/where to store this kind of information?

Parents
  • Take a look at the NVS driver that Zephyr provides.  There is a sample application over in zephyr/samples/subsys/nvs.

    The only issue I bumped into was the flash offset you pass into nvs_init().  The Zephyr sample uses DT_FLASH_AREA_STORAGE_OFFSET, which should work in most cases.  Howeverif you are using mcuboot for FOTA updating, that value needs to be PM_MCUBOOT_STORAGE_ADDRESS.

  • I'm revisiting this now. I am able to read/write NVS at the PM_MCUBOOT_STORAGE_ADDRESS however I'm not sure how to initialize that area of flash. I'd like to include as part of our programming script writing the initial values to PM_MCUBOOT_STORAGE_ADDRESS (0xFC000) but when I try to write a binary there I get an error. I assume the area is protected.

    What is the proper way to do this?

  • I'm not sure when that area of flash is or isn't protected.  I would expect the JTAG programmer should be able to write there whenever it wants.

    In our application, our initial/default values are the same for every unit we program, so we actually hard-coded them into special NVS-reader functions.  A factory reset erases the NVS space on our devices, and the reader functions notice that there is no stored value and return the hard-coded initial/default value instead.

    Are you using unique or changing initial NVS values for different devices?

Reply
  • I'm not sure when that area of flash is or isn't protected.  I would expect the JTAG programmer should be able to write there whenever it wants.

    In our application, our initial/default values are the same for every unit we program, so we actually hard-coded them into special NVS-reader functions.  A factory reset erases the NVS space on our devices, and the reader functions notice that there is no stored value and return the hard-coded initial/default value instead.

    Are you using unique or changing initial NVS values for different devices?

Children
Related