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

Use nrf_fstorage_sd with nrf_sdh_ble_enable

Hi, I'm using SDK15.2.0 and A nRF52832 for my project.

I followed the "flash_fstorage" example give by Nordic, to write in the flash memory in my project. 

When I run my program the function nrf_fstorage_erase(&fstorage, address, 1, NULL); and nrf_fstorage_write(&fstorage, address, &data, sizeof(data), NULL); work perfectly but after I had called nrf_sdh_ble_enable(), the functions nrf_fstorage_erase() and nrf_fstorage_write() don't work anymore even if I don't use BLE.

The SVCALL is never called to write or erase the flash, I still stuck in nrf_fstorage_is_busy().

Do I need to change some priorities in sdk_config.h ?

Thanks, Automne

  • Hi Vidar,

    I tried to implant fstorage in my code as you did in your example, I got the same problem. The functions nrf_fstorage_write() and nrf_fstorage_erase() work perfectly when the softdevice stack is disable.
    When the softdevice is enable nrf_fstorage_write() and nrf_fstorage_erase() work only once and I never get out of the SVCALL. I didn't get the events NRF_FSTORAGE_EVT_WRITE_RESULT or NRF_FSTORAGE_EVT_ERASE_RESULT.

    I don't call this functions from an interrupt.

    Which resource use SVCALL(nrf_fstorage_write) and SVCALL(nrf_fstorage_erase) ?

    Thanks, Automne

  • Hi Automne,

    The SD flash API operates in blocking mode when the Softdevice is disabled (i.e., flash API does not return before a flash operation is complete), instead of being asynchronous where completion of a flash operation is reported through Softdevice SoC events. I think the problem may be that the fstorage module is not receiving the completion events from the Softdevice, and therefore unable to process following flash operations.

    Please verify that following source files are included in your build (are responsible for forwarding SD events to SDK modules):

    - nrf_sdh.c

    - nrf_sdh_ble.c

    - nrf_sdh_soc.c

    Also, what IDE/Toolchain are you using? The issue may be related to linker settings. 

  • Hi Vidar,

    Thanks for the quick answer.

    You have well identify my problem, "the fstorage module is not receiving the completion events from the Softdevice, and therefore unable to process following flash operations".

    I double check and the source files are well include. The prio level are 0 (NRF_SDH_BLE_STACK_OBSERVER_PRIO 0, NRF_SDH_SOC_STACK_OBSERVER_PRIO 0).

    I use an text editor, a MakeFile and I compile with ARM GCC 4.8.3

    I share you my linker, Dropbox download link : https://www.dropbox.com/s/jmsreqodc8h823u/linker.zip?dl=0

    Thanks, Automne

  • Hi Automne,

    The linker script appears to be ok, you have included the fs_data section. Did you use GCC 4.8.3 when you tested the example I provided? This is a pretty old version, and have not been tested or verified with SDK 15.2.0.

    Edit: is your makefile based on the ones we use in the SDK, or do you have a custom build system? e.g., building library files of the SDK modules, etc. 

  • Hi Vidar,

    Thanks for your help, yes I used GCC 4.8.3 with your code.

    Finally I found a work around, I don't use the SVCALL, I call the function directly :

    - sd_flash_page_erase(uint32_t page_number) 

    - sd_flash_write(uint32_t * p_dst, uint32_t const * p_src, uint32_t size)

    Now it's working for me Slight smile

    Automne

Related