I am using FDS as recommended in nRF datasheet as API for on-chip flash : https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v11.0.0%2Fgroup__flash__data__storage.html
I can successfully read and write various sizes of data into flash, however, I find Nordic provided fds_gc() is causing unalignment when wiping memory as this error:
<error> nrf_fstorage: addr_is_page_aligned(p_fs, page_addr) check failed in nrf_fstorage_erase() with value 0x10.
I am pretty sure I am not the only one having this issue. The only time I called to fds_record_delete is here:
/*!
* @brief find and delete data from non volatile flash memory on nrf52832.
*
* @param file_id : 1st tracking ID for stored data. User faced, not the real number being used in low level driver
record_key : 2nd tracking ID for stored data. User faced, not the real number being used in low level driver
*
* @returns ret_code_t
*/
ret_code_t fds_test_find_and_delete (uint16_t file_id, uint16_t record_key)
{
file_id++;
fds_record_desc_t record_desc;
fds_find_token_t ftok;
ftok.page=0;
ftok.p_addr=NULL;
// Loop and find records with same ID and rec key and mark them as deleted.
while (fds_record_find(file_id, record_key, &record_desc, &ftok) == NRF_SUCCESS)
{
ret_code_t ret = fds_record_delete(&record_desc);
if (ret != NRF_SUCCESS)
{
return ret;
}
NRF_LOG_INFO("Deleted record ID: %d",record_desc.record_id);
ut_DelayMs(50);
}
// // call the garbage collector to empty them, don't need to do this all the time, this is just for demonstration
// ret_code_t ret = fds_gc();
// if (ret != NRF_SUCCESS)
// {
// return ret;
// }
return NRF_SUCCESS;
}
fds_record_delete marks this data as dirty, then fds_gc() later clears this data and reformats the flash.
Is there anything I can do to fix this issue?
