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

fds_evt_handler() not invoked for 52840, SDKv14.2, S140 ?

I'm running the code as shown in FDS Usage here:  http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.2.0/lib_fds_usage.html?cp=4_0_0_3_50_3

The FDS_EVT_INIT in fds_evt_handler() does not occur until I flash the application to the nRF52840 dev kit for the fourth time.  The first three times fails to have the event.  The fourth time and subsequent flashing of the application will have the event occur.

fds_register() and fds_init() do return success.

- Warren

  • Hi,

    I am guessing you are using the SoftDevice. It seems you have not registered a handler for SoftDevice events.

    This should be done automatically (in nrf_fstorage_sd.c that's done at the top of the file):

    /* Define a nrf_sdh_soc event observer to receive SoftDevice system events. */
    NRF_SDH_SOC_OBSERVER(m_sys_obs, 0, nrf_fstorage_sys_evt_handler, NULL);
    provided you have a few #defines set.


    Have you set NRF_FSTORAGE_ENABLED to 1 ?
    Have you set NRF_SDH_SOC_ENABLED to 1 ?

  • I do have NRF_FSTORAGE_ENABLED and NRF_SDH_SOC_ENABLED both set to 1.  And I have successfully registered an FDS event handler.

    I have figured out additional information about the problem I am seeing.  The event handler does not get called with the FDS_EVT_INIT event upon startup unless all FDS_VIRTUAL _PAGES get initialized with valid tag values of FDS_PAGE_TAG_SWAP or FDS_PAGE_TAG_DATA.

    I am now using a nRF52832 processor (PCA10040), SDK v14.2.0 and softdevice S132v5

    The sequence of events that causes the issue I see:

        - my application config has FDS_VIRTUAL_PAGES defined as 2

        - erase flash

        - load softdevice S132v5

        - load applicattion 

        - upon startup no FDS_EVT_INIT occurs, but the first FDS_VIRTUAL_PAGE (0x7e000) contains a FDS_PAGE_TAG_SWAP value.

        - reset.  no FDS_EVT_INIT occurs but the second FDS_VIRTUAL_PAGE (0x7f000) contains a FDS_PAGE_TAG_DATA value

        - reset.  The FDS_EVT_INIT now occurs  and will continue to occur on subsequent resets

    So the problem I am having is that successive reset operations after erasing the flash and loading softdevice and application appear to initialize only one FDS_VIRTUAL_PAGE at a time and the fds_evt_handler() will not happen until all tthe virtual pages are initialized with valid tags.

    If I build my application with FDS_VIRTUAL_PAGES defined as 3 instead of 2, then it will take 3 resets before the event handler will operate.

    Is there a problem with pages_init() in fds.c that appears to have a loop to initialize all FDS_VIRTUAL_PAGES??

    Warren

  • Your understanding of the problem is correct, the handler is not invoked so the initialization only performs one step every bootup. Could you provide a snippet of you main file?

  • Hello emdi,

    I have isolated and corrected my problem.  The nrf_sdh_soc.c file was not being included in my build.  Because of this SOC events were not happening.  It's a consequence of the compile-time OBSERVER inclusion that I was not getting any error or warning that this file was missing from my build.

    Thanks for your help.  This ticket can be closed.

    Warren

Related