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

FDS Write Operation Fails in Release Mode

Hello,

I'm using nRF52811 SoC with nRF5_SDK16.0.0 and SoftDevice v7.0.1. I'm using following code to write data into flash. This code is tested with nRF52840 in both debug as well as release mode. It works with nRF52811 as well but only when the the project is compiled in debug mode. Whenever it's compiled in release mode, A fatal error is reported upon data write and device gets a reset. Why this is happening?

Here is the code:

void record_update_rgb(uint8_t red, uint8_t green, uint8_t blue){
    ret_code_t rc;
    fds_record_desc_t desc = {0};
    fds_find_token_t  tok  = {0};

    NRF_LOG_INFO("Updating RGB Record...");
    wait_for_fds_ready();

    rc = fds_record_find(RGB_FILE_ID, RGB_REC_KEY, &desc, &tok);
    if (rc == FDS_SUCCESS){
        // RGB record found
        NRF_LOG_INFO("RGB record found");
        rgb_dummy_cfg.red = red;
        rgb_dummy_cfg.green = green;
        rgb_dummy_cfg.blue = blue;
        rc = fds_record_update(&desc, &rgb_dummy_record);
        APP_ERROR_CHECK(rc);
        if (rc == FDS_SUCCESS){
            NRF_LOG_INFO("RGB record updated: %X,%X,%X", rgb_dummy_cfg.red, rgb_dummy_cfg.green, rgb_dummy_cfg.blue);
            NRF_LOG_INFO("RGB record id: %d", desc.record_id);
        }
    }
    else{
        // System config not found; write a new one.
        NRF_LOG_INFO("Creating new RGB file...");
        rc = fds_record_write(&desc, &rgb_dummy_record);
        //NRF_LOG_INFO("FDS write error: %d", rc);
        APP_ERROR_CHECK(rc);
    }
}
 

Error message:

<info> app: Updating RGB Record...
<info> app: Creating new RGB file...
<error> app: Fatal error
<warning> app: System reset

Related