Hi,

> On Jun 26, 2017, at 3:29 AM, Laczen JMS <[email protected]> wrote:
> 
> Hi,
> 
> I would like to use flash circular buffers for variable storage and
> logging. I am not sure how to initialize and use the buffers. I am working
> on a nrf51 system.
> 
> The first use case is storing of data (e.g. integer), I would like to store
> data1 (int), data2 (int), data3 (int) in the flash area FLASH_AREA_NFFS:
> (in my case only 2kb). How do I initialize and use a FCB for each data
> element (data1 ... data3) in one flash area (FLASH_AREA_NFFS)?

as you probably have gathered, FCB works on units of sectors. These
sectors being defined in the flash driver.

FCB can work with one sector present only, but if you want some data
retention when your area overflows, you’ll probably want to allocate
at least 2 sectors per area.

If you need to create 3 separate FCB areas, you’ll have to set aside
space accordingly.

I imagine you should start by setting your BSP’s bsp.yml such that you have
the space to keep those FCBs. Note that the flash_map, with these
ids (e.g. FLASH_AREA_NFFS) is an abstraction layer which we needed
to make it easier to have an code which is platform independent regarding 
locations.
I.e. you don’t have to use those ids for your data. You can, of course,
should you choose :)

Unfortunately I don’t think there’s specific documentation written for FCB,
but for simple use cases, take a look at unit tests in 
fs/fcb/test/src/testcases.

> 
> The second use case is for logging. I would split the FLASH_AREA_REBOOT_LOG
> (16kb) area in 2 area's of each 8kb: FLASH_AREA_REBOOT_LOG (8kb) and
> FLASH_AREA_LOG (8kb), how do I setup a logger to use the FLASH_AREA_LOG?

You create 2 different loggers, and then assign logs from subsystem(s) to go
to these different logger targets. Intent was that you should be able to have 
multiple
separate FCB areas where you log data to. I believe this to be the case, but I 
have
not tried that myself. Again, the unit tests for package sys/log/full
would probably be helpful in getting started. These are in 
sys/log/full/test/src/testcases

Hope this helps,
M

Reply via email to