Nordic nrf52 Flash write with the SoftDevice

Framework: Arduino on nRF52
Platform: nordicnrf52

Hello,

has anyone figured out how to write into the nRF52832 Flash from the main application? There is a library Arduino NVM that does the great job, but sadly, it wont work when the SoftDevice is used, i.e. when any BLE functionality is wanted.

The official Nordic examples are recommending to use their fstorage and FDS functions, but I’ve been struggling for two weeks now to make it work in Arduino.

Try filing a bug there, maybe the developers can help you.

unfortunately, there is open issue in that repo that addresses this exact problem, and the author welcomes any help in that regard.

furthermore, the issue is from years go :frowning:

The adafruit core has the Adafruit_nRF52_Arduino/libraries/InternalFileSytem at master · adafruit/Adafruit_nRF52_Arduino · GitHub library for an internal filesystem, can’t you use that as a replacement for EEPROM? It uses LittleFS.

Also, when I copy the nrf_nvmc.c and nrf_nvmc.h files from the SDK (nRF5_SDK_17.0.2_d674dde from Nordic in my case, or see here), which implement the main non-volatile memory controller functions, there are no errors. So these functions should be directly usable.

I’m using board = adafruit_feather_nrf52832 for reference.

hello @maxgerhardt, thanks for the help!

The Adafruit solution probably works, but my issue is that I’m not using Adafruit nRF52 Arduino Framework, but the other one (Sandeepmistry nordicnrf52). And migrating to the Adafruit turned out to be a tremendous fail for me. My board is not compatible with Adafruit’s and it just refused to work.

Regarding the second part of your answer:
Writing into the Flash on nRF52 is possible with two backend functions: one that uses NVMC backend, like yours one here and my original one above, and the one that uses SoftDevice. These are not compatible, because the SoftDevice takes control over writing to Flash once you turn the BLE radio on. To make it happen, you use fstorage API with Softdevice backend.