SFCB to save persistence data for #bluetoothmesh

Vikrant More <vikrant8051@...>

Hi Johan,

Is SFCB better option than NFFS to save #BluetoothMesh's persistence data ?
Will it help us in case of nRF51 series which has limited flash storage ?

Thank You !!

---------- Forwarded message ----------
From: Laczen JMS <laczenjms@...>
Date: Sat, Feb 10, 2018 at 2:30 PM
Subject: Re: [Zephyr-devel] [Zephyr-users] Power Configuration of nrf52840 (Vikrant More)
To: zephyr-devel@...

Hi Vikrant,

NFFS file system might not be a good choice to store frequently changing data.

For this case I have created a library called sfcb that you can find
in my zephyr project fork: https://github.com/Laczen/zephyr. The sfcb
(simple flash circular buffer) allows you to store data in a series of
sectors in flash.

All data is stored as a identifier-value pair, the identifier is a 16
bit value, the data can be anything from a byte to a very long string
of bytes (limited by the sector size). By writing a new
identifier-value pair the previous pair with the same identifier is
considered overwritten.

When all the available sectors have been used the library does a
garbage collection phase before erasing a sector. In this phase it
makes sure that there is at least one identifier-value pair for each

The library allows you to combine almost constant data: node address,
netkeys, groups together with frequently changing data: sequence
number, iv_index into one storage solution, without wearing out flash
to fast. The almost constant data could be stored into one
identifier-value pair, the frequently changing in a different
identifier-value pair. Of course for the sequence number you will need
to avoid storing it for every change.

It can also be used in different cases where you would like to combine
the storage of network address, device name, ... in combination with
the device state (e.g. light switched on) in the same storage

Another use of the library is to consider the identifier as a file
name and the value as file contents.

In my zephyr project fork you can find a simple example in samples/subsys/sfcb.

Kind regards,