From 977b7f4bdb57c6ceee6d40087e816a38065b41ac Mon Sep 17 00:00:00 2001 From: luomanruo Date: Mon, 6 Nov 2023 10:56:50 +0800 Subject: [PATCH 1/5] ble(fix): Fixed the issue of not returning memory to the memory pool after deinit callout ble(fix): Fixed the issue of not returning memory to the memory pool after deinit callout --- components/bt/controller/esp32c2/bt.c | 2 +- components/bt/controller/lib_esp32c2/esp32c2-bt-lib | 2 +- components/bt/porting/npl/freertos/src/npl_os_freertos.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/bt/controller/esp32c2/bt.c b/components/bt/controller/esp32c2/bt.c index 667e7049c3..20dd402669 100644 --- a/components/bt/controller/esp32c2/bt.c +++ b/components/bt/controller/esp32c2/bt.c @@ -721,10 +721,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/lib_esp32c2/esp32c2-bt-lib b/components/bt/controller/lib_esp32c2/esp32c2-bt-lib index ea33fbad1f..11c11f187f 160000 --- a/components/bt/controller/lib_esp32c2/esp32c2-bt-lib +++ b/components/bt/controller/lib_esp32c2/esp32c2-bt-lib @@ -1 +1 @@ -Subproject commit ea33fbad1fa0879fe0e118359d20463b3e2f126b +Subproject commit 11c11f187fc349df8494305c7b308b4d7783d762 diff --git a/components/bt/porting/npl/freertos/src/npl_os_freertos.c b/components/bt/porting/npl/freertos/src/npl_os_freertos.c index 930889dd35..f93b1fc18c 100644 --- a/components/bt/porting/npl/freertos/src/npl_os_freertos.c +++ b/components/bt/porting/npl/freertos/src/npl_os_freertos.c @@ -720,12 +720,12 @@ npl_freertos_callout_deinit(struct ble_npl_callout *co) } #else xTimerDelete(callout->handle, portMAX_DELAY); +#endif // BLE_NPL_USE_ESP_TIMER #if OS_MEM_ALLOC os_memblock_put(&ble_freertos_co_pool,callout); #else free((void *)callout); #endif // OS_MEM_ALLOC -#endif // BLE_NPL_USE_ESP_TIMER co->co = NULL; memset(co, 0, sizeof(struct ble_npl_callout)); } From 30cd76b0f0d136ca09b87da7aeefec09e5af7ae1 Mon Sep 17 00:00:00 2001 From: luomanruo Date: Fri, 17 Nov 2023 16:48:58 +0800 Subject: [PATCH 2/5] ble: update c2 lib to db4e1fb2 --- components/bt/controller/lib_esp32c2/esp32c2-bt-lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bt/controller/lib_esp32c2/esp32c2-bt-lib b/components/bt/controller/lib_esp32c2/esp32c2-bt-lib index 11c11f187f..1e8bbd6f1a 160000 --- a/components/bt/controller/lib_esp32c2/esp32c2-bt-lib +++ b/components/bt/controller/lib_esp32c2/esp32c2-bt-lib @@ -1 +1 @@ -Subproject commit 11c11f187fc349df8494305c7b308b4d7783d762 +Subproject commit 1e8bbd6f1af71b90a2e8130e77ed49dc799031fe From 1c261213d7ea1fd3d40c7969bf2c5eb8e275b79b Mon Sep 17 00:00:00 2001 From: luomanruo Date: Fri, 17 Nov 2023 11:13:50 +0800 Subject: [PATCH 3/5] ble: update controller log module --- components/bt/controller/esp32c2/bt.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/components/bt/controller/esp32c2/bt.c b/components/bt/controller/esp32c2/bt.c index 20dd402669..a0af304fc3 100644 --- a/components/bt/controller/esp32c2/bt.c +++ b/components/bt/controller/esp32c2/bt.c @@ -646,6 +646,12 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) coex_init(); #endif + ret = ble_controller_init(cfg); + if (ret != ESP_OK) { + ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_init failed %d", ret); + goto modem_deint; + } + #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED interface_func_t bt_controller_log_interface; bt_controller_log_interface = esp_bt_controller_log_interface; @@ -667,12 +673,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) } #endif // CONFIG_BT_CONTROLLER_LOG_ENABLED - ret = ble_controller_init(cfg); - if (ret != ESP_OK) { - ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_init failed %d", ret); - goto modem_deint; - } - ret = controller_sleep_init(); if (ret != ESP_OK) { ESP_LOGW(NIMBLE_PORT_LOG_TAG, "controller_sleep_init failed %d", ret); @@ -693,11 +693,11 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) return ESP_OK; free_controller: controller_sleep_deinit(); - ble_controller_deinit(); modem_deint: #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED ble_log_deinit_async(); #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED + ble_controller_deinit(); esp_phy_modem_deinit(); periph_module_disable(PERIPH_BT_MODULE); #if CONFIG_BT_NIMBLE_ENABLED From 08e4757764858ca587fc207f4499363beeb3c055 Mon Sep 17 00:00:00 2001 From: zwl Date: Fri, 17 Nov 2023 17:30:57 +0800 Subject: [PATCH 4/5] fix(ble): fixed ble occasional rx exception issue --- components/esp_phy/src/phy_init.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/esp_phy/src/phy_init.c b/components/esp_phy/src/phy_init.c index 2586438603..9b9eb35554 100644 --- a/components/esp_phy/src/phy_init.c +++ b/components/esp_phy/src/phy_init.c @@ -699,7 +699,11 @@ void esp_phy_load_cal_and_init(void) // Set PHY whether in combo module // For comode mode, phy enable will be not in WiFi RX state #if SOC_PHY_COMBO_MODULE +#if CONFIG_IDF_TARGET_ESP32C2 + phy_init_param_set(1); +#else phy_init_param_set(0); +#endif #endif esp_phy_calibration_data_t* cal_data = From 1c0fb3bb4a588525cab7f6b178c7f1810ce6fe8f Mon Sep 17 00:00:00 2001 From: luomanruo Date: Fri, 17 Nov 2023 20:40:12 +0800 Subject: [PATCH 5/5] ble(fix): deinit crash issue --- components/bt/controller/esp32c2/bt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/bt/controller/esp32c2/bt.c b/components/bt/controller/esp32c2/bt.c index a0af304fc3..b4d6868927 100644 --- a/components/bt/controller/esp32c2/bt.c +++ b/components/bt/controller/esp32c2/bt.c @@ -669,7 +669,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 @@ -693,11 +693,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 @@ -721,10 +722,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);