How can I pre-program default NVS entries during manufacturing?

In our Zephyr-based nRF project we store configuration in NVS.
For the production line we’d like every unit to leave the factory with default objects already written to flash, for example:

Key 1 : 0x01
Key 2 : 0xAA 0xBB

Is there a recommended workflow or CLI tool to:

  1. generate a binary blob that contains these NVS records, or

  2. write them directly to the NVS partition as part of the flashing script,

so that the firmware sees the values on first boot?

Any pointers, sample commands, or documentation links would be greatly appreciated.
(nRF Connect SDK 2.9.1, nRF9160)

Parents
  • Unfortunately there are no official suggested ways or tools provided to do this. But easiest way could be that you could factory load NVS defaults by using Zephyr’s Settings subsystem (with CONFIG_SETTINGS_NVS), pinning the “storage” partition via a pm_static.yml. Googling for tools and found this external tool to generate a small binary image of that partition like zephyr-settings-generator . Finally, script your production flash to load both the application and that preload image. This way, on first boot your device sees exactly the default values you baked in and no manual provisioning step would be needed.

Reply
  • Unfortunately there are no official suggested ways or tools provided to do this. But easiest way could be that you could factory load NVS defaults by using Zephyr’s Settings subsystem (with CONFIG_SETTINGS_NVS), pinning the “storage” partition via a pm_static.yml. Googling for tools and found this external tool to generate a small binary image of that partition like zephyr-settings-generator . Finally, script your production flash to load both the application and that preload image. This way, on first boot your device sees exactly the default values you baked in and no manual provisioning step would be needed.

Children
No Data
Related