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

FStorage event handler interrupts not forwarded by soft device in bootloader

I've developed a little test application on a nrf52832 chip to run fstorage in a bootloader memory address. I followed the nordic guidance to set up, build, and install a bootloader application which launches off the MBR. It has soft device working correctly, as i use other soft device interrupt functionalities like app timers for a service loop and Uart printouts.

Whats bothering me is the fstorage isnt working in it. My sample app waits 3 seconds, then attempts to erase a section of memory in flash (30 ish pages). it never completes, as the interrupt never fires from the soft device (i think). The first page is erased successfully, but no other pages. I've done the same test application in a firmware memory space (0x19000 and up) and it works perfectly. 

Can someone tell me what I've done wrong? I feel like I followed the nordic recommended examples and I cant get this feature functional. I feel like i have to be doing something really dumb. 

Bootloader Test App.zip 

  • Hi,

    I assume you are using the nrf_fstorage_sd backend and not the nrf_fstorage_nvmc? Assuming so, this is event based, and the fstorage event handler is nrf_fstorage_sys_evt_handler(), which is registered by the NRF_SDH_SOC_OBSERVER macro in nrf_fstorage_sd.c. This makes the SoftDevice handler forward events to fstorage. Do you get any events in the event handler (checked with a breakpoint or similar)?

    I did not get a chance to look closely at your code today, but could it be a problem of interrupt priorities or similar? Do you wait for a fstorage event (or something completely different) in a interrupt priority, so that the thing you are waiting for doesn't get CPU time to run, making a deadlock?

  • Hi Einar, 

    Yes, I am using the nrf_fstorage_sd backend. I have been watching with breakpoints in the nrf_fstorage_sys_evt_handler() and never receive any events. My debugging process was first watching for the erase to execute in queue_process() in the nrf_fstorage_sd.c file. I confirmed this happened, but I never get a breakpoint hit in the event handler. Nor do I get a breakpoint on the event handler function call, located in the queue_process() switch statement.

    One thing I noticed is the nrf_fstorage_sys_evt_handler() call in queue_process() is only triggered when the soft device is enabled, which makes sense. I assume this backend cant operate without that being enabled? Is it possible to get to the nrf_fstorage_sys_evt_handler() call in queue_process() without the soft device being initially enabled? Could that be an issue (some kind of race condition?).

    And regarding the waiting for interrupt, I dont block while waiting for the operation to complete, I come back and poll it on a tick based approach, which lets other operations occur. Is that what you are asking?

  • Hi,

    rsoc16 said:
    Is it possible to get to the nrf_fstorage_sys_evt_handler() call in queue_process() without the soft device being initially enabled?

    No, the SD backen cannot work without the SoftDevice being enabled. But you should have seen an error if this was the problem (unless you ignore return values). The SoftDevice must be enabled before you make any calls to the SoftDevice API (directly or indirectly).

    rsoc16 said:
    And regarding the waiting for interrupt, I dont block while waiting for the operation to complete, I come back and poll it on a tick based approach, which lets other operations occur. Is that what you are asking?

    Yes, that was what I was asking about. That should not be the problem, then.

Related