Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Managing multiple files with significant difference is size, using FDS module

I will want to have multiple files in my application, so I will use multiple file IDs when writing records.

At a minimum, I will want one file which will store about 200 bytes worth of raw configuration data.  The second file will be used as a event log; I will want to store at least 1024 events, where each event is 16 bytes.

For the configuration data, I would use one record key and update the record when changes need to be made.

For the event data, I would start with a record key of 1, and increment the key every time a new event is logged.  When required, I would open the file with records (events) and send them the raw data of each record back to the client.  After 1024 records are recorded, I would want the 1025th record to overwrite the 1st record (but the record ID would continue to increment).

In all, I would want File 1 to be ~214 bytes in size, and I would want File 2 to be ~16KB in size. 

Would this mean I would want FDS_VIRTUAL_PAGE_SIZE to be 20KB, and I would have to set FDS_VIRTUAL_PAGES to 2, therefore allocating 40KB of flash for FDS?

Is there a better way to do this?  My other thought was using the Flash Storage module and writing a driver to handle raw flash transactions to handle event data.

Parents
  • Hi

    I can't think of any better way to store this amount of data I'm afraid. 2 pages should do I guess, as that will leave you with the option to do garbage collection for example, but you will indeed need to allocate ~35kB if flash for the FDS module. What I will suggest is that you pay attention to the fragmentation of the two files you're storing, as you might end up wasting a lot of space when the file sizes are so different if they aren't fragmented properly.

    Best regards,

    Simon

  • Page size has to be on 4KB boundaries. And minimum number of pages is 2.  I could sacrifice the number of 16 byte records to fit it all in 16KB, however you'd still need 1 extra page that eats up an additional flash... i think.

Reply Children
No Data
Related