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

Queries on FDS records

Hello,

I am using nRF52840, SDK_16.0.0, SoftDevice S140 V7.0.1 and Segger for flashing the image. I am using ‘ble_app_blinky’.

 

1) Do we need to call fds_record_close(). As per below statement in below link. I am bit confused with the statement and fds example code. In example  fds_record_update() is called after fds_record_close(). Once closed, even to update do we need to open.

                “So if you need to access the data after closing the record, you must open it again.”

                https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v16.0.0%2Flib_fds_usage.html&anchor=lib_fds_usage_retrieve

  

2) As per below statement do I need to call fds_init() after ble_stack_init() as we have SoftDevice. But I am able to call fds_init() before SoftDevice Initilization.

           “Before initializing FDS, you must initialize the SoftDevice and register a callback handler to handle FDS events.”

 https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v16.0.0%2Flib_fds_format.html

 

3) Once I receive FDS_ERR_NO_SPACE_IN_FLASH, whether can I call fds_gc() directly.

a) (Or) Before calling garbage collection, do I need to close the record.

b) Also do I need to delete record fds_record_delete() before initiating garbage collection.

 

4) Assume I have 4 records and I am updating one record very frequently and received  FDS_ERR_NO_SPACE_IN_FLASH. Now if I do garbage collection, will it erase other 3 records.

a) Assume I keep updating the record. Once there is no space and if I want to call garbage collection, what will happen to last updated record value. After reset, I need to get latest value for all record. Whether it be taken backup before erasing the record.

 

Thanks & Regards

Vishnu Beema

Parents
  • Hi,

    1. fds_record_close() is only used after you have opened an existing record for reading using fds_record_open(). For updating/deleting a record, you do not need to open it first.

    2. If you are using the softdevice backend for FDS, you should initialize the softdevice first to enable the softdevice API calls required by FDS/fstorage. Failing to initialize the softdevice before the API calls are made, may lead to hardfaults or errors.

    3. You can run garbage collection without closing records first, but it will not be able to complete successfully on the page with open records. Garbage collection works by moving valid records to a swap page before the old data page is erased and the swap page is promoted to a data page. The old data page is changed to a new swap page. Both delete and update functions will generate garbage (update function is essentially delete- and write-operations combined). If no records have been deleted or updated, there should be no garbage to collect.

    4. No, as I described in 3, all valid records are moved to a new page before the old page is erased.

    Best regards,
    Jørgen

Reply
  • Hi,

    1. fds_record_close() is only used after you have opened an existing record for reading using fds_record_open(). For updating/deleting a record, you do not need to open it first.

    2. If you are using the softdevice backend for FDS, you should initialize the softdevice first to enable the softdevice API calls required by FDS/fstorage. Failing to initialize the softdevice before the API calls are made, may lead to hardfaults or errors.

    3. You can run garbage collection without closing records first, but it will not be able to complete successfully on the page with open records. Garbage collection works by moving valid records to a swap page before the old data page is erased and the swap page is promoted to a data page. The old data page is changed to a new swap page. Both delete and update functions will generate garbage (update function is essentially delete- and write-operations combined). If no records have been deleted or updated, there should be no garbage to collect.

    4. No, as I described in 3, all valid records are moved to a new page before the old page is erased.

    Best regards,
    Jørgen

Children
No Data
Related