From d24f7d9f12a06726a8bbbe71d0272cd6900b5057 Mon Sep 17 00:00:00 2001 From: luomanruo Date: Fri, 17 Nov 2023 20:35:12 +0800 Subject: [PATCH] ble(fix): deinit crash issue --- components/bt/controller/esp32c2/bt.c | 7 ++++--- components/bt/controller/esp32c6/bt.c | 9 +++++---- components/bt/controller/esp32h2/bt.c | 9 +++++---- components/bt/controller/lib_esp32c6/esp32c6-bt-lib | 2 +- components/bt/controller/lib_esp32h2/esp32h2-bt-lib | 2 +- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/components/bt/controller/esp32c2/bt.c b/components/bt/controller/esp32c2/bt.c index 52d9c15d84..822cc70323 100644 --- a/components/bt/controller/esp32c2/bt.c +++ b/components/bt/controller/esp32c2/bt.c @@ -667,7 +667,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) #endif // CONFIG_BT_CONTROLLER_LOG_DUMP if (ret != ESP_OK) { ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_log_init failed %d", ret); - goto modem_deint; + goto controller_init_err; } #endif // CONFIG_BT_CONTROLLER_LOG_ENABLED @@ -691,11 +691,12 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) return ESP_OK; free_controller: controller_sleep_deinit(); -modem_deint: #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED +controller_init_err: ble_log_deinit_async(); #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED ble_controller_deinit(); +modem_deint: esp_phy_modem_deinit(); periph_module_disable(PERIPH_BT_MODULE); #if CONFIG_BT_NIMBLE_ENABLED @@ -719,10 +720,10 @@ esp_err_t esp_bt_controller_deinit(void) controller_sleep_deinit(); - ble_controller_deinit(); #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED ble_log_deinit_async(); #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED + ble_controller_deinit(); periph_module_disable(PERIPH_BT_MODULE); diff --git a/components/bt/controller/esp32c6/bt.c b/components/bt/controller/esp32c6/bt.c index 7e9afe236e..716337982f 100644 --- a/components/bt/controller/esp32c6/bt.c +++ b/components/bt/controller/esp32c6/bt.c @@ -794,7 +794,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) #endif // CONFIG_BT_CONTROLLER_LOG_DUMP if (ret != ESP_OK) { ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_log_init failed %d", ret); - goto modem_deint; + goto controller_init_err; } #endif // CONFIG_BT_CONTROLLER_LOG_ENABLED @@ -825,12 +825,13 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) free_controller: controller_sleep_deinit(); - os_msys_deinit(); -modem_deint: #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED +controller_init_err: ble_log_deinit_async(); #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED + os_msys_deinit(); ble_controller_deinit(); +modem_deint: esp_phy_modem_deinit(); modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE); modem_clock_module_disable(PERIPH_BT_MODULE); @@ -861,10 +862,10 @@ esp_err_t esp_bt_controller_deinit(void) modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE); modem_clock_module_disable(PERIPH_BT_MODULE); - ble_controller_deinit(); #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED ble_log_deinit_async(); #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED + ble_controller_deinit(); #if CONFIG_BT_NIMBLE_ENABLED /* De-initialize default event queue */ diff --git a/components/bt/controller/esp32h2/bt.c b/components/bt/controller/esp32h2/bt.c index 86e3e989e1..d5b0c4bc1a 100644 --- a/components/bt/controller/esp32h2/bt.c +++ b/components/bt/controller/esp32h2/bt.c @@ -774,7 +774,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) #endif // CONFIG_BT_CONTROLLER_LOG_DUMP if (ret != ESP_OK) { ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_log_init failed %d", ret); - goto modem_deint; + goto controller_init_err; } #endif // CONFIG_BT_CONTROLLER_LOG_ENABLED @@ -806,12 +806,13 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) free_controller: controller_sleep_deinit(); - os_msys_deinit(); -modem_deint: #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED +controller_init_err: ble_log_deinit_async(); #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED + os_msys_deinit(); ble_controller_deinit(); +modem_deint: modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE); modem_clock_module_disable(PERIPH_BT_MODULE); #if CONFIG_BT_NIMBLE_ENABLED @@ -840,10 +841,10 @@ esp_err_t esp_bt_controller_deinit(void) modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE); modem_clock_module_disable(PERIPH_BT_MODULE); - ble_controller_deinit(); #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED ble_log_deinit_async(); #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED + ble_controller_deinit(); #if CONFIG_BT_NIMBLE_ENABLED /* De-initialize default event queue */ diff --git a/components/bt/controller/lib_esp32c6/esp32c6-bt-lib b/components/bt/controller/lib_esp32c6/esp32c6-bt-lib index 932edd189e..e70c4abbd5 160000 --- a/components/bt/controller/lib_esp32c6/esp32c6-bt-lib +++ b/components/bt/controller/lib_esp32c6/esp32c6-bt-lib @@ -1 +1 @@ -Subproject commit 932edd189ed4a39de19fb0e0dfc08b26b8785731 +Subproject commit e70c4abbd5666afac3b7b3cea1c3d9c59ee33ce9 diff --git a/components/bt/controller/lib_esp32h2/esp32h2-bt-lib b/components/bt/controller/lib_esp32h2/esp32h2-bt-lib index 11aa66e7f3..66303b4a8c 160000 --- a/components/bt/controller/lib_esp32h2/esp32h2-bt-lib +++ b/components/bt/controller/lib_esp32h2/esp32h2-bt-lib @@ -1 +1 @@ -Subproject commit 11aa66e7f39c9402039882acb14a993e390f8893 +Subproject commit 66303b4a8cc8e889a0c9bdd7301582ba2cb8b0eb