Using Reserved virtual page space for storing very critical value which needs to be saved for a very long time.

Value can only be changed on characteristics write. Every time a new value has to be written to the critical component , I first erase the page and then write on that page.

/** Erase the page and then write to the reserved flash**/
ret_code_t ret = nrf_fstorage_erase(&reserve_fs,write_address,1,NULL);
return nrf_fstorage_write(&reserve_fs, write_address, page_tag_data1, 4 * sizeof(uint32_t), NULL);

This is the code snippet.

Is there a possibility that this method breaks at some point.

I am also doing GC(garbage collection) on the rest of the pages, can gc be done on this page as well.

Parents
  • The main problem with your implementaton is a power failure between page erase and writing new data. It is likely you will end up in a situation with no data in the reserved page in this situation, so this is something you at least need to handle in some way. Other than that it should be fine.

    To ensure your reserved page is not touched by the FDS module (that for instance can run GC) I sugggest to place the reserved page outside of the FDS area.

    Best regards,
    Kenneth

Reply
  • The main problem with your implementaton is a power failure between page erase and writing new data. It is likely you will end up in a situation with no data in the reserved page in this situation, so this is something you at least need to handle in some way. Other than that it should be fine.

    To ensure your reserved page is not touched by the FDS module (that for instance can run GC) I sugggest to place the reserved page outside of the FDS area.

    Best regards,
    Kenneth

Children
Related