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

FDS write failure

Hi,

I am seeing some random behavior on FDS write:

1.sometimes it won't receive any callback for 2 seconds

19:57:49 - logMessage: "Fds_Write_Async 2"

19:57:51 - logMessage: "Fds_write timeout"

2. sometimes it won't find the exisiting the record, though the previous one was just read
19:57:55 - logMessage: "Fds_Write_Async 2"
19:57:55 - logMessage: "FDS event: type 2 ret 34313 record_id 6 file_id 1 record_key 2 update 0"
ret 34313 is  FDS_ERR_NOT_FOUND
3. after a write timeout, the next write with a different record triggered the event for the previous record
19:58:52 - logMessage: "Fds_Write_Async 2"
19:58:54 - logMessage: "Fds_write timeout"
19:58:55 - logMessage: "Fds_Write_Async 1"
19:58:55 - logMessage: "FDS event: type 2 ret 34313 record_id 12 file_id 1 record_key 2 update 0"
Normally when it works I saw multiple event coming back(here I am updating the record):
19:59:11 - logMessage: "Fds_Write_Async 2"
19:59:11 - logMessage: "SD event received"
19:59:11 - logMessage: "SD event received"
19:59:11 - logMessage: "SD event received"
19:59:11 - logMessage: "SD event received"
19:59:11 - logMessage: "SD event received"
19:59:11 - logMessage: "FDS event: type 2 ret 0 record_id 12 file_id 1 record_key 2 update 1"
here is my write logic, all the writes are synchronized in the upper layer so they are happening in sequence:
// If data already exists, update it
if (fds_record_find(record.file_id, record.key, &record_desc, &ftok) == NRF_SUCCESS) {
ret = fds_record_update(&record_desc, &record);
} else {
ret = fds_record_write(&record_desc, &record);
}
Any idea what might be going wrong?
Thanks,
-Ray
  • Hello,

    If you are using FreeRTOS you should be aware that FDS is not thread safe by itself, so I know there are some special considerations that should be done before and after executing FDS calls. If you think it may be FreeRTOS related, I may need to transfer this case to someone with in-depth experience with FreeRTOS. 

    1.sometimes it won't receive any callback for 2 seconds

    Typically flash operations have the second lowest (fourth) priority compared to other softdevice activities, see here:
    https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/multilink_scheduling/priorities_and_events_intro.html

    Can it be that you have other activities with high priorities that may delay or cause the flash operation to timeout? If you experience timeout you may try to increase NRF_FSTORAGE_SD_MAX_RETRIES.

    If the activity that prevents the flash operations to be executed immediately is stopped, you may suddenly get multiple flash operations completed in a row afterwards. They may have been queued until success.

    Best regards,
    Kenneth

Related