Hi!
I know, that there are some similar issues in this forum, and I checked them,
but I didn't see the clue.
I try to use fstorage to write something to flash. I have a running softdevice,
so i use the fstorage_sd backend. I looked at examples/peripheral/flash_storage
and copied some code:
nrf_fstorage_api_t * p_fs_api; static void fstorage_evt_handler(nrf_fstorage_evt_t * p_evt); NRF_FSTORAGE_DEF(nrf_fstorage_t fstorage) = { .evt_handler = fstorage_evt_handler, .start_addr = 0x26000, .end_addr = 0x27fff, }; static void fstorage_evt_handler(nrf_fstorage_evt_t * p_evt) { if (p_evt->result != NRF_SUCCESS) { return; } switch (p_evt->id){ case NRF_FSTORAGE_EVT_WRITE_RESULT: is_written=true; break; case NRF_FSTORAGE_EVT_ERASE_RESULT: is_erased=true; break; default: break; } } void wait_for_flash_ready(nrf_fstorage_t const * p_fstorage) { /* While fstorage is busy, sleep and wait for an event. */ while (nrf_fstorage_is_busy(p_fstorage)) { (void) sd_app_evt_wait(); } }
In my init function, I copied the call from example:
p_fs_api = &nrf_fstorage_sd; uint32_t retcode=nrf_fstorage_init(&fstorage, p_fs_api, NULL);
return of nrf_fstorage_init is NRF_SUCCESS.
when it comes to write, i call (similar to example)
is_written=false; uint32_t retcode = nrf_fstorage_write(&fstorage, write_addr, data, 16, NULL); wait_for_flash_ready(&fstorage);
where write_addr is 0x26000 and data is an uint8_t[16].
retcode is NRF_SUCCESS.
But then the problem starts: wait_for_flash_ready() blocks infinitly (until watchdog
bites after 10 s) and the fstorage_evt_handler is not called.
Looking by debugger into flash, the data is written.
If I do not wait_for_flash_ready(&fstorage), the fstorage_evt_handler is called.
If I replace the wait_for_flash_ready by nrf_delay_ms(100), the fstorage_evt_handler
is called after delay is done.
So I guess it has something to do with priorities. But which priorities and where
can I configure them?
I use SD112 and SDK15.3, running on PCA10040