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

FDS - How can I write binary data to flash while receiving via BLE

Hi community,

for our application (nrf52832 / SDK 12.2) we need to store data received via BLE. The received data is a 25 kB binary blob which by design will be chopped in 20 B chunks to be sent and received via BLE.

Now my question is if somehow it is possible to store these chunks using the fds library as one record? My current understanding of the fds library is that I need to store each received chunk as new record. Ideally I need a pointer to the whole 25kB blob for further processing.

How would you solve it?

  • The easiest way and likely fastest/safest way, is to allocate a 25k buffer in RAM and after you have all the data, just let the FDS churn through all of it at once.

  • This was my first thought too Andrew. But since I'm running a freertos based system with a micropython stack I'm afraid of getting in trouble doing it this way. Nevertheless I need to analyze the memory of the system if its possible theoretically.

  • On further inspection of the documentation, nodic says the following: "To store larger data, increase the virtual page size or use the Experimental: Flash Storage module instead of FDS."

    I think your application falls into this description. You just have to decide how risk adverse you are to using experimental modules.

  • fds is more like a library to manage a collection of relatively small pieces of data, i.e. records. I don't believe it might be feasible to use a 25k RAM buffer and write it all at once in fds, in order to do that you'd have to use a virtual page of at least 28k in size and fds would need two of such pages, one for data and one to use as swap.

    I would stick to fstorage for this, it has a simple API and is much more suited for your requirements. There is an example in SDK 14.1 under examples/peripheral/flash_fstorage.

    Regards, emdi