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

Write and read flash using sd_write_flash and sd_?

I want to use the SoftDevice APIs to read and write flash on the nRF51822. Are there any examples of how to do this. I see all kinds of mixes between pstorage, NVIC (not sure what that stands for) and the softdevice APIs. I did read that if SoftDevice is enabled one should use the SoftDevice APIs. I will be using soft device and lots of soft device BTLE APIs.

However, I don't see any examples of how to do this using JUST the soft device APIs. There isn't even a read method, just write, protect, and erase. Its probably somewhere in the documentation but the search engine is so bad you have to know exactly what you want and what it is called to get anywhere with it.

I want to save and restore pairing/bonding info in the same manner I do it on the PC using the pc-ble-driver. Therefore I do not want to use any of the SDK methods.

Parents Reply
  • It is what I want. In addition, I have to go between s110 v5/6, s130  and s140v6 on nfr51822 and nrf52840. The SDK for writing to flash has changed dramatically between these different versions, but sd_flash_write and sd_flash_page_erase have not. Since I am porting the same functionality across these different platforms (a basic health device) I am sticking to sd_* calls and not the SDK.

    However, I have come across a major problem in s110 v5/6 that sd_flash_write does not work. Actually it does work if I step through the code line by line in the debugger. It does not if I run through it 'normally' in the debugger or using no debugger. I have tried all combinations of 'tricks', checking for the busy and retrying, waiting on the flash event using the sd_ polling call. None work unless I step through line by line in the debugger. I am at a total loss.

    Admittedly when using the bond manager and the pstorage SDK APIs, it didn't work either. Since they are so complicated I did not try and debug it. But the result is easy to test, encryption on a bonded reconnect fails because the long term keys are not saved by the flash write.

Children
Related