From 1d693ee1333af9f26b195bf80f298ae43d21cafe Mon Sep 17 00:00:00 2001 From: cjin Date: Wed, 18 Oct 2023 15:51:18 +0800 Subject: [PATCH 1/6] change(ble): update ble lib on c6 h2 and c2 chip --- components/bt/controller/lib_esp32c2/esp32c2-bt-lib | 2 +- components/bt/controller/lib_esp32c6/esp32c6-bt-lib | 2 +- components/bt/controller/lib_esp32h2/esp32h2-bt-lib | 2 +- components/esp_rom/esp32c2/ld/esp32c2.rom.ld | 6 ------ 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/components/bt/controller/lib_esp32c2/esp32c2-bt-lib b/components/bt/controller/lib_esp32c2/esp32c2-bt-lib index fc690c13c6..4fb60aa91d 160000 --- a/components/bt/controller/lib_esp32c2/esp32c2-bt-lib +++ b/components/bt/controller/lib_esp32c2/esp32c2-bt-lib @@ -1 +1 @@ -Subproject commit fc690c13c618d1cb8f94611c2bbe6aec2f1cc72e +Subproject commit 4fb60aa91de64b0f1d0eb6292d38b6c22a3aa005 diff --git a/components/bt/controller/lib_esp32c6/esp32c6-bt-lib b/components/bt/controller/lib_esp32c6/esp32c6-bt-lib index da04501653..25d9661bc3 160000 --- a/components/bt/controller/lib_esp32c6/esp32c6-bt-lib +++ b/components/bt/controller/lib_esp32c6/esp32c6-bt-lib @@ -1 +1 @@ -Subproject commit da045016531dbe7bf334507a79cd7d40d7549e7b +Subproject commit 25d9661bc3d5cc7bade40c03f501b935d3ad7642 diff --git a/components/bt/controller/lib_esp32h2/esp32h2-bt-lib b/components/bt/controller/lib_esp32h2/esp32h2-bt-lib index 32c856a1d9..8450d3f508 160000 --- a/components/bt/controller/lib_esp32h2/esp32h2-bt-lib +++ b/components/bt/controller/lib_esp32h2/esp32h2-bt-lib @@ -1 +1 @@ -Subproject commit 32c856a1d942cbb0100420373db2ea8c46721739 +Subproject commit 8450d3f50804bc2d685a6ef5c5a76e1f4f13d579 diff --git a/components/esp_rom/esp32c2/ld/esp32c2.rom.ld b/components/esp_rom/esp32c2/ld/esp32c2.rom.ld index 8b7e8cdf9d..63b063ff5b 100644 --- a/components/esp_rom/esp32c2/ld/esp32c2.rom.ld +++ b/components/esp_rom/esp32c2/ld/esp32c2.rom.ld @@ -605,10 +605,8 @@ r_ble_hw_rng_stop = 0x40000b94; r_ble_hw_rx_local_is_resolved = 0x40000b98; r_ble_hw_rx_local_is_rpa = 0x40000b9c; r_ble_hw_whitelist_add = 0x40000ba0; -r_ble_hw_whitelist_clear = 0x40000ba4; r_ble_hw_whitelist_dev_num = 0x40000ba8; r_ble_hw_whitelist_get_base = 0x40000bac; -r_ble_hw_whitelist_rmv = 0x40000bb0; r_ble_hw_whitelist_search = 0x40000bb4; r_ble_hw_whitelist_sort = 0x40000bb8; r_ble_ll_acl_data_in = 0x40000bbc; @@ -1381,12 +1379,8 @@ r_os_memblock_put_from_cb = 0x40001a4c; r_os_mempool_clear = 0x40001a50; r_os_mempool_ext_clear = 0x40001a54; r_os_mempool_ext_init = 0x40001a58; -r_os_mempool_info_get_next = 0x40001a5c; r_os_mempool_init = 0x40001a60; -r_os_mempool_init_internal = 0x40001a64; r_os_mempool_is_sane = 0x40001a68; -r_os_mempool_module_init = 0x40001a6c; -r_os_mempool_unregister = 0x40001a70; r_os_mqueue_get = 0x40001a74; r_os_mqueue_init = 0x40001a78; r_os_mqueue_put = 0x40001a7c; From 85bc27249075a2836889b95bfc8f5f64b1efe9d2 Mon Sep 17 00:00:00 2001 From: luomanruo Date: Wed, 18 Oct 2023 16:47:42 +0800 Subject: [PATCH 2/6] ble: update controller log module for ESP32-H2 and ESP32-C6 --- components/bt/controller/esp32c6/Kconfig.in | 14 ++++++ components/bt/controller/esp32c6/bt.c | 48 ++++++++++++------- components/bt/controller/esp32h2/Kconfig.in | 14 ++++++ components/bt/controller/esp32h2/bt.c | 48 ++++++++++++------- .../bt/include/esp32c6/include/esp_bt.h | 8 ++++ .../bt/include/esp32h2/include/esp_bt.h | 8 ++++ 6 files changed, 104 insertions(+), 36 deletions(-) diff --git a/components/bt/controller/esp32c6/Kconfig.in b/components/bt/controller/esp32c6/Kconfig.in index 439d57981d..4140671c44 100644 --- a/components/bt/controller/esp32c6/Kconfig.in +++ b/components/bt/controller/esp32c6/Kconfig.in @@ -263,9 +263,23 @@ config BT_LE_CONTROLLER_TASK_STACK_SIZE config BT_LE_CONTROLLER_LOG_ENABLED bool "Controller log enable" default n + help + Enable controller log + +config BT_LE_CONTROLLER_LOG_CTRL_ENABLED + bool "enable controller log module" + depends on BT_LE_CONTROLLER_LOG_ENABLED + default y help Enable controller log module +config BT_LE_CONTROLLER_LOG_HCI_ENABLED + bool "enable HCI log module" + depends on BT_LE_CONTROLLER_LOG_ENABLED + default y + help + Enable hci log module + config BT_LE_CONTROLLER_LOG_DUMP_ONLY bool "Controller log dump mode only" depends on BT_LE_CONTROLLER_LOG_ENABLED diff --git a/components/bt/controller/esp32c6/bt.c b/components/bt/controller/esp32c6/bt.c index 297bdce0bc..d2be4c827d 100644 --- a/components/bt/controller/esp32c6/bt.c +++ b/components/bt/controller/esp32c6/bt.c @@ -123,8 +123,9 @@ typedef void (*interface_func_t) (uint32_t len, const uint8_t*addr, bool end); extern int ble_osi_coex_funcs_register(struct osi_coex_funcs_t *coex_funcs); extern int ble_controller_init(esp_bt_controller_config_t *cfg); #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED -extern int ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create); +extern int ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size); extern int ble_log_deinit_async(void); +extern void ble_log_async_select_dump_buffers(uint8_t buffers); extern void ble_log_async_output_dump_all(bool output); #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED extern int ble_controller_deinit(void); @@ -200,6 +201,11 @@ static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, b /* Static variable declare */ static DRAM_ATTR esp_bt_controller_status_t ble_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE; +#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED +const static uint32_t log_bufs_size[] = {6144, 1024, 2048}; +static uint8_t buffers = 0; +#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED + /* This variable tells if BLE is running */ static bool s_ble_active = false; #ifdef CONFIG_PM_ENABLE @@ -766,6 +772,26 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) coex_init(); #endif // CONFIG_SW_COEXIST_ENABLE +#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED + interface_func_t bt_controller_log_interface; + bt_controller_log_interface = esp_bt_controller_log_interface; +#if CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED + buffers |= ESP_BLE_LOG_BUF_CONTROLLER; +#endif // CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED +#if CONFIG_BT_LE_CONTROLLER_LOG_HCI_ENABLED + buffers |= ESP_BLE_LOG_BUF_HCI; +#endif // CONFIG_BT_LE_CONTROLLER_LOG_HCI_ENABLED +#if CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY + ret = ble_log_init_async(bt_controller_log_interface, false, buffers, (uint32_t *)log_bufs_size); +#else + ret = ble_log_init_async(bt_controller_log_interface, true, buffers, (uint32_t *)log_bufs_size); +#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; + } +#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); @@ -773,19 +799,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) } esp_ble_change_rtc_freq(slow_clk_freq); -#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED - interface_func_t bt_controller_log_interface; - bt_controller_log_interface = esp_bt_controller_log_interface; -#if CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY - ret = ble_log_init_async(bt_controller_log_interface, false); -#else - ret = ble_log_init_async(bt_controller_log_interface, true); -#endif // CONFIG_BT_CONTROLLER_LOG_DUMP - if (ret != ESP_OK) { - ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_log_init failed %d", ret); - goto controller_init_err; - } -#endif // CONFIG_BT_CONTROLLER_LOG_ENABLED ble_controller_scan_duplicate_config(); @@ -812,13 +825,12 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) free_controller: controller_sleep_deinit(); -#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: +#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED + ble_log_deinit_async(); +#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED esp_phy_modem_deinit(); modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE); modem_clock_module_disable(PERIPH_BT_MODULE); diff --git a/components/bt/controller/esp32h2/Kconfig.in b/components/bt/controller/esp32h2/Kconfig.in index 8489faf3ea..024f85fce3 100644 --- a/components/bt/controller/esp32h2/Kconfig.in +++ b/components/bt/controller/esp32h2/Kconfig.in @@ -263,9 +263,23 @@ config BT_LE_CONTROLLER_TASK_STACK_SIZE config BT_LE_CONTROLLER_LOG_ENABLED bool "Controller log enable" default n + help + Enable controller log + +config BT_LE_CONTROLLER_LOG_CTRL_ENABLED + bool "enable controller log module" + depends on BT_LE_CONTROLLER_LOG_ENABLED + default y help Enable controller log module +config BT_LE_CONTROLLER_LOG_HCI_ENABLED + bool "enable HCI log module" + depends on BT_LE_CONTROLLER_LOG_ENABLED + default y + help + Enable hci log module + config BT_LE_CONTROLLER_LOG_DUMP_ONLY bool "Controller log dump mode only" depends on BT_LE_CONTROLLER_LOG_ENABLED diff --git a/components/bt/controller/esp32h2/bt.c b/components/bt/controller/esp32h2/bt.c index e88245cd17..48203f7734 100644 --- a/components/bt/controller/esp32h2/bt.c +++ b/components/bt/controller/esp32h2/bt.c @@ -117,8 +117,9 @@ typedef void (*interface_func_t) (uint32_t len, const uint8_t*addr, bool end); extern int ble_osi_coex_funcs_register(struct osi_coex_funcs_t *coex_funcs); extern int ble_controller_init(esp_bt_controller_config_t *cfg); #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED -extern int ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create); +extern int ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size); extern int ble_log_deinit_async(void); +extern void ble_log_async_select_dump_buffers(uint8_t buffers); extern void ble_log_async_output_dump_all(bool output); #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED extern int ble_controller_deinit(void); @@ -194,6 +195,11 @@ static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, b /* Static variable declare */ static DRAM_ATTR esp_bt_controller_status_t ble_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE; +#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED +const static uint32_t log_bufs_size[] = {6144, 1024, 2048}; +static uint8_t buffers = 0; +#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED + /* This variable tells if BLE is running */ static bool s_ble_active = false; #ifdef CONFIG_PM_ENABLE @@ -746,6 +752,26 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) coex_init(); #endif // CONFIG_SW_COEXIST_ENABLE +#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED + interface_func_t bt_controller_log_interface; + bt_controller_log_interface = esp_bt_controller_log_interface; +#if CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED + buffers |= ESP_BLE_LOG_BUF_CONTROLLER; +#endif // CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED +#if CONFIG_BT_LE_CONTROLLER_LOG_HCI_ENABLED + buffers |= ESP_BLE_LOG_BUF_HCI; +#endif // CONFIG_BT_LE_CONTROLLER_LOG_HCI_ENABLED +#if CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY + ret = ble_log_init_async(bt_controller_log_interface, false, buffers, (uint32_t *)log_bufs_size); +#else + ret = ble_log_init_async(bt_controller_log_interface, true, buffers, (uint32_t *)log_bufs_size); +#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; + } +#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); @@ -753,19 +779,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) } esp_ble_change_rtc_freq(slow_clk_freq); -#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED - interface_func_t bt_controller_log_interface; - bt_controller_log_interface = esp_bt_controller_log_interface; -#if CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY - ret = ble_log_init_async(bt_controller_log_interface, false); -#else - ret = ble_log_init_async(bt_controller_log_interface, true); -#endif // CONFIG_BT_CONTROLLER_LOG_DUMP - if (ret != ESP_OK) { - ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_log_init failed %d", ret); - goto controller_init_err; - } -#endif // CONFIG_BT_CONTROLLER_LOG_ENABLED ble_controller_scan_duplicate_config(); @@ -793,13 +806,12 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) free_controller: controller_sleep_deinit(); -#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: +#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED + ble_log_deinit_async(); +#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE); modem_clock_module_disable(PERIPH_BT_MODULE); #if CONFIG_BT_NIMBLE_ENABLED diff --git a/components/bt/include/esp32c6/include/esp_bt.h b/components/bt/include/esp32c6/include/esp_bt.h index 1e96bfd0d7..876754df6d 100644 --- a/components/bt/include/esp32c6/include/esp_bt.h +++ b/components/bt/include/esp32c6/include/esp_bt.h @@ -103,6 +103,14 @@ typedef enum { ESP_BLE_ENHANCED_PWR_TYPE_MAX, } esp_ble_enhanced_power_type_t; +/** + * @brief Select buffers +*/ +typedef enum { + ESP_BLE_LOG_BUF_HCI = 0x02, + ESP_BLE_LOG_BUF_CONTROLLER = 0x05, +} esp_ble_log_buf_t; + /** * @brief Address type and address value. */ diff --git a/components/bt/include/esp32h2/include/esp_bt.h b/components/bt/include/esp32h2/include/esp_bt.h index 7f929d63ae..75b9231b22 100644 --- a/components/bt/include/esp32h2/include/esp_bt.h +++ b/components/bt/include/esp32h2/include/esp_bt.h @@ -116,6 +116,14 @@ typedef struct { uint8_t val[6]; /*!< Array containing the 6-byte Bluetooth address value */ } esp_ble_addr_t; +/** + * @brief Select buffers +*/ +typedef enum { + ESP_BLE_LOG_BUF_HCI = 0x02, + ESP_BLE_LOG_BUF_CONTROLLER = 0x05, +} esp_ble_log_buf_t; + /** * @brief Set BLE TX power * Connection Tx power should only be set after connection created. From 20533dccce8f2247e0a86b439dad0992746b9728 Mon Sep 17 00:00:00 2001 From: luomanruo Date: Wed, 18 Oct 2023 16:51:42 +0800 Subject: [PATCH 3/6] ble: update controller log module for ESP32-C2 --- components/bt/controller/esp32c2/Kconfig.in | 14 ++++++ components/bt/controller/esp32c2/bt.c | 49 ++++++++++++------- .../bt/include/esp32c2/include/esp_bt.h | 8 +++ 3 files changed, 52 insertions(+), 19 deletions(-) diff --git a/components/bt/controller/esp32c2/Kconfig.in b/components/bt/controller/esp32c2/Kconfig.in index ca1902ca94..6c2971dcf1 100644 --- a/components/bt/controller/esp32c2/Kconfig.in +++ b/components/bt/controller/esp32c2/Kconfig.in @@ -256,9 +256,23 @@ config BT_LE_CONTROLLER_TASK_STACK_SIZE config BT_LE_CONTROLLER_LOG_ENABLED bool "Controller log enable" default n + help + Enable controller log + +config BT_LE_CONTROLLER_LOG_CTRL_ENABLED + bool "enable controller log module" + depends on BT_LE_CONTROLLER_LOG_ENABLED + default y help Enable controller log module +config BT_LE_CONTROLLER_LOG_HCI_ENABLED + bool "enable HCI log module" + depends on BT_LE_CONTROLLER_LOG_ENABLED + default y + help + Enable hci log module + config BT_LE_CONTROLLER_LOG_DUMP_ONLY bool "Controller log dump mode only" depends on BT_LE_CONTROLLER_LOG_ENABLED diff --git a/components/bt/controller/esp32c2/bt.c b/components/bt/controller/esp32c2/bt.c index 7ed6ca84ae..b2e1093072 100644 --- a/components/bt/controller/esp32c2/bt.c +++ b/components/bt/controller/esp32c2/bt.c @@ -124,7 +124,7 @@ typedef void (*interface_func_t) (uint32_t len, const uint8_t*addr, bool end); extern int ble_osi_coex_funcs_register(struct osi_coex_funcs_t *coex_funcs); extern int ble_controller_init(esp_bt_controller_config_t *cfg); #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED -extern int ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create); +extern int ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size); extern int ble_log_deinit_async(void); extern void ble_log_async_output_dump_all(bool output); #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED @@ -200,6 +200,11 @@ static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, b /* Static variable declare */ static DRAM_ATTR esp_bt_controller_status_t ble_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE; +#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED +const static uint32_t log_bufs_size[] = {2048, 1024, 1024}; +static uint8_t buffers = 0; +#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED + /* This variable tells if BLE is running */ static bool s_ble_active = false; #ifdef CONFIG_PM_ENABLE @@ -639,26 +644,33 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) #if CONFIG_SW_COEXIST_ENABLE coex_init(); #endif + +#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED + interface_func_t bt_controller_log_interface; + bt_controller_log_interface = esp_bt_controller_log_interface; +#if CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED + buffers |= ESP_BLE_LOG_BUF_CONTROLLER; +#endif // CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED +#if CONFIG_BT_LE_CONTROLLER_LOG_HCI_ENABLED + buffers |= ESP_BLE_LOG_BUF_HCI; +#endif // CONFIG_BT_LE_CONTROLLER_LOG_HCI_ENABLED +#if CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY + ret = ble_log_init_async(bt_controller_log_interface, false, buffers, (uint32_t *)log_bufs_size); +#else + ret = ble_log_init_async(bt_controller_log_interface, true, buffers, (uint32_t *)log_bufs_size); +#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; + } +#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; } -#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED - interface_func_t bt_controller_log_interface; - bt_controller_log_interface = esp_bt_controller_log_interface; -#if CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY - ret = ble_log_init_async(bt_controller_log_interface, false); -#else - ret = ble_log_init_async(bt_controller_log_interface, true); -#endif // CONFIG_BT_CONTROLLER_LOG_DUMP - if (ret != ESP_OK) { - ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_log_init failed %d", ret); - goto controller_init_err; - } -#endif // CONFIG_BT_CONTROLLER_LOG_ENABLED - ret = controller_sleep_init(); if (ret != ESP_OK) { ESP_LOGW(NIMBLE_PORT_LOG_TAG, "controller_sleep_init failed %d", ret); @@ -679,12 +691,11 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) return ESP_OK; free_controller: controller_sleep_deinit(); -#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: +#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED + ble_log_deinit_async(); +#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED esp_phy_modem_deinit(); periph_module_disable(PERIPH_BT_MODULE); #if CONFIG_BT_NIMBLE_ENABLED diff --git a/components/bt/include/esp32c2/include/esp_bt.h b/components/bt/include/esp32c2/include/esp_bt.h index ae6a6bde78..6939470393 100644 --- a/components/bt/include/esp32c2/include/esp_bt.h +++ b/components/bt/include/esp32c2/include/esp_bt.h @@ -106,6 +106,14 @@ typedef enum { ESP_BLE_ENHANCED_PWR_TYPE_MAX, } esp_ble_enhanced_power_type_t; +/** + * @brief Select buffers +*/ +typedef enum { + ESP_BLE_LOG_BUF_HCI = 0x02, + ESP_BLE_LOG_BUF_CONTROLLER = 0x05, +} esp_ble_log_buf_t; + /** * @brief Address type and address value. */ From f3447f256ff1e114024fedf13c8f3f4f6a1233de Mon Sep 17 00:00:00 2001 From: zwl Date: Wed, 18 Oct 2023 17:01:23 +0800 Subject: [PATCH 4/6] fix(ble): fixed ble connection timeout issue on ESP32H2 --- components/esp_phy/lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_phy/lib b/components/esp_phy/lib index ea648e92ec..12981140ec 160000 --- a/components/esp_phy/lib +++ b/components/esp_phy/lib @@ -1 +1 @@ -Subproject commit ea648e92ecaba36b0f2437849569795d85433497 +Subproject commit 12981140ec2cd9730b883924bc906a80a304e2ee From bacd3f40bb33af5ad40818841b74629de26dbd64 Mon Sep 17 00:00:00 2001 From: luomanruo Date: Wed, 18 Oct 2023 18:10:25 +0800 Subject: [PATCH 5/6] ble: update controller log module for ESP32-C6, ESP32-H2 and ESP32-C2 --- components/bt/controller/esp32c2/bt.c | 2 +- components/bt/controller/esp32c6/bt.c | 2 +- components/bt/controller/esp32h2/bt.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 b2e1093072..6eef298151 100644 --- a/components/bt/controller/esp32c2/bt.c +++ b/components/bt/controller/esp32c2/bt.c @@ -202,7 +202,6 @@ static DRAM_ATTR esp_bt_controller_status_t ble_controller_status = ESP_BT_CONTR #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED const static uint32_t log_bufs_size[] = {2048, 1024, 1024}; -static uint8_t buffers = 0; #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED /* This variable tells if BLE is running */ @@ -648,6 +647,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED interface_func_t bt_controller_log_interface; bt_controller_log_interface = esp_bt_controller_log_interface; + uint8_t buffers = 0; #if CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED buffers |= ESP_BLE_LOG_BUF_CONTROLLER; #endif // CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED diff --git a/components/bt/controller/esp32c6/bt.c b/components/bt/controller/esp32c6/bt.c index d2be4c827d..4691ba4a6d 100644 --- a/components/bt/controller/esp32c6/bt.c +++ b/components/bt/controller/esp32c6/bt.c @@ -203,7 +203,6 @@ static DRAM_ATTR esp_bt_controller_status_t ble_controller_status = ESP_BT_CONTR #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED const static uint32_t log_bufs_size[] = {6144, 1024, 2048}; -static uint8_t buffers = 0; #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED /* This variable tells if BLE is running */ @@ -775,6 +774,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED interface_func_t bt_controller_log_interface; bt_controller_log_interface = esp_bt_controller_log_interface; + uint8_t buffers = 0; #if CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED buffers |= ESP_BLE_LOG_BUF_CONTROLLER; #endif // CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED diff --git a/components/bt/controller/esp32h2/bt.c b/components/bt/controller/esp32h2/bt.c index 48203f7734..068387749f 100644 --- a/components/bt/controller/esp32h2/bt.c +++ b/components/bt/controller/esp32h2/bt.c @@ -197,7 +197,6 @@ static DRAM_ATTR esp_bt_controller_status_t ble_controller_status = ESP_BT_CONTR #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED const static uint32_t log_bufs_size[] = {6144, 1024, 2048}; -static uint8_t buffers = 0; #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED /* This variable tells if BLE is running */ @@ -755,6 +754,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED interface_func_t bt_controller_log_interface; bt_controller_log_interface = esp_bt_controller_log_interface; + uint8_t buffers = 0; #if CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED buffers |= ESP_BLE_LOG_BUF_CONTROLLER; #endif // CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED From eccf07022ebf29320ef86abbec2ad4a75e57a48a Mon Sep 17 00:00:00 2001 From: luomanruo Date: Thu, 19 Oct 2023 14:29:52 +0800 Subject: [PATCH 6/6] fix(ble): fixed ble connection timeout issue on ESP32H2 --- components/esp_phy/lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_phy/lib b/components/esp_phy/lib index 12981140ec..ecd88d5ce3 160000 --- a/components/esp_phy/lib +++ b/components/esp_phy/lib @@ -1 +1 @@ -Subproject commit 12981140ec2cd9730b883924bc906a80a304e2ee +Subproject commit ecd88d5ce3578e45402b80b78c26969ef8732839