Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

writing same record with fds_record_update()

HI!

I use flash data storage (fds) to store some user inputs in flash. Everything works fine, but I am surprised by the fact that the function fds_record_update() is not smart enough to detect when an attempt is made to replace an existing record with exactly the same data.

Instead, fds_record_update()will invalidate the existing record and create a new one (exactly the same).

This causes unnecessary flash wear!

I know that I could check at every occasion before writing to the flash, if data have changed or not. But in my opinion this is something so simple that it should be implemented directly inside  fds_record_update()before writing to the flash.

Or maybe, there is some good reason why this has not (yet) been done?

Thank you!

 

Parents
  • Hi,

    Yes, FDS doesn't make any attempt to check if the data equal to the previous record as you say, this is something that has been left to application to handle. I will report this as a feature request internally.

    Best regards,

    Vidar

  • Thank you Vidar for considering this feature request.

    And while you are at it, there is a second situation which would be very easy to handle and that could preserve flash wear:

    in addition to checking if data has changed before updating a record in flash, please also check if the change consists only of bits that have flipped from '1' to '0'. In this case as well, it is not necessary to duplicate the record. The old record can instead be simply overwritten. This reduces the garbage and consequently the frequency and need of garbage collection (which wears the flash by erasing and rewriting it).

    Together, these two verifications would make just a few lines of code to be added in fds_record_update().

    Thank you!

  • It is a good suggestion, but the problem is that you are limited to 2 writes per word according to the specification (el. spec - Flash programming), so I'm not sure it will be worth it when considering  additional overhead and complexity this would add.

Reply Children
No Data
Related