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

About garbage collection logic

SDK: 15.3.0
Device: EYSHJNZWZ (nRF52832)

Please tell me the operation when garbage collection is executed.
The setting values of FDS are shown below for reference.

#define FDS_ENABLED 1
#define FDS_VIRTUAL_PAGES 3
#define FDS_VIRTUAL_PAGE_SIZE 1024
#define FDS_VIRTUAL_PAGES_RESERVED 0

We recognize that it has the following configuration.
① Virtual page for garbage collection
② Usable virtual page A
③ Usable virtual page B

"PM_EVT_STORAGE_FULL" is generated when ② and ③ are full.
At that time, garbage collection is executed by calling "fds_gc".

What kind of data movement does ①②③ do?
For example, copy ② to ① and then clear ②?
For example, is ① cleared after writing to ② or ③?
I do not understand how it works.

Please tell me about the data flow when garbage collection is executed.
Please let me know if there is any reference material.

Parents
  • Hi Takashina, 

    You can read more about the garbage collection (GC) here: https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/lib_fds_functionality.html?cp=7_1_3_56_1_2#lib_fds_functionality_gc

    Basically, the FDS system doesn't do the erasing (or updating) a record. It only marks the records as deleted (invalidated). When (1) and (2) are full (of both invalided and valid records) the PM_EVT_STORAGE_FULL is generated. The application will have to call fds_gc(). This is when GC started. It will start with erasing the GC's page. Then copying the valid records inside (1) and (2) to the GC page and use the GC as one of the valid page. It continue o all data page, from (1) to (2) and so on. 
    This way we only do erasing the page once in a while (when doing GC) and limit the number of time an area in flash being erased. The GC page is not fixed to a physical page in flash but move from one page to another (rotating) so that we don't have a the same page being used as GC page. If the page doesn't have any invalided record, it will not be GC hence doesn't get erased. 

     

Reply
  • Hi Takashina, 

    You can read more about the garbage collection (GC) here: https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/lib_fds_functionality.html?cp=7_1_3_56_1_2#lib_fds_functionality_gc

    Basically, the FDS system doesn't do the erasing (or updating) a record. It only marks the records as deleted (invalidated). When (1) and (2) are full (of both invalided and valid records) the PM_EVT_STORAGE_FULL is generated. The application will have to call fds_gc(). This is when GC started. It will start with erasing the GC's page. Then copying the valid records inside (1) and (2) to the GC page and use the GC as one of the valid page. It continue o all data page, from (1) to (2) and so on. 
    This way we only do erasing the page once in a while (when doing GC) and limit the number of time an area in flash being erased. The GC page is not fixed to a physical page in flash but move from one page to another (rotating) so that we don't have a the same page being used as GC page. If the page doesn't have any invalided record, it will not be GC hence doesn't get erased. 

     

Children
Related