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

FDS Sample Code

Hi,

I am trying to use the FDS for saving some variables and displaying them again later. I have downloaded the NRF52-fds-master sample code posted on github. However, this uses the peer manager and I don't want to include that in my final code. I copied out all of the methods for init, reading and writing and set the sys_evt_dispatch to use the fs_sys_event_handler. When I compile this code the event handler never triggers on the end of a write operation. I have gone through the code in the SDK documentation but it is all equivalent to the things that I copied from the sample code. I am trying to use UART and the nus ble profile to trigger read and write methods.

Does the FDS only work with the peer manager? Or is there a sample that just uses FDS without the peer manager?

Thanks for the help

  • The radio has higher priority and may prevent flash operation. Have you tried getting it to work with simple static data? If you are trying to trigger flash operation when the radio is working in relation to the BLE UART that could be problematic.

  • I test call the methods for reading and writing after initializing the ble components (ble stack, gap params, services etc) but before calling the advertising start method. This is how it is done in the sample code. I am assuming that the radio isn't active until I start advertising.

  • Of course FDS works without the peer manager and it works with the softdevice and the uart drivers and everything else, it's simply another wrapper around the flash writing event system, well actually fstorage is another wrapper around the flash writing event system and fds is just built on top of that.

    Basically sounds like you're on the right path, so bang some debugging in there and see what's going on. Is your sys_evt_dispatch() getting called with flash storage events and do the events you're getting make sense, ie is the write actually happening, but you're just not getting the callback? Is the underlying fstorage subsystem getting initialized properly and your client properly registered to it?

    Or post some code, it's impossible to debug observations. You're probably just missing one small thing, the FS and FDS work pretty well, much better than the old pstorage module.

  • Ok, one other thing to check is you are initialising correctly, I see a comment in the SDK "In the Peer Manager, fds_init is part of the initialization function pm_init." Presumably you have already accounted for that?

  • Yes, I had read through the initialising and had the pm_init in the main function. I solved the issue. The sample code initialised the peer manager and then called a test init later. This means the system initialises the fds module twice and the first time is early during the start up. In my code I had my test method calls right after the initialisation and didn't wait for the event handler to return that it had been initialised. I added a delay flag to wait for the response and now it works. Thanks for the help!

Related