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

FDS garbage collection not clearing dirty records

Hi below is the function i am using to run garbage collection after deleting the data but the result i am getting was the same as before garbage collection.

I mean DIRTY_RECORDS_BEFORE_GC = DIRTY_RECORDS_AFTER_GC.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
static void delete_all() {
NRF_LOG_INFO("deleting all records...");
ret_code_t rc;
bool next_record = true;
while (next_record) {
fds_record_desc_t record_desc = {0};
fds_find_token_t ftok = {0};
if (fds_record_iterate(&record_desc, &ftok) == FDS_SUCCESS) {
ret_code_t ret = fds_record_delete(&record_desc);
while (!fds_delete_complete)
;
fds_delete_complete = false;
//NRF_LOG_INFO("Iterate suc..");
next_record = true;
} else {
next_record = false;
}
}
fds_stat_t stat = {0};
rc = fds_stat(&stat);
APP_ERROR_CHECK(rc);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 

Do i need to reinitialize the fds again to get proper dirty records value?

  • Yes exactly the same whatever you mentioned i was doing.

  • Are you able to upload your project so I can try to debug it here?

  • This is the project I am doing so its difficult to disclose in public. If any other source is there to upload my project privately then it is fine for me or else i will re-produce the issue with some code snippet and post it here within some couple of minutes.

  • 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    /**
    * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA
    *
    * All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without modification,
    * are permitted provided that the following conditions are met:
    *
    * 1. Redistributions of source code must retain the above copyright notice, this
    * list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form, except as embedded into a Nordic
    * Semiconductor ASA integrated circuit in a product or a software update for
    * such product, must reproduce the above copyright notice, this list of
    * conditions and the following disclaimer in the documentation and/or other
    * materials provided with the distribution.
    *
    * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
    * contributors may be used to endorse or promote products derived from this
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    I attached Modified flash_fds example from SDK 15.3.0 to reproduce the issue. But one thing i am not able to understand was if i send 'stat' command via putty-Terminal then it gives dirty records as '0'. How come?

  • Thanks, but you're calling fds_stat() immediately after calling fds_gc() so the garbage collection does not get time any to complete.

    Code using fds_gc_complete flag:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /**
    * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA
    *
    * All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without modification,
    * are permitted provided that the following conditions are met:
    *
    * 1. Redistributions of source code must retain the above copyright notice, this
    * list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form, except as embedded into a Nordic
    * Semiconductor ASA integrated circuit in a product or a software update for
    * such product, must reproduce the above copyright notice, this list of
    * conditions and the following disclaimer in the documentation and/or other
    * materials provided with the distribution.
    *
    * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
    * contributors may be used to endorse or promote products derived from this
    * software without specific prior written permission.
    *
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

1 2 3