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

FDS Example - so what does "freeable words" actually mean?

Even immediately after issuing a gc (garbage collect) command, "freeable words" is still 1022:

fds example:~$ stat

total pages:    2
total records:  3
valid records:  1
dirty records:  2
largest contig: 1024
freeable words: 1031 (4124 bytes)
reserved words: 0
used     words: 2

fds example:~$ gc
<info> app: Event: FDS_EVT_GC received (FDS_SUCCESS)
fds example:~$ stat
total pages:    2
total records:  2
valid records:  1
dirty records:  1
largest contig: 1024
freeable words: 1022 (4088 bytes)
reserved words: 0
used     words: 2

fds example:~$

Why?

What does this number actually mean?

The documentation just says,

The largest number of words that can be reclaimed by garbage collection.

The actual amount of space freed by garbage collection might be less than this value if records are open while garbage collection is run.

But, even after doing delete all, and gc, it is still 1022:

fds example:~$ delete_all
<info> app: Deleting next record.
<info> app: Event: FDS_EVT_DEL_RECORD received (FDS_SUCCESS)
<info> app: Record ID:  0x0015
<info> app: File ID:    0xF010
<info> app: Record key: 0x7010
<info> app: Deleting next record.
<info> app: No records left to delete.
fds example:~$ gc
<info> app: Event: FDS_EVT_GC received (FDS_SUCCESS)
fds example:~$ stat
total pages:    2
total records:  1
valid records:  0
dirty records:  1
largest contig: 1024
freeable words: 1022 (4088 bytes)
reserved words: 0
used     words: 2
fds example:~$

Why?

If they are "freeable" - why does gc not free them??!

Parents Reply Children
  • Yes It does that sometimes. Devzone is (since the update) a bit flaky. You can remove the _build or output (depending on what IDE you are using) folder inside the project. This will reduce the size significantly. Then try again.

     

    Can you please describe what commands you wrote in the UART terminal? Was it only the part that is included in the log output in your initial post?

     

    BR,

    Edvin

  • Just as shown, I think.

    In my real app (on a different board), the initialisation was failing with FD_ERROR_NO_PAGES.

    I've just tried doing a complete chip erase, then reprogramming the SD and app - and that error goes away!

    So it looks like the FDS is (or can be) sensitive to what's been in flash before?

    I'll have to try the full erase & reprogram with the example ...

  • From fds.c:

    /**@brief The largest number of words that can be reclaimed by garbage collection.
    *
    * The actual amount of space freed by garbage collection might be less than this value if
    * records are open while garbage collection is run.
    */
    uint16_t freeable_words;

     

    So freeable_words is the total number of words in your dirty_records. I have not looked to much in the details of the example, but it might be that the record was open when you ran gc. If you have modified the example, that is possible, but I don't think the example should leave any records open when you run the cli commands.

     

    BR,

    Edvin

  • and the number - 1022 - is far larger than the size of a record!

  • So it looks like the FDS is (or can be) sensitive to what's been in flash before?

    Yes. The application data area of flash is separate from that of the application itself, and so the data is left unchanged when you re-download the application only. I.e. whatever application data is stored from previously is still there, unless explicitly cleared. Doing a full erase solves this issue, as does erasing the application data flash pages (e.g. with `nrfjprog --erasepage'.)

Related