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

I have a question with flash writing of nRF 52.

Once written, you can not write it for the second time. It will not cause an error, but is there any way?
Write the source code below.


NRF_FSTORAGE_DEF (nrf_fstorage_t fstorage) =
    {
        / * Set a handler for fstorage events. * /
        .evt_handler = fstorage_evt_handler,

        / * These below are the boundaries of the flash space assigned to this instance of fstorage.
     * You must set these manually, even at runtime, before nrf_fstorage_init () is called.
     * The function nrf5_flash_end_addr_get () can be used to retrieve the last address on the
     * last page of flash available to write data. * /
        .start_addr = 0x76000,
        .end_addr = 0x76 FFF,
};

#define GSM_APN_SETTING_SIZE 0x40
#define GSM_APN_SETTING_OFFSET 0x11

flash_update (gsm_apn_config, GSM_APN_SETTING_SIZE, GSM_APN_SETTING_OFFSET, true);
}

void flash_update (const uint8_t * p_dest, uint32_t size, uint32_t offset, bool isString)
{
    ret_code_t rc;

    rc = nrf_fstorage_write (& fstorage, fstorage.start_addr + offset, p_dest, size, NULL);
    APP_ERROR_CHECK (rc);
}

  • Hi, for all flash storage you can only write bits to '0', not '1'. This means that you can write to a flash page multiple times, however if you need to change any bits from '0' to '1', then you need to erase the entire flash page before writing updated data to the flash page, in such case you also need to temporary buffer other data in the flash page before writing them back.

Related