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

Flash write with SDK 4.4.2 + S110 5.2.1

Hello everyone,

I have inherited a project from my coworker. It uses NRF51822 QFAAH0, SDK 4.4.2 and S110 5.2.1. My device is scheduled to: advertise, collect the data from a sensor.

Now I would like to store sensor data in flash then transfer them via BLE if there is a connection. As I have searched in this forum: fstorage, pstorage are preferred (to avoid conflicts between flash writing and BLE communcation). However, due to some reasons, I still have to use SDK 4.4.2 and S110 5.2.1 instead of other SDKs and Softdevices which support fstorage and pstorage functions.

My question is:

  1. In my case (SDK 4.4.2 and S110 5.2.1), how can I store data in flash?
  2. Could someone explain the use of flash_word/page_write function? I saw it is used in ble_bondmngr.c but I can't find and document about it. This may be a solution for me. If yes,
  3. Can I define a fixed area in my flash for storing data? BLE may use some spaces in flash for storing its own bonding and attribute information. And I don't want them to be stored in my data area.

Thank you for spending time.

Best regards.

Parents
  • You cannot use pstorage or fstorage, these are accessing flash through the SoftDevice, with functions like sd_flash_write() and sd_flash_page_erase(). These do not exist in SD 110 5.2.1.

    With SD 110 5.2.1 the application has to access Non-Volatile Memory Controller registers directly, which doesn't have to be a problem, but writing to flash will halt the CPU for a given period of time (depending on how much data you write). When it is finished, the flash is written, the CPU will return (just like a normal function call). BLE connections have strict timing, so if the CPU is halted when the stack requires the CPU it will cause problems. A flash page erase takes 22 ms.

    The simplest/safest way to do this is to not use the radio when you write/erase flash, so stop advertising, write/erase flash then start advertising again, and never write/erase flash while in a connection.

    You can use the Flash Manager library. You can find it's documentation in SDK documentation. Modules->nRF51822->Libraries->Bluetooth Libraries->Flash Manager. If you have specific questions regarding the library I think you should add a new question and explain more about what is unclear.

    You have to have control over which flash pages are used by SoftDevice, application, and bond manager, and which that are available. QFAAH0 has 256 flash pages, the SD 110 5.2.1 uses 0-79. You application is in 80-x, while the bond manager typically reserves 253-255. So you should be free to use any page between x and 253.

Reply Children
No Data
Related