Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Hypothetical FDS Question

Hello All, 

this question pertains mostly to nRF5 SDK ver 17.1.0 

I was recently investigating a bug in a project that used FDS and in particular the record update functionality. The root cause ended up being something simple in my own code but it got me thinking about a hypothetical scenario that might have come up if I didn't catch the bug in the first place. Lets say for some reason I have accidentally written a new version of a file I meant to update, so instead of there being one "dirty" copy of the file and one clean copy there are now two clean copies whose headers only differ by their record ID, not in File ID or Record Key. If I later call the fds update function on this File ID, when the module is looking for old record ID's to  mark for garbage collection will it stop after finding the first record? will it ever catch that there are two copies of the same file or would I have to address this separately with an explicit function to iterate through all FDS pages and mark all but the newest record ID's for garbage collection?

Thanks

  • Hi,

    If I later call the fds update function on this File ID, when the module is looking for old record ID's to  mark for garbage collection will it stop after finding the first record?

    When you call the fds_record_update() you pass a descriptor as the first parameter. To get the correct descriptor before updating the record, you need to call fds_record_find() or similar, which will return the first record with the same key and file ID. Calling the find again with the returned descriptor will return the descriptor for the second record with the same key and file ID and so on... It's up to you to check that you have the correct descriptor before calling the update function.

    regards

    Jared 

Related