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

Flash Data Storage (FDS), events go missing after Soft Device S140 Enabled

Been beating my head against this for a couple of days and came across a number of people on the forum with the same issue without a solution, so hopefully this saves someone else some pain.

It comes from taking the flash_fds example and merging it with other examples.  The symptoms are that FDS works fine for any writes, prior to enabling the soft device, and then afterwards, the FDS events don't occur, or occur late, sporadic or appear to never occur.

The problem originates in this pattern:

1. Set a volatile variable indicating event completion  in the FDS event handler

2. Issue FDS commands that write, delete, garbage collect etc., i.e. anything that's asynchronous and calls the event handler on completion

3. Loop whilst waiting for the volatile variable to be set/unset etc, calling sd_app_evt_wait or nrf_pwr_mgmt_run during the loop, or just a while(1);

The issue comes with the NRF_SDH_DISPATCH_MODEL setting, set to 1, which tells the the soft device to use the app_scheduler to execute the callback events in the main thread.

Solution is either to set NRF_SDH_DISPATCH_MODEL to "Interrupt" instead of "App Scheduler"

OR

In the above loop, add app_sched_execute(); to ensure the event handler is called.

A simple solution, but it's not entirely obvious, especially if you have an app_sched_execute in your "main", it can result in erratic behavior, where it works sometimes and not others.

Parents Reply Children
No Data
Related