HI,
I am building my application on one of the nordic ble_app in SDK 15.3.. currently, I am facing a strange issue. I am using fds to store some data on the flash. my write operation is successful and data is written. my read operation is always faulty. it points somewhere else. Although the found record ID is correct the data and pointer to memory both are wrong. I have used the example code. I have also checked the GitHub example but I am stuck here. I have attached the screenshot of the log messages.
The data I am writing is deadbeef
kidly help I am stuck here for two days.
thanks.
void read_record(fds_record_t* record, uint16_t file_id, uint16_t key) { ret_code_t rc; fds_record_desc_t desc; fds_find_token_t tok; fds_flash_record_t flash_record; record->file_id = file_id; record->key = key; memset(&tok, 0x00, sizeof(fds_find_token_t)); //fds_find_record_ rc = fds_record_find(file_id, key, &desc, &tok); if(rc==NRF_SUCCESS) { /* A file is in flash. Let's update it. */ /* Open the record and read its contents. */ rc = fds_record_open(&desc, &flash_record); APP_ERROR_CHECK(rc); /* Copy the configuration from flash into record. */ NRF_LOG_INFO("Found Record ID = %d\r\n",desc.record_id); //memcpy((uint8_t*)record->data.p_data, (uint8_t*)config.p_data, record->data.length_words * 4); // record->data.p_data = config.p_data; uint32_t* data = (uint32_t *)flash_record.p_data; record->data.p_data = data; record->data.length_words = flash_record.p_header->length_words; for (uint8_t i=0;i<flash_record.p_header->length_words;i++) { NRF_LOG_INFO("0x%8x",data[i]); } NRF_LOG_INFO("Record file found..\n"); NRF_LOG_INFO("Record file location 0x%x\n", data); NRF_LOG_INFO("Record file length %d\n", flash_record.p_header->length_words); /* Close the record when done reading. */ rc = fds_record_close(&desc); APP_ERROR_CHECK(rc); } } void write_record(fds_record_t* record) { ret_code_t rc; m_fds_write = false; fds_record_desc_t desc = {0}; fds_find_token_t tok = {0}; rc = fds_record_find(record->file_id, record->key, &desc, &tok); if (rc == NRF_SUCCESS) { /* A file is in flash. Let's update it. */ /* Write the updated record to flash. */ rc = fds_record_update(&desc, record); if ((rc != NRF_SUCCESS) && (rc == FDS_ERR_NO_SPACE_IN_FLASH)) { NRF_LOG_INFO("No space in flash, delete some records to update the config file.\n"); } else { APP_ERROR_CHECK(rc); } } else { /* System config not found; write a new one. */ NRF_LOG_INFO("Writing config file...\n"); rc = fds_record_write(&desc, record); if ((rc != NRF_SUCCESS) && (rc == FDS_ERR_NO_SPACE_IN_FLASH)) { NRF_LOG_INFO("No space in flash, delete some records to update the config file.\n"); } else { APP_ERROR_CHECK(rc); } } while(m_fds_write == false); }