Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Flash write issue

Hello,

nRF52840, SDk16.0, Softdevice 7.0.1, 

I am having the following flash write error message while writing data to flash. I'm using FDS library. Interestingly this happens only on a particular hardware. There are other boards with same chipset and we used same code for over a year and they never gave such error. We fear that this issue may arise in product units as we are just about to launch the product.

Googling shows that I'm trying to write data into wrong memory area, but FDS lib doesn't allow you to choose memory addresses, there is file ID and file Key though mentioned at the end below.

Any idea what is happening.

Error message:

00> <info> app: Updating Script Record...
00> <info> app: Copied/dummy string
00> <info> app:  55 0A 00 00 01 58 1D 00|U....X..
00> <info> app:  00 02 26 2F 00 00 03 00|..&/....
00> <info> app:  01 05 00 63 FF E1 00 00|...c....
00> <info> app:  00 00 00 00 00 00 00 00|........
00> <info> app:  00 00 00 00 00 00 00 00|........
00> <info> app:  00 00 00 00 00 00 00 00|........
00> <info> app:  00 00 00 00 00 00 00 00|........
00> <info> app:  00 00 00 00 00 00 00 00|........
00> <info> app:  00 00 00 00 00 00 00 00|........
00> <info> app:  00 00 00 00 00 00 00 00|........
00> <info> app: Copied/dummy string len: 22
00> <info> app: Script record found
00> <error> nrf_fstorage: addr_is_within_bounds(p_fs, dest, len) check failed in nrf_fstorage_write() with value 0x10.

Code snippet where this happens:

void record_update_scr(char script[], int len){
    ret_code_t rc;
    fds_record_desc_t desc = {0};
    fds_find_token_t  tok  = {0};


    //script_total_length = len;

    NRF_LOG_INFO("Updating Script Record...");
//    NRF_LOG_INFO("Received string");
//    NRF_LOG_HEXDUMP_INFO(script, sizeof(scr_dummy_cfg.script));


    //script_id = script[len-1];
    //NRF_LOG_INFO("Script ID: %d", script_id);

    // copy data into scr_dummy_cfg
    //int len = sizeof(scr_dummy_cfg.script);
    int i=0;
    for (i=0; i<len; i++){
        scr_dummy_cfg.script[i] = script[i];
    }
    for (i=len; i<scr_dummy_record.data.length_words*4; i++){
        scr_dummy_cfg.script[i] = 0;
    }
    
    NRF_LOG_INFO("Copied/dummy string");
    NRF_LOG_HEXDUMP_INFO(scr_dummy_cfg.script, sizeof(scr_dummy_cfg.script));
    NRF_LOG_INFO("Copied/dummy string len: %d", len); //strlen(scr_dummy_cfg.script))
    //NRF_LOG_INFO("Record len: %d", scr_dummy_record.data.length_words);
    
    wait_for_fds_ready();

    rc = fds_record_find(SCR_FILE_ID, SCR_REC_KEY, &desc, &tok);
    if (rc == FDS_SUCCESS){
        // RGB record found
        NRF_LOG_INFO("Script record found");

        rc = fds_record_update(&desc, &scr_dummy_record);
        APP_ERROR_CHECK(rc);
        if (rc == FDS_SUCCESS){
            NRF_LOG_INFO("Script record updated");
            NRF_LOG_INFO("Script record id: %d", desc.record_id);
        }
    }
    else{
        // System config not found; write a new one.
        NRF_LOG_INFO("Creating new Script file...");

        rc = fds_record_write(&desc, &scr_dummy_record);
        APP_ERROR_CHECK(rc);
    }
}

#define SCR_FILE_ID     (0xF010)
#define SCR_REC_KEY     (0x7010)

Parents
  • Hi,

    Is the write/update completed successfully, or is there any errors reported from the FDS function call?

    Could be that the FDS area is full, preventing you from storing more data to flash. What values do you get if you call fds_stat()?

    Are you running garbage collection somewhere in your application?

    Can you provide a dump of the flash? You can do that using "nrfjprog --readcode flash.hex" command.

    Best regards,
    Jørgen

  • The error prompts in response to following commands:

    rc = fds_record_update(&desc, &scr_dummy_record);
    APP_ERROR_CHECK(rc);

    fds_stat() give:

    00> <info> app: Event: FDS_EVT_INIT received (FDS_SUCCESS)
    00> <info> app: Running garbage collector...
    00> <info> app: Event: FDS_EVT_GC received (FDS_SUCCESS)
    00> <info> app: Garbage collection complete
    00> <info> app: Reading flash usage statistics...
    00> <info> app: Found 5 valid records.
    00> <info> app: Found 0 dirty records (ready to be garbage collected).

    Garbage collection is done here in the pm_evt_handler in main.c:

    case PM_EVT_STORAGE_FULL:
            {
                // Run garbage collection on the flash.
                err_code = fds_gc();
                if (err_code == FDS_ERR_NO_SPACE_IN_QUEUES)
                {
                    // Retry.
                }
                else
                {
                    APP_ERROR_CHECK(err_code);
                }
            } break;

    Flash dump:

    3630.flash.hex

  • Looks like there should be plenty of space in the FDS area to store 22 bytes. Can you debug the application and check the content of the parameters passed to addr_is_within_bounds (dest, len), then you get the error?

Reply Children
No Data
Related