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

FDS records and chunks usage

I have a question about the usage of Flash Data Storage, chunks and parsing of the data retrieved from FDS.

  1. How, when and why are you supposed to use "chunks" when setting up a record? None of the examples I've seen uses chunks, but there must be some good use for it, I guess?

I want to save this data structure as a FDS record:

typedef struct
{
    uint16_t        sequence_number;
    uint32_t	    timestamp;
	uint16_t	    data;
    uint8_t         type;
} ble_data_meas_t;

Would I be better off splitting it up into 1-word chunks, or a big 3-word chunk?

  1. The length_words parameter. My data is not a multiple of word (32 bits). If I set length_words to 3 when writing the record, will that amount of space be allocated and used for each record, with 0.75 words empty? How can I optimize this? No I need to pad manually, or is this managed in the background?

  2. Parsing of retrieved data. I am using fds_record_find and fds_record_open to access records. If I understand correctly, my data will be returned in fds_flash_record_t (a pointer to the place in flash). How do I parse this to put the correct data back into each member of my struct?

  • Hi Sakitten,

    1. We designed chunks in accordance with record to give some more flexibility of where the data can be stored in RAM before it's stored in flash. (Data in one record can be distributed in RAM). However, we are considering to remove this feature, but not for now.

    In your case simply use one chunk is fine. The size of a chunk is not limited.

    1. The NVMC peripheral on the nRF5 doesn't support accessing non word aligned address. It's not handled automatically, so you need to round your data size to meet with the number of word, in your case it's 3 words.

    2. You can simply use a pointer and cast the fds_flash_record_t.p_data to your struct data format. You may need to use memcpy to move from flash to RAM.

Related