Storing sensor data as circular buffer in non volatile memory

Hey guys,

I want to store sensor data as circular buffer in non volatile memory. I saw
https://docs.nordicsemi.com/bundle/zephyr-apis-latest/page/group_file_system_storage.html and https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/services/storage/index.html. But researching here in the devzone I can see that users have issues like here https://devzone.nordicsemi.com/f/nordic-q-a/110506/nrf5340-fcb-flash-circular-buffer-on-external-flash/530085

I was trying to use NVS but it seems that it overwrites data as stated here https://github.com/nrfconnect/sdk-zephyr/blob/a1d9a8db0ea4bbee2e69feec1140e6ce20e62f5e/samples/subsys/nvs/src/main.c#L30
But of course I need the complete history of my data.

So my question is what is currently the best approach for this?

Best

Parents Reply
  • Hi Artnia,

    Most persistent storage solution over flash works the same way as NVS, and has the same limitation that history is completely removed upon garbage collection. I am not aware of any other module/subsystem/etc that behave differently.

    An option is to write your own version of NCS, or a subsystem based on it, that upon switching flash page, not only copy the newest value, but also copy a configurable number of past values.

    If you do that, you could also consider making it a contribution to NVS/the Zephyr project.

    Best,

    Hieu

Children
Related