Hi,
I'm developing firmware for nRF52840 device (Acconeer XM122), and I'm trying to use fstorage library to write some data to flash.
SDK version 15.3.0, Segger Embedded Studio (v5.20a).
I'm stuck on trying to erase a page, getting the following error:
<error> nrf_fstorage: addr_is_within_bounds(p_fs, page_addr, (len * p_fs->p_flash_info->erase_unit)) check failed in nrf_fstorage_erase() with value 0x10. <error> app: ERROR 16 [NRF_ERROR_INVALID_ADDR] at C:\SDKs\nRF5_SDK_15.3.0_59ac345\_project\_project\acconeer_beacon_tank_level\source\fstorage_ctrl.c:124 PC at: 0x00035D75 <error> app: End of error report
I found what the problem is, but I can't fix it.
It seems like after calling the NRF_FSTORAGE_DEF() macro as following:NRF_FSTORAGE_DEF(nrf_fstorage_t fstorage) =
{
/* Set a handler for fstorage events. */
.evt_handler = fstorage_evt_handler,
.start_addr = 0x60000,
.end_addr = 0x61FFF,
};
I end up with wrong start and end address inside (nrf_fstorage_t)fstorage, and I verified that's the case by placing a breakpoint and watching this structure and by printing the addresses: <info> app: ========| flash info |========
<info> app: erase unit: 4096 bytes
<info> app: program unit: 4 bytes
<info> app: Flash start: ABD7AEAA
<info> app: Flash end: 10204115
<info> app: ==============================
Edit:
This is what the init function looks like:
void fstorage_module_init(void)
{
nrf_fstorage_api_t * p_fs_api;
p_fs_api = &nrf_fstorage_sd;
ret_code_t err_code = nrf_fstorage_init(&fstorage, p_fs_api, NULL);
APP_ERROR_CHECK(err_code);
}
And this is how I call the erase function:
err_code = nrf_fstorage_erase(&fstorage, 0x60000, 1, NULL);
APP_ERROR_CHECK(err_code);
Any help is appreciated!
Thanks
Emir
