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

BLE stack re-initialize problem with FreeRTOS

How to correctly reinitialize the BLE stack when using FreeRTOS?


I can not find in the libraries where the task for the work of the stack under FreeRTOS is created.


Stopping the stack is successful, but here's a new initialization leads to a hardfall,

since FreeRTOS is running and the stack task most likely is not deleted when the stack is stopped.

For deinitialization I use the function - nrf_sdh_disable_request();

Problems with reinitialization have already been discussed in this thread - https://devzone.nordicsemi.com/support/214553

Parents
  • try this.

    remove heap_1.c and add heap_2.c file in your project. Since heap_1,c does not support deletion of heap memory needed to delete the task.

    add the below function in nrf_sdh_freertos.c

    void nrf_sdh_freertos_deinit()
    {
         // Use the handle to delete the task.
         if( m_softdevice_task != NULL )
         {
             vTaskDelete( m_softdevice_task );
         }
    }
    

    when you disable the softdevice delete the task along with disable

    nrf_sdh_disable_request();
    nrf_sdh_freertos_deinit();
    

    When you want to reenable the softdevice, then do the below

        err_code = nrf_sdh_enable_request();
        APP_ERROR_CHECK(err_code);
        
        nrf_sdh_freertos_init(advertising_start, &erase_bonds);

    Should work fine .

Reply
  • try this.

    remove heap_1.c and add heap_2.c file in your project. Since heap_1,c does not support deletion of heap memory needed to delete the task.

    add the below function in nrf_sdh_freertos.c

    void nrf_sdh_freertos_deinit()
    {
         // Use the handle to delete the task.
         if( m_softdevice_task != NULL )
         {
             vTaskDelete( m_softdevice_task );
         }
    }
    

    when you disable the softdevice delete the task along with disable

    nrf_sdh_disable_request();
    nrf_sdh_freertos_deinit();
    

    When you want to reenable the softdevice, then do the below

        err_code = nrf_sdh_enable_request();
        APP_ERROR_CHECK(err_code);
        
        nrf_sdh_freertos_init(advertising_start, &erase_bonds);

    Should work fine .

Children
Related