Issue with Data Deletion and Garbage Collection in FDS

SDK: nRF5_SDK_17.1.0

I am currently encountering some difficulties regarding data deletion and garbage collection after recording in my Nordic application. I have followed the instructions provided by NRF closely, yet I seem to face persistent issues.

I have the impression that the code indicates that the deletion and garbage collection have been successfully completed, but when I examine the actual dirty records, they are not deleted. It seems that the garbage collection only works successfully during device initialization

Here's a snippet of the code I'm using:

void app_fds_delete_file(uint16_t my_file_id)
{
    ret_code_t rc;

    NRF_LOG_INFO("Deleting files...");
    rc = fds_file_delete(my_file_id);
    APP_ERROR_CHECK(rc);

    wait_for_del_file();

    app_fds_garbage_collection();
}

In the fds_evt_handler, m_fds_del_file is set to true in response to FDS_EVT_DEL_FILE.

static void app_fds_garbage_collection(void)
{
    ret_code_t rc;

    NRF_LOG_INFO("Trying to run garbage collection...");
    rc = fds_gc();
    APP_ERROR_CHECK(rc);

    wait_for_gc();
}
static void wait_for_del_file(void)
{
    while(!m_fds_del_file)
    {
        power_manage();
    }

    m_fds_del_file = false;
}

Here's an excerpt from the log showing the behavior during startup:

<info> app_timer: RTC: initialized.
<info> app: Initializing fds...
<info> app: Event: FDS_EVT_INIT received (NRF_SUCCESS)
<info> app: Reading flash usage statistics...
<info> app: Found 14 valid records.
<info> app: Found 10 dirty records (ready to be garbage collected).
<info> app: Found 16 pages_available.
<info> app: Found 0 open_records.
<info> app: Found 0 words_reserved.
<info> app: Found 1844 words_used.
<info> app: Found 2046 largest_contig.
<info> app: Event: FDS_EVT_GC received (NRF_SUCCESS)
<info> app: GC completed successfully.
<info> app: Sync file found.
<info> app: Sync storage round: 11
<info> app: Thu Jan 01 00:00:00 1970

At this point, querying the dirty records correctly returns 0, but if I save some data and try delete them the dirty records will never go back to 0.

I'm puzzled as to why this is happening. Could someone provide insights or suggestions on how to resolve this issue effectively?

Your assistance and expertise are greatly appreciated.

Parents Reply Children
No Data
Related