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

NRF_BLE_FREERTOS_SDH_TASK_STACK not enough

Hello,

I have faced a lot of issues that were causing hardfault on my device. I'm using FreeRTOS with nrf52. I was suspecting stack overflow but it wasn't so easy to identify. When i have introduced the bonding, the issue occured more often and by exploring the stack and going back into the upper address i think i found out what it is. Indeed, i think the soft device stack size is not enough. It has been set to 256 bytes in nrf_sdh_freertos.c file (NRF_BLE_FREERTOS_SDH_TASK_STACK)

I have tested by setting it at 512 bytes and all issues disappeared.

Am i right ? Is someone else facing the same issue ?

Regards,

Aurélien

  • Yes, I had to do the same thing with my project.

    You can configure FreeRTOS to help catch stack overflows in your FreeRTOSConfig.h. For example, I use:

    #define configCHECK_FOR_STACK_OVERFLOW  ( DEBUG ? 2: 0 )
    

    You can also measure the stack high water mark. For example, in nrf_sdh_freertos.c's softdevice_task I have a snippet to measure:

    #if DEBUG
            UBaseType_t uxHighWaterMark;
            uxHighWaterMark = uxTaskGetStackHighWaterMark( m_softdevice_task );
            NRF_LOG_INFO("BLE HWM = %u", uxHighWaterMark);
    #endif
    
  • Hi,

    thank you very much for the reply. Since i have made the modification, my device has never been more stable than right now.

    Thank you for all tips you give for debug, it will help me for sure ;)

    Regards,

    Aurélien

Related