fstorage erase is not working

Hi,

I am using fstorage functions in the ANT broadcast RX project.

I am doing the fstorage write function when the ANT device is connected (Inside RX EVENT of ANT event handler, only one write) and I am calling erase function during any button interrupt.

But I am having one problem:

Erase function is not happening if any write function has happened before.

If I reset the device and try only erase function, then it's happening.

And I am not getting any fstorage events.

Please provide us the solution for this issue.

Regards,

Aslam

  • Hi Susheel,

    "Have you declared NRF_FSTORAGE_DEF in your application?"

    Yes, I have declared NRF_FSTORAGE_DEF in my application.

    And I have observed that Writing to flash before soft device initialization results in successful flash writes and flash events being triggered.

    However, writing to flash after soft device initialization does not result in flash writes and flash events are not triggered. I have checked in debug mode, the program seems to be stuck on the line where nrf_fstorage_is_busy function is called.

    Regards,

    Aslam

  • it almost sounds like you are not using the nrf_fstorage_sd as your backend for fstorage.

    When softdevice is enabled, all flash activity needs to go through the softdevice flash API which is hidden in the abstraction of the backend in nrf_fstorage_sd.c  Please look at the example nRF5_SDK_17.1.0_ddde560\examples\peripheral\flash_fstorage\main.c.

    If you have used the proper backend and included the nrf_fstorage_sd.c, I do not see how this could be a problem. Can you attach your project here so that I can give a quick smoke test on the DK on my desk?

  • Hi Susheel,

    I have been utilizing nrf_fstorage_sd for flash storage operations.

    I have attached my project. Please check it on your end and provide us solution.

    And use the ANT S212 Soft device hex file with this project.

    ant_devzone_prj.zip

    Regards,

    Aslam

  • I can replicate the issue now. I will try to provide you a workaround soon.

    Thanks for your patience and the attaching the project.

  • The issue is that fstorage only works with SOC events and not with ANT events. So when we have added nrf_fstorage_sd.c we have NRF_SDH_SOC_OBSERVER properly defined but this seems to be optimized away when you are using only nrf_sdh_ant.c.

    The solution is add nrf_sdh_soc.c also along with nrf_sdh_ant.c  in your project like this

    and all the below line in flash_placement.xml file

    	<ProgramSection alignment="4" keep="Yes" load="Yes" name=".sdh_soc_observers" inputsections="*(SORT(.sdh_soc_observers*))" address_symbol="__start_sdh_soc_observers" end_symbol="__stop_sdh_soc_observers" />

    After that, I can compile the code and get fstorage events correctly.

    <info> app_timer: RTC: initialized.
    <info> app: --> Event received: erased 1 page from address 0x2C000.
    <info> app: --> Event received: wrote 4 bytes at address 0x2C000.
    <info> app: DUMMY READ : 69C5
    <info> app: device id read from the flash : 27077
    <info> app: ANT SLAVE LEV started.
    

Related