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

How to save data on flash storage?

I need to save some data on the flash storage. This data will be some structures and I will write, read and modify them as and when required. I am also using peer manager in my application. Can my application use fds(flash data storage) module while using peer manager? Or should I use flash storage module directly? Although I have seen the sample code snippets on NRF infocenter but I would like to see a complete application code that uses flash storage along with peer manager.

  • Hello Prasad

    It is possible to use the FDS to store data in flash while using the peer manager. The FDS reserves a number of physical flash pages from fstorage on initialization, and creates its virtual flash pages with those. All data stored using the FDS will then be stored within these virtual pages, so your application data would be stored alongside the peer manager data. You can read and modify your data using the record key and file ID you provided when storing them.

    You can also use fstorage directly if you prefer that. You will then specify the number of physical flash pages you want to reserve for your application data, and only your data will be stored in those flash pages.

    The following github link contains a FDS example, which is a modified version of the proximity example, which uses the peer manager, where some predefined data is also written to, read and deleted from flash with FDS. See the three functions just above the main function.

    github.com/.../nRF5-flash-storage-examples

    There is also an example for fstorage based on the ble template project.

    The examples are written for SDK11, but to my knowledge there haven't been made a lot of changes to FDS function calls since then.

    Best regards

    Jørn Frøysa

Related