Recommended solution for persistent data storage in NCS

I'm currently evaluating the nRF52840dk using the nRF Connect SDK to determine whether or not to port over our codebase to it from a Xiao nRF52 module

I was using KVStore before, just storing an authToken char array which is set once after a network request and might be replaced once every couple months which worked perfectly for my needs. It just needs to be persisted between resets

It seems like the Nordic SDK's have historically provide several different libraries for this functionality:

  • fstorage
  • pstorage
  • ble_flash
  • Emergency Data Storage (EMDS)
  • Flash Data Storage (FDS)

According to this answer Flash Data Storage (FDS) is the latest and greatest as of 6 years and several SDK's ago, but I can't even find a reference to it in the NCS docs here, only EMDS which I've mostly been using. But, from what I've read, you're only supposed to call `emds_store()` when it's about to lose power so I'm not sure if it's supposed to be the standard method for persistent data storage?

Can you explain or direct me to the docs for the recommended way to handle my persistent data in NCS v2.0.2?

Parents
  • Hi Josheph,

    There is no direct connection between the flash libraries we had on the nRF5 SDK to the nRF Connect SDK. 

    The nRF Connect SDK based on Zephyr RTOS and uses the Zephyr's libraries for flash storage. 

    I would suggest to have a look at the Settings library. This is where you can store the setting data to non-volatile memory. The Bluetooth example uses Settings to store bond information. It's similar to fds library we used on nRF5. 

    The Settings library by default will use the NVS library to access flash. The NVS library is equivalent to the fstorage on the nRF5. It's the lower flash access library. 

    You can find the example of using Settings in peripheral_nfc_pairing sample. And example of using NVS in \zephyr\samples\subsys\nvs sample. 

    If you have a look at nrf52dk_nrf52832.dts you can see that the storage_partition (for NVS) is configured at the offset 0x7a000. It's where the NVS "storage" stores the data. 

Reply
  • Hi Josheph,

    There is no direct connection between the flash libraries we had on the nRF5 SDK to the nRF Connect SDK. 

    The nRF Connect SDK based on Zephyr RTOS and uses the Zephyr's libraries for flash storage. 

    I would suggest to have a look at the Settings library. This is where you can store the setting data to non-volatile memory. The Bluetooth example uses Settings to store bond information. It's similar to fds library we used on nRF5. 

    The Settings library by default will use the NVS library to access flash. The NVS library is equivalent to the fstorage on the nRF5. It's the lower flash access library. 

    You can find the example of using Settings in peripheral_nfc_pairing sample. And example of using NVS in \zephyr\samples\subsys\nvs sample. 

    If you have a look at nrf52dk_nrf52832.dts you can see that the storage_partition (for NVS) is configured at the offset 0x7a000. It's where the NVS "storage" stores the data. 

Children
Related