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

Unable to return from fds_gc(), stuck in infinite loop.

There is a bug in fds.c file, Please go through the below code snippet.

ret_code = fds_record_update(&desc, record_id);
if (ret_code == FDS_ERR_NO_SPACE_IN_FLASH)
{
            ret_code = fds_gc();
            ERROR_CHECK(ret_code);
            ret_code = fds_record_update(&desc, record_id);
 }

I do not return from fds_gc(), execution stays there for infinite. 

More information:

1) #define FDS_VIRTUAL_PAGES 30

2) #define FDS_VIRTUAL_PAGE_SIZE (1024)

3) Initialization is successful and able to write, update and read several records.

4) SDK version: nRF_SDK_15.2.0

The problem occurs when record_update is failed with FDS_ERR_NO_SPACE_IN_FLASH and followed by garbage collection function fds_gc().

According to me, a library function has to return an error code if something is wrong, but not locked in an infinite loop. This is a serious bug.

Please help me as I am stuck in the crucial phase of our development.

Regards,

Jagadeep

Parents
  • Hi,

    All FDS functions that writes to or erases flash are asynchronous, and fds_gc() is no exception. This means on the call to fds_gc() the actual garbage collection gets queued. You will get an FDS_EVT_GC event at a later point, when the garbage collection has run. This means that yes, the code snippet that you listed initially does not work. In the case where garbage collection is needed, what happens in that code is that garbage collection gets queued, then before garbage collection is finished there is a new attempt to write for which you should expect another ret_code of FDS_ERR_NO_SPACE_IN_FLASH.

    Have you done a debug session in order to confirm where you get stuck?

    Regards,
    Terje

Reply
  • Hi,

    All FDS functions that writes to or erases flash are asynchronous, and fds_gc() is no exception. This means on the call to fds_gc() the actual garbage collection gets queued. You will get an FDS_EVT_GC event at a later point, when the garbage collection has run. This means that yes, the code snippet that you listed initially does not work. In the case where garbage collection is needed, what happens in that code is that garbage collection gets queued, then before garbage collection is finished there is a new attempt to write for which you should expect another ret_code of FDS_ERR_NO_SPACE_IN_FLASH.

    Have you done a debug session in order to confirm where you get stuck?

    Regards,
    Terje

Children
No Data
Related