Persistence storage on nRF52, examples using littlefs?

Dear community,

I feel I've hit a road block when researching options for persistence storage, which uses the Flash to store values in a Nordic nRF52 based board (Adafruit Feather BLE).

First I researched Nordic's permanently preliminary fstorage solution, but was discouraged again by the consistently poor documentation and lack of code base typical for Nordic.

Further forays into the topics brought me to ARM's own Little File System, which looks like would nicely suit my needs (I basically want EEPROM emulation, to store some simple values like I used to do with AVR chips in EEPROM)

However when using the example

const struct lfs_config cfg = {
.read = user_provided_block_device_read,
.prog = user_provided_block_device_prog,
.erase = user_provided_block_device_erase,
.sync = user_provided_block_device_sync,

and exchanging user_provided_block_device_read with a function name, for instance

.read = lfs_file_read,

I get always the error message "sorry, unimplemented: non-trivial designated initializers not supported"

Can someone help me to understand how to make littlefs work in the Arduino world? Are there examples out there I can use?

One other think which also keeps bugging me is that although the Feather BLE memory map ( Introduction | Bluefruit nRF52 Feather Learning Guide | Adafruit Learning System ) says 28kB is allocated to littleFS, I do not find any kind of memory mapping in the code and I'm reluctant to bring the board by overwriting accidentally somethin vital... is there a safety mechanism protecting the bootloader from being overwritten by a file system?


My understanding is you need to provide those functions for littleFS to work. So, you need to define a function that reads a block, programs a block, erase a block and sync a block. I would think that there are some functions for working with the flash memory on the nRF52. You could probably just use those?


I managed to figure this out and get littlefs working with Arduino. Adafruit added littlefs to their nRF52 core library so if you have a recent version of that, you should have it built in.

Thanks a lot sslupsky, I've read your message on GitHub too.
For completeness'sake here is the link you provided:

I will give it a try and report back about how it went.