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

Unable to read from flash using FDS ?

Hello to all,

I have developed our project and successfully write data into flash but got stuck for retrieve data from flash.

When I call read function getting 0xffffff length continuous in record read here is my below function:

uint8_t *fds_read_data(uint16_t file_no, uint16_t file_key, uint8_t *read_data) {
  uint32_t read_counter = 0;
    ret_code_t err_code;
    uint32_t length = 0;
    fds_flash_record_t flash_record = {0};
    fds_record_desc_t record_desc = {0};
    fds_find_token_t ftok = {0};
    memset(&ftok, 0x00, sizeof(fds_find_token_t));
    memset(&record_desc, 0x00, sizeof(fds_record_desc_t));
    memset(&flash_record, 0x00, sizeof(fds_flash_record_t));
    while (fds_record_find(file_no, file_key, &record_desc, &ftok) == FDS_SUCCESS) {
      err_code = fds_record_open(&record_desc, &flash_record);
      if (err_code != FDS_SUCCESS) {
        // Handle error
        NRF_LOG_DEBUG("fds_record_open error %d\r\n", err_code);
      }
      uint8_t *data;
      data = (uint8_t *)flash_record.p_data;
      length = flash_record.p_header->length_words * sizeof(uint32_t);
      for (int j = 0; j < length; j++) {
        read_data[read_counter++] = data[j];
      }
      // Close the record when done.
      err_code = fds_record_close(&record_desc);
      if (err_code != FDS_SUCCESS) {
        // Handle error
        NRF_LOG_DEBUG("fds_record_close err_code %d\r\n", err_code);
      }
    }
  NRF_LOG_DEBUG("[FDS] read Data is:%s\n", (uint8_t *)read_data);
  return read_data;
}

Getting stuck for How i read proper data from flash using FDS lib

Looking forward to your response..!!!

Thanks,

Vishal Borle

Parents Reply Children
No Data
Related