FATAL ERROR using NVS for writing to flash while BLE is active

Hi All,

I'm updating some configuration parameters, which I store in flash using the NVS API, inside the callback that handles a characteristic write. So, flash writes occur while BLE is active.

Whenever I write to flash using nvd_write() a FATAL ERROR exception is raised.

I came across this recent post here, which provides a concise reasoning about causes, and suggests that Zephyr's NVS drivers are the recommended approach and state that: "Zephyr modules such as NVS will do the same when writing or erasing flash while BLE is enabled, but then through the APIs implemented in soc_flash_nrf.c". "The same" here presumably refers to "to use async APIs", to my best understanding.

But thing is I'm using the NVS APIs and that FATAL ERROR comes up every time I try to write to flash. If I do it before starting BLE it all works like a charm.

Questions are: How do I solve this situation, so I can store structured data in flash without requiring to bring BLE down, then write to flash, then bring it back up again?

NVS is very convenient and releases me from needing to implement a file-system or alike.l

BR,

Related