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 writes while performing garbage collection.

I'm testing this with SDK 15.2 on an NRF52832, with SD132.

The documentation says: "When the space is exhausted, write requests return the error FDS_ERR_NO_SPACE_IN_FLASH, and you must run garbage collection and wait for completion before repeating the call to the write function."

But if i call fds_record_update(), immeditaly after calling fds_gc(), it will return FDS_ERR_SUCCESS. Has this behaviour changed, while documention was not? Is it safe to write before GC is done?

Parents
  • Hi,

    The reason that you should wait for the asynchronous function to return is because it guarantees that the garbage collection has released the memory. A program that doesn't wait for the function to return could result in unexpected behavior. 

    Best regards

    Jared

  • Right, so shouldn't fds_record_write() return FDS_ERR_BUSY? I only have 1 FDS user, but when you have multiple, the other users don't even know GC started.

  • Hi, 

    No, FDS_ERR_BUSY is not returned by fds_record_write(), but is returned by record_write_data(). The latter is an internally function used by the module which is not meant to be used directly by the application. The documentation for fds_record_write() specifies the return types as follows:

    Return values

    FDS_SUCCESS If the operation was queued successfully.
    FDS_ERR_NOT_INITIALIZED If the module is not initialized.
    FDS_ERR_NULL_ARG If p_record is NULL.
    FDS_ERR_INVALID_ARG If the file ID or the record key is invalid.
    FDS_ERR_UNALIGNED_ADDR If the record data is not aligned to a 4 byte boundary.
    FDS_ERR_RECORD_TOO_LARGE If the record data exceeds the maximum length.
    FDS_ERR_NO_SPACE_IN_QUEUES If the operation queue is full or there are more record chunks than can be buffered.
    FDS_ERR_NO_SPACE_IN_FLASH If there is not enough free space in flash to store the record.

    Note: that the return of FDS_SUCCESS does not mean that the write operation is done, but that the operation has been staged. 

    Best regards

    Jared

Reply
  • Hi, 

    No, FDS_ERR_BUSY is not returned by fds_record_write(), but is returned by record_write_data(). The latter is an internally function used by the module which is not meant to be used directly by the application. The documentation for fds_record_write() specifies the return types as follows:

    Return values

    FDS_SUCCESS If the operation was queued successfully.
    FDS_ERR_NOT_INITIALIZED If the module is not initialized.
    FDS_ERR_NULL_ARG If p_record is NULL.
    FDS_ERR_INVALID_ARG If the file ID or the record key is invalid.
    FDS_ERR_UNALIGNED_ADDR If the record data is not aligned to a 4 byte boundary.
    FDS_ERR_RECORD_TOO_LARGE If the record data exceeds the maximum length.
    FDS_ERR_NO_SPACE_IN_QUEUES If the operation queue is full or there are more record chunks than can be buffered.
    FDS_ERR_NO_SPACE_IN_FLASH If there is not enough free space in flash to store the record.

    Note: that the return of FDS_SUCCESS does not mean that the write operation is done, but that the operation has been staged. 

    Best regards

    Jared

Children
Related