Dear Sirs,
I am trying to use the FDS Storage Library to store 4word = 16 bytes in to flash.. Which seems to be working fine. No errors and the function is shown below:-
static WriteDriverIDtoFlash(uint8_t DId[static 16]) { //static uint32_t const m_deadbeef = 0xbeefdead; // static char const m_hello[] = "Hello, world!"; fds_record_t record; fds_record_desc_t record_desc; // Set up record. record.file_id = FILE_ID; record.key = RECORD_KEY_1; record.data.p_data = &DId; record.data.length_words = 4; /* one word is four bytes. */ ret_code_t rc; DeleteAllFiles(); nrf_delay_ms(300); fds_gc(); nrf_delay_ms(300); rc = fds_record_write(&record_desc, &record); if (rc != NRF_SUCCESS) { NRF_LOG_INFO("Flash Write Error"); } }
However when i try to read the data i get the following error:-
app: Flash Record Found
<info> app: Flash Open Error FDS_ERR_CRC_CHECK_FAILED
Below is my read function
static ReadDriverIDFromFlash()
{
fds_flash_record_t flash_record;
fds_record_desc_t record_desc;
fds_find_token_t ftok;
/* It is required to zero the token before first use. */
memset(&ftok, 0x00, sizeof(fds_find_token_t));
/* Loop until all records with the given key and file ID have been found. */
while (fds_record_find(FILE_ID, RECORD_KEY_1, &record_desc, &ftok) == NRF_SUCCESS)
{
NRF_LOG_INFO("Flash Record Found");
uint32_t ret_code =fds_record_open(&record_desc, &flash_record);
if (ret_code != NRF_SUCCESS)
{
NRF_LOG_INFO("Flash Open Error %s",fds_err_str(ret_code));
}
//NRF_LOG_INFO("Flash Data Read %x",(*(uint8_t[]*)flash_record.p_data));
NRF_LOG_HEXDUMP_INFO(*(uint8_t*)flash_record.p_data, 16);
/* Close the record when done. */
if (fds_record_close(&record_desc) != NRF_SUCCESS)
{
NRF_LOG_INFO("Flash Close Error");
}
}
}
Please can some one help... I can not find anywhere a solution... I am not sure if I am reading properly... Do i need to tell the flash open how many words to read?