Does deleting records via FDS or during garbage collection (GC), stored data is reset or retains what was being written?

We have been using FDS to store certain data in the NOR flash, which is often erased and written with new data. What I understand about FDS is that, when we erase a record, it is not erased from NOR flash but actually it becomes invalidated, therefore not accessible via FDS and once garbage collection (GC) happens, those invalidated memory space is reclaimed. 

What I am trying to understand is that, once the record is invalidated, if we try to read that memory location (by directly referencing it and not using FDS), will the value that written there be still present or would have to got reset to say 0xFFFFFFFF or 0xA5A5A5A5. If value is not reset, then will it get reset after GC? Apart from reclaiming the invalid records, does it also reset its value?

Parents
  • What I am trying to understand is that, once the record is invalidated, if we try to read that memory location (by directly referencing it and not using FDS), will the value that written there be still present

    The values will still be there, only a part of the header will be changed to mark the record as 'dirty'.

    https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/lib_fds_format.html has a description of the storage format. So  only the record key is set to FDS_RECORD_KEY_DIRTY when a record is invalidated.

    If value is not reset, then will it get reset after GC?

    Yes, garbage collection is the phase when the flash is actually erased.

  • Thanks for the reply.

    So what I understand about GC process is that, first the GC page or Swap page is erased, then valid records from data page is moved to the swap page, which now becomes the data page and the previous data page now becomes the swap page.

    Now I am trying to understand the placement of valid data records in the new data page, will it same as it was in the previous data page or the valid records will be placed from the starting memory location in this new page. For ex- If earlier in the previous data page, from the starting location, 20 bytes were invalid records followed by 10 bytes of valid records. So after GC, in the new data page, from the starting location, will the 20 bytes area be vacant followed by 10bytes of valid data or first 10 bytes in that page itself will be occupied with the valid data?

  • Valid data will be written to the start of the page. There would be no benefit in leaving holes  where old data used to be.

Reply Children
Related