Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Interrupt priority issues with fstorage and FreeRTOS

Hi,

I'm using an nRF52832 with SDK 14.2 and FreeRTOS. I'm hitting a configASSERT when I call nrf_fstorage_erase. I called the function after calling ble_stack_init but before calling nrf_sdh_freertos_init. 

I hit the asssert at SWI2_EGU2_IRQHandler (SD_EVT_IRQHandler, nrf_sdh_freertos.c, line 65) which called vTaskNotifyGiveFromISR (tasks.c, line 4309). From what I understood in the comment block in this function, the assert seems to be due to an issue with the interrupt priority. But I couldn't find an configs for the interrupt priority of fstorage.

Next, I tried calling the fstorage function from another task. This time, I didn't hit the assert, but there didn't seem to be any changes in the flash registers when I did a memory dump.

Can someone please help me get the root cause for this issue?

Also, I had read a post mentioning that FDS is not thread safe and this link also says that the backends are not thread safe. Is fstorage also not thread safe? 

Thanks,

Gowtham

Parents
  • Did you get the event complete event for fds after you do a page erase?

    If not there might be some priority issues with your task. 

  • I placed a breakpoint at the event handler and checked the results.

    1. When the flash erase is in main, the application hits the assert before receiving any events.

    2. When the flash erase is in a task, the event handler receives a NRF_FSTORAGE_EVT_ERASE_RESULT with result as 0 but without any of the flash writes occuring after the erase. I ran the application 2 more times, and i received a flash write success logs once. So it seems to be an issue with the priority as you mentioned.

    So, is there any method from which I can raise the priority of fstorage? And why does it still not work from the main function? Does nrf_sdh_freertos_init need to be called first for any fstorage APIs to work?

Reply
  • I placed a breakpoint at the event handler and checked the results.

    1. When the flash erase is in main, the application hits the assert before receiving any events.

    2. When the flash erase is in a task, the event handler receives a NRF_FSTORAGE_EVT_ERASE_RESULT with result as 0 but without any of the flash writes occuring after the erase. I ran the application 2 more times, and i received a flash write success logs once. So it seems to be an issue with the priority as you mentioned.

    So, is there any method from which I can raise the priority of fstorage? And why does it still not work from the main function? Does nrf_sdh_freertos_init need to be called first for any fstorage APIs to work?

Children
No Data
Related