espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.7k stars 7.3k forks source link

Panic on BT/WiFi deinit (IDFGH-4131) #5998

Open fpgamaster opened 4 years ago

fpgamaster commented 4 years ago

Problem Description

A panic produced by the following code after some times returning from deep sleep: // Deinit BLUFI esp_myg_blufi_profile_deinit();

    // Disable BT and WiFi
    esp_bluedroid_disable();
    esp_bluedroid_deinit();
    esp_bt_controller_disable();
    esp_bt_controller_deinit();
    esp_wifi_stop();
    esp_wifi_deinit();

//Detailed problem description goes here. The above code is executed right before entering in deep sleep.

I (7523) BLUFI: BLUFI Event callback 1



I (7523) BLUFI: BLUFI deinit finish



W (7543) BT_APPL: bta_dm_disable BTA_DISABLE_DELAY set to 200 ms

I (7543) GATTC: GATTC Event handler idx 0, event 1

I (7543) GATTC: DEFAULT_EVT

I (7553) GATTC: GATTC Event handler idx 1, event 1

I (7553) GATTC: DEFAULT_EVT

I (7563) GATTC: GATTC Event handler idx 2, event 1

I (7563) GATTC: DEFAULT_EVT

E (7753) BT_OSI: alarm_free null



CORRUPT HEAP: multi_heap.c:540 detected at 0x3ffbaa74

abort() was called at PC 0x40094b9b on core 0

0x40094b9b: multi_heap_assert at /home/xxxx/esp/esp-idf/components/heap/multi_heap_platform.h:68 

Backtrace:0x40090222:0x3fff5d00 0x40090885:0x3fff5d20 0x40096076:0x3fff5d40 0x40094b9b:0x3fff5db0 0x40094fa4:0x3fff5dd0 0x400856b1:0x3fff5df0 0x400960a1:0x3fff5e10 0x4014708a:0x3fff5e30 0x4014797a:0x3fff5e50 0x401479cb:0x3fff5e70 0x40147225:0x3fff5e90 0x40137a41:0x3fff5eb0 0x40163db6:0x3fff5ed0 0x40163e04:0x3fff5ef0 0x40137735:0x3fff5f60 0x401376ed:0x3fff5f80 0x40137843:0x3fff5fa0 0x40148047:0x3fff5fc0

0x40090222: panic_abort at /home/xxxx/esp/esp-idf/components/esp_system/panic.c:361  0x40090885: esp_system_abort at /home/xxxx/esp/esp-idf/components/esp_system/system_api.c:106  0x40096076: abort at /home/xxxx/esp/esp-idf/components/newlib/abort.c:46  0x40094b9b: multi_heap_assert at /home/xxxx/esp/esp-idf/components/heap/multi_heap_platform.h:68  0x40094fa4: multi_heap_free_impl at /home/xxxx/esp/esp-idf/components/heap/multi_heap.c:540  0x400856b1: heap_caps_free at /home/xxxx/esp/esp-idf/components/heap/heap_caps.c:305  0x400960a1: free at /home/xxxx/esp/esp-idf/components/newlib/heap.c:47  0x4014708a: bucketfree at /home/xxxx/esp/esp-idf/components/bt/common/osi/hash_map.c:244  0x4014797a: list_free_node at /home/xxxx/esp/esp-idf/components/bt/common/osi/list.c:262  0x401479cb: list_remove at /home/xxxx/esp/esp-idf/components/bt/common/osi/list.c:184  0x40147225: hash_map_erase at /home/xxxx/esp/esp-idf/components/bt/common/osi/hash_map.c:175  0x40137a41: bta_sys_free_timer at /home/xxxx/esp/esp-idf/components/bt/host/bluedroid/bta/sys/bta_sys_main.c:681  0x40163db6: bta_dm_deinit_cb at /home/xxxx/esp/esp-idf/components/bt/host/bluedroid/bta/dm/bta_dm_act.c:325  0x40163e04: bta_dm_sys_hw_cback at /home/xxxx/esp/esp-idf/components/bt/host/bluedroid/bta/dm/bta_dm_act.c:430  0x40137735: bta_sys_hw_evt_disabled at /home/xxxx/esp/esp-idf/components/bt/host/bluedroid/bta/sys/bta_sys_main.c:443  0x401376ed: bta_sys_sm_execute at /home/xxxx/esp/esp-idf/components/bt/host/bluedroid/bta/sys/bta_sys_main.c:228  0x40137843: bta_sys_event at /home/xxxx/esp/esp-idf/components/bt/host/bluedroid/bta/sys/bta_sys_main.c:499  0x40148047: osi_thread_run at /home/xxxx/esp/esp-idf/components/bt/common/osi/thread.c:68 

ELF file SHA256: 4725f1642b69c378

Rebooting...

xiewenxiang commented 4 years ago

It is recommended to stop scanning, stop broadcasting, and disconnect before deinit stack.

fpgamaster commented 4 years ago

Hi @xiewenxiang ,

I hope the code I use will do this: esp_myg_blufi_profile_deinit(); esp_bluedroid_disable(); esp_bluedroid_deinit(); esp_bt_controller_disable(); esp_bt_controller_deinit(); esp_wifi_stop(); esp_wifi_deinit();

cyberman54 commented 3 years ago

@fpgamaster try a esp_ble_gap_stop_scanning() before esp_bluedroid_deinit()