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

Why are the records getting dirty in fds example

I am trying to use the fds example provided in the sdk16, while viewing the debugging prints I see the following,

<info> app: Initializing fds...
<info> app: Event: FDS_EVT_INIT received (NRF_SUCCESS)
<info> app: Found 1 valid records.
<info> app: Found 41 dirty records (ready to be garbage collected).

Every time I restart the boot count is rightfully incremented and saved back on the flash also displayed in the debugging log. Why are the records getting dirty (and I need to run garbage collector).

Thank you

  • Are you sure you did only write one word? Note that the data.length_words parameter in the fds_record_t struct takes the number of words, not the number of bytes, to be written. If you use sizeof() or similar to get the size of the struct, you need to divide by 4.

    I modified the FDS example to output stats.words_used and it seems to work correctly:

    fds example:~$ stat
    total pages:    3
    total records:  2
    valid records:  2
    dirty records:  0
    largest contig: 1022
    freeable words: 0 (0 bytes)
    words used:     12
    fds example:~$ write 0xFF 0xFF TEST
    writing record to flash...
    file: 0xFF, key: 0xFF, "TEST", len: 4 bytes
    <info> app: Event: FDS_EVT_WRITE received (NRF_SUCCESS)
    <info> app: Record ID:  0x0003
    <info> app: File ID:    0x00FF
    <info> app: Record key: 0x00FF
    fds example:~$ stat
    total pages:    3
    total records:  3
    valid records:  3
    dirty records:  0
    largest contig: 1022
    freeable words: 0 (0 bytes)
    words used:     16

  • That was the case.

    .data.length_words = (sizeof(four_word_cfg) + 3) / sizeof(uint32_t),

Related