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

FDS initial state

Hi, Id like to understand the FDS state after flashing the device. Im trying to check if the record exists then I use it, otherwise I write a valid info into the record. For some reason after flashing the record always exists, but obviously with some random data. How can I make sure that there is no data written in FDS?

Thanks!

image description

Parents
  • FormerMember
    0 FormerMember

    The data in flash will only be erased if you specifically do so. Re-programming chip will not erase flash.

    When using FDS, data in flash will only be erased from flash if you do a garbage collection. When deleting a record using FDS, the record itself will not immediately be deleted, but instead its record key will be set to 'zero' only. When doing garbage collection, the records with the record key 'zero' will be deleted.

  • FormerMember
    0 FormerMember in reply to FormerMember

    1) then the printout always shows the first BT address that I wrote in memory, but not the second one:

    Do you mean that the printout always shows the oldest record and not the one that was newly written? If you want to update the data of a record, you should use fds_record_update(). If you write to a FILE with a given RECORD_KEY, and that file and record key already exists, there will be two records with the same record key in the same file. From what I can see in fdsRead(), it only calls fds_record_find() once, so it will only find the first instance for a given record key.

    2) How do you see that the FDS init callback gets called twice?

Reply
  • FormerMember
    0 FormerMember in reply to FormerMember

    1) then the printout always shows the first BT address that I wrote in memory, but not the second one:

    Do you mean that the printout always shows the oldest record and not the one that was newly written? If you want to update the data of a record, you should use fds_record_update(). If you write to a FILE with a given RECORD_KEY, and that file and record key already exists, there will be two records with the same record key in the same file. From what I can see in fdsRead(), it only calls fds_record_find() once, so it will only find the first instance for a given record key.

    2) How do you see that the FDS init callback gets called twice?

Children
No Data
Related