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

wait_for_queue() hangs on re-init of DFU service

I have an app that requires BLE stack to be re-initialized, however it seems that if you run

ble_dfu_init();

more than once, it crashes

Upon further inspection is seems the source the of crash is here:

nrf_dfu_settings_init();

Drilling down, I discovered it seems to be hanging on:

wait_for_queue();

I'm using nRF5_SDK_12.2.0

I can prevent it hanging by increasing this constant:

FS_QUEUE_SIZE

However, it no longer advertises correctly because of:

// Delay starting advertising until the flash operations are complete.
if (flash_access_in_progress())
{
    m_advertising_start_pending = true;
    return NRF_SUCCESS;
}
Parents
  • The problem is mainly due to the inability to re-init the flash whilst you have pending flash operations (from peer manager and DFU init). They need to be handled before attempting a re-init. Also if you are using freertos you need to modify:

    app_timer_create()
    

    Here is the fix that seems to be working for me:

    static uint8_t is_flash_busy(void) {
    
    uint32_t count;
    
    fs_queued_op_count_get(&count);
    
    return (count!=0);}
    
    static void pre_ble_reinit(void) {
    
    while(is_flash_busy())
     {
        while (pdFALSE == xSemaphoreTake(m_ble_event_ready, portMAX_DELAY));
    
        intern_softdevice_events_execute();
     }}
    
Reply
  • The problem is mainly due to the inability to re-init the flash whilst you have pending flash operations (from peer manager and DFU init). They need to be handled before attempting a re-init. Also if you are using freertos you need to modify:

    app_timer_create()
    

    Here is the fix that seems to be working for me:

    static uint8_t is_flash_busy(void) {
    
    uint32_t count;
    
    fs_queued_op_count_get(&count);
    
    return (count!=0);}
    
    static void pre_ble_reinit(void) {
    
    while(is_flash_busy())
     {
        while (pdFALSE == xSemaphoreTake(m_ble_event_ready, portMAX_DELAY));
    
        intern_softdevice_events_execute();
     }}
    
Children
No Data
Related