From 071b489c5d62eb408f245ee67144539fe547658c Mon Sep 17 00:00:00 2001 From: Zhou Xiao Date: Wed, 9 Jul 2025 13:13:19 +0800 Subject: [PATCH 1/9] change(ble): [AUTO_MR] Update lib_esp32h2 to ca6c20bc (cherry picked from commit 6a650312d4eff157c8c1f247904a1267adcf8954) Co-authored-by: Zhou Xiao --- components/bt/controller/lib_esp32h2/esp32h2-bt-lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bt/controller/lib_esp32h2/esp32h2-bt-lib b/components/bt/controller/lib_esp32h2/esp32h2-bt-lib index 513c3fb61e..b83a28f797 160000 --- a/components/bt/controller/lib_esp32h2/esp32h2-bt-lib +++ b/components/bt/controller/lib_esp32h2/esp32h2-bt-lib @@ -1 +1 @@ -Subproject commit 513c3fb61e0aa30b22d920ec17408a13be4ef93a +Subproject commit b83a28f7978625d20147f8999aac53a08420bf7a From 2339901607ab661bc36e3738af4114f0073c42e2 Mon Sep 17 00:00:00 2001 From: Zhou Xiao Date: Wed, 9 Jul 2025 13:13:22 +0800 Subject: [PATCH 2/9] change(ble): [AUTO_MR] Update lib_esp32c6 to ca6c20bc (cherry picked from commit 1e236a1febaa3da1412e13e011ba8bf28f06300b) Co-authored-by: Zhou Xiao --- components/bt/controller/lib_esp32c6/esp32c6-bt-lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bt/controller/lib_esp32c6/esp32c6-bt-lib b/components/bt/controller/lib_esp32c6/esp32c6-bt-lib index 80f6b7e6e4..f68cbf2768 160000 --- a/components/bt/controller/lib_esp32c6/esp32c6-bt-lib +++ b/components/bt/controller/lib_esp32c6/esp32c6-bt-lib @@ -1 +1 @@ -Subproject commit 80f6b7e6e4bcfc28684a9273a2bc037097255e51 +Subproject commit f68cbf2768b4177794e9938e51221b2744c336b3 From 89da7335a951d953fe53fef834b987e9547137d9 Mon Sep 17 00:00:00 2001 From: Zhou Xiao Date: Wed, 9 Jul 2025 13:13:24 +0800 Subject: [PATCH 3/9] change(ble): [AUTO_MR] Update lib_esp32c2 to c7732d48 (cherry picked from commit 3d45e8578e4d8632c9bb227e5895b71873170cb2) Co-authored-by: Zhou Xiao --- 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 7be8be96db..68d2b55c99 160000 --- a/components/bt/controller/lib_esp32c2/esp32c2-bt-lib +++ b/components/bt/controller/lib_esp32c2/esp32c2-bt-lib @@ -1 +1 @@ -Subproject commit 7be8be96db63928b5c4c6785f633eddbffa3287c +Subproject commit 68d2b55c99c5fad51dcc6c269464a6adb59d0206 From 643bcf2f3b2af358cc4951f99f7ee2cec5f3fedc Mon Sep 17 00:00:00 2001 From: Zhou Xiao Date: Wed, 9 Jul 2025 13:13:27 +0800 Subject: [PATCH 4/9] feat(ble): support memory allocation check debug feature on ESP32-C2 (cherry picked from commit 7ef90d41130900e2bb54652a651f37093da65bb9) Co-authored-by: cjin --- components/bt/controller/esp32c2/Kconfig.in | 163 +++++++++--------- components/bt/controller/esp32c2/bt.c | 7 + .../bt/include/esp32c2/include/esp_bt.h | 4 + components/bt/porting/include/bt_osi_mem.h | 4 + components/bt/porting/mem/bt_osi_mem.c | 30 +++- 5 files changed, 130 insertions(+), 78 deletions(-) diff --git a/components/bt/controller/esp32c2/Kconfig.in b/components/bt/controller/esp32c2/Kconfig.in index f3796bad13..dd3e3f9b32 100644 --- a/components/bt/controller/esp32c2/Kconfig.in +++ b/components/bt/controller/esp32c2/Kconfig.in @@ -281,94 +281,103 @@ config BT_LE_CONTROLLER_TASK_STACK_SIZE help This configures stack size of NimBLE controller task -menuconfig BT_LE_CONTROLLER_LOG_ENABLED - bool "Controller log enable" - default n - help - Enable controller log +menu "Controller debug features" + menuconfig 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_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_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 - default y - help - Only operate in dump mode + config BT_LE_CONTROLLER_LOG_DUMP_ONLY + bool "Controller log dump mode only" + depends on BT_LE_CONTROLLER_LOG_ENABLED + default y + help + Only operate in dump mode -config BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED - bool "Output ble controller logs to SPI bus (Experimental)" - depends on BT_LE_CONTROLLER_LOG_ENABLED - depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY - select BT_BLE_LOG_SPI_OUT_ENABLED - default n - help - Output ble controller logs to SPI bus + config BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED + bool "Output ble controller logs to SPI bus (Experimental)" + depends on BT_LE_CONTROLLER_LOG_ENABLED + depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY + select BT_BLE_LOG_SPI_OUT_ENABLED + default n + help + Output ble controller logs to SPI bus -config BT_LE_CONTROLLER_LOG_STORAGE_ENABLE - bool "Store ble controller logs to flash(Experimental)" - depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY - depends on BT_LE_CONTROLLER_LOG_ENABLED - default n - help - Store ble controller logs to flash memory. + config BT_LE_CONTROLLER_LOG_STORAGE_ENABLE + bool "Store ble controller logs to flash(Experimental)" + depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY + depends on BT_LE_CONTROLLER_LOG_ENABLED + default n + help + Store ble controller logs to flash memory. -config BT_LE_CONTROLLER_LOG_PARTITION_SIZE - int "size of ble controller log partition(Multiples of 4K)" - depends on BT_LE_CONTROLLER_LOG_STORAGE_ENABLE - default 65536 - help - The size of ble controller log partition shall be a multiples of 4K. - The name of log partition shall be "bt_ctrl_log". - The partition type shall be ESP_PARTITION_TYPE_DATA. - The partition sub_type shall be ESP_PARTITION_SUBTYPE_ANY. + config BT_LE_CONTROLLER_LOG_PARTITION_SIZE + int "size of ble controller log partition(Multiples of 4K)" + depends on BT_LE_CONTROLLER_LOG_STORAGE_ENABLE + default 65536 + help + The size of ble controller log partition shall be a multiples of 4K. + The name of log partition shall be "bt_ctrl_log". + The partition type shall be ESP_PARTITION_TYPE_DATA. + The partition sub_type shall be ESP_PARTITION_SUBTYPE_ANY. -config BT_LE_LOG_CTRL_BUF1_SIZE - int "size of the first BLE controller LOG buffer" - depends on BT_LE_CONTROLLER_LOG_ENABLED - default 4096 - help - Configure the size of the first BLE controller LOG buffer. + config BT_LE_LOG_CTRL_BUF1_SIZE + int "size of the first BLE controller LOG buffer" + depends on BT_LE_CONTROLLER_LOG_ENABLED + default 4096 + help + Configure the size of the first BLE controller LOG buffer. -config BT_LE_LOG_CTRL_BUF2_SIZE - int "size of the second BLE controller LOG buffer" - depends on BT_LE_CONTROLLER_LOG_ENABLED - default 1024 - help - Configure the size of the second BLE controller LOG buffer. + config BT_LE_LOG_CTRL_BUF2_SIZE + int "size of the second BLE controller LOG buffer" + depends on BT_LE_CONTROLLER_LOG_ENABLED + default 1024 + help + Configure the size of the second BLE controller LOG buffer. -config BT_LE_LOG_HCI_BUF_SIZE - int "size of the BLE HCI LOG buffer" - depends on BT_LE_CONTROLLER_LOG_ENABLED - default 4096 - help - Configure the size of the BLE HCI LOG buffer. + config BT_LE_LOG_HCI_BUF_SIZE + int "size of the BLE HCI LOG buffer" + depends on BT_LE_CONTROLLER_LOG_ENABLED + default 4096 + help + Configure the size of the BLE HCI LOG buffer. -config BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE - bool "Enable wrap panic handler" - depends on BT_LE_CONTROLLER_LOG_ENABLED - default n - help - Wrap esp_panic_handler to get controller logs when PC pointer exception crashes. + config BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE + bool "Enable wrap panic handler" + depends on BT_LE_CONTROLLER_LOG_ENABLED + default n + help + Wrap esp_panic_handler to get controller logs when PC pointer exception crashes. + + config BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE + bool "Enable esp_task_wdt_isr_user_handler implementation" + depends on BT_LE_CONTROLLER_LOG_ENABLED + default n + help + Implement esp_task_wdt_isr_user_handler to get controller logs when task wdt issue is triggered. + + config BT_LE_MEM_CHECK_ENABLED + bool "Enable memory allocation check" + default n + help + Used in internal tests only. Enable the memory allocation check. +endmenu -config BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE - bool "Enable esp_task_wdt_isr_user_handler implementation" - depends on BT_LE_CONTROLLER_LOG_ENABLED - default n - help - Implement esp_task_wdt_isr_user_handler to get controller logs when task wdt issue is triggered. config BT_LE_LL_RESOLV_LIST_SIZE int "BLE LL Resolving list size" range 1 5 diff --git a/components/bt/controller/esp32c2/bt.c b/components/bt/controller/esp32c2/bt.c index e2a39427c6..fa310ac0be 100644 --- a/components/bt/controller/esp32c2/bt.c +++ b/components/bt/controller/esp32c2/bt.c @@ -1571,3 +1571,10 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv) #endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC #endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED) + +#if CONFIG_BT_LE_MEM_CHECK_ENABLED +void ble_memory_count_limit_set(uint16_t count_limit) +{ + bt_osi_mem_count_limit_set(count_limit); +} +#endif // CONFIG_BT_LE_MEM_CHECK_ENABLED diff --git a/components/bt/include/esp32c2/include/esp_bt.h b/components/bt/include/esp32c2/include/esp_bt.h index dcb7ccd757..320ae238d0 100644 --- a/components/bt/include/esp32c2/include/esp_bt.h +++ b/components/bt/include/esp32c2/include/esp_bt.h @@ -446,6 +446,10 @@ uint32_t esp_bt_get_lpclk_freq(void); void esp_bt_set_lpclk_freq(uint32_t clk_freq); +#if CONFIG_BT_LE_MEM_CHECK_ENABLED +void ble_memory_count_limit_set(uint16_t count_limit); +#endif // CONFIG_BT_LE_MEM_CHECK_ENABLED + #ifdef __cplusplus } #endif diff --git a/components/bt/porting/include/bt_osi_mem.h b/components/bt/porting/include/bt_osi_mem.h index 9ab06d0ab4..cf5f60956e 100644 --- a/components/bt/porting/include/bt_osi_mem.h +++ b/components/bt/porting/include/bt_osi_mem.h @@ -19,3 +19,7 @@ void *bt_osi_mem_malloc_internal(size_t size); void *bt_osi_mem_calloc_internal(size_t n, size_t size); void bt_osi_mem_free(void *ptr); + +#if CONFIG_BT_LE_MEM_CHECK_ENABLED +void bt_osi_mem_count_limit_set(uint16_t count_limit); +#endif // CONFIG_BT_LE_MEM_CHECK_ENABLED diff --git a/components/bt/porting/mem/bt_osi_mem.c b/components/bt/porting/mem/bt_osi_mem.c index 612099d277..cbedf8c96d 100644 --- a/components/bt/porting/mem/bt_osi_mem.c +++ b/components/bt/porting/mem/bt_osi_mem.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -11,6 +11,10 @@ #include static uint8_t log_count; +#if CONFIG_BT_LE_MEM_CHECK_ENABLED +static uint16_t mem_count_limit = 0; +static uint16_t curr_mem_count; +#endif // CONFIG_BT_LE_MEM_CHECK_ENABLED IRAM_ATTR void *bt_osi_mem_malloc(size_t size) { void *mem = NULL; @@ -49,11 +53,27 @@ IRAM_ATTR void *bt_osi_mem_calloc(size_t n, size_t size) IRAM_ATTR void *bt_osi_mem_malloc_internal(size_t size) { +#if CONFIG_BT_LE_MEM_CHECK_ENABLED + if (mem_count_limit) { + if (curr_mem_count > mem_count_limit) { + return NULL; + } + curr_mem_count ++; + } +#endif // CONFIG_BT_LE_MEM_CHECK_ENABLED return heap_caps_malloc(size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT|MALLOC_CAP_DMA); } IRAM_ATTR void *bt_osi_mem_calloc_internal(size_t n, size_t size) { +#if CONFIG_BT_LE_MEM_CHECK_ENABLED + if (mem_count_limit) { + if (curr_mem_count > mem_count_limit) { + return NULL; + } + curr_mem_count ++; + } +#endif // CONFIG_BT_LE_MEM_CHECK_ENABLED return heap_caps_calloc(n, size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT|MALLOC_CAP_DMA); } @@ -61,3 +81,11 @@ IRAM_ATTR void bt_osi_mem_free(void *ptr) { heap_caps_free(ptr); } + +#if CONFIG_BT_LE_MEM_CHECK_ENABLED +void bt_osi_mem_count_limit_set(uint16_t count_limit) +{ + mem_count_limit = count_limit; + curr_mem_count = 0; +} +#endif // CONFIG_BT_LE_MEM_CHECK_ENABLED From 3e9279ce8234a30fb44c74dac26654563bc6819b Mon Sep 17 00:00:00 2001 From: Zhou Xiao Date: Wed, 9 Jul 2025 13:13:29 +0800 Subject: [PATCH 5/9] feat(ble): support memory allocation check debug feature on ESP32-C6 (cherry picked from commit 027766e0c26dcfd1d04fd9cf5d8d5f7ed85a9d1c) Co-authored-by: cjin --- components/bt/controller/esp32c6/Kconfig.in | 6 ++++++ components/bt/controller/esp32c6/bt.c | 7 +++++++ components/bt/include/esp32c6/include/esp_bt.h | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/components/bt/controller/esp32c6/Kconfig.in b/components/bt/controller/esp32c6/Kconfig.in index 8f3c33630b..f7b2a7db92 100644 --- a/components/bt/controller/esp32c6/Kconfig.in +++ b/components/bt/controller/esp32c6/Kconfig.in @@ -447,6 +447,12 @@ menu "Controller debug features" config BT_LE_PTR_CHECK_ENABLED bool "Enable boundary check for internal memory" default n + + config BT_LE_MEM_CHECK_ENABLED + bool "Enable memory allocation check" + default n + help + Used in internal tests only. Enable the memory allocation check. endmenu config BT_LE_LL_RESOLV_LIST_SIZE diff --git a/components/bt/controller/esp32c6/bt.c b/components/bt/controller/esp32c6/bt.c index 105c71db5e..39272f0184 100644 --- a/components/bt/controller/esp32c6/bt.c +++ b/components/bt/controller/esp32c6/bt.c @@ -1768,3 +1768,10 @@ ble_capture_info_user_handler(uint8_t type, uint32_t reason, uint32_t param1, ui } return 0; } + +#if CONFIG_BT_LE_MEM_CHECK_ENABLED +void ble_memory_count_limit_set(uint16_t count_limit) +{ + bt_osi_mem_count_limit_set(count_limit); +} +#endif // CONFIG_BT_LE_MEM_CHECK_ENABLED diff --git a/components/bt/include/esp32c6/include/esp_bt.h b/components/bt/include/esp32c6/include/esp_bt.h index 960defc144..94f099184a 100644 --- a/components/bt/include/esp32c6/include/esp_bt.h +++ b/components/bt/include/esp32c6/include/esp_bt.h @@ -521,6 +521,10 @@ uint32_t esp_bt_get_lpclk_freq(void); void esp_bt_set_lpclk_freq(uint32_t clk_freq); +#if CONFIG_BT_LE_MEM_CHECK_ENABLED +void ble_memory_count_limit_set(uint16_t count_limit); +#endif // CONFIG_BT_LE_MEM_CHECK_ENABLED + #ifdef __cplusplus } #endif From 7c247b7aed6a946932b82994e6acb5cf00652215 Mon Sep 17 00:00:00 2001 From: Zhou Xiao Date: Wed, 9 Jul 2025 13:13:32 +0800 Subject: [PATCH 6/9] feat(ble): support memory allocation check debug feature on ESP32-H2 (cherry picked from commit 265a8746dce7a1acb427c6f0a017a918dbbb1bef) Co-authored-by: cjin --- components/bt/controller/esp32h2/Kconfig.in | 6 ++++++ components/bt/controller/esp32h2/bt.c | 7 +++++++ components/bt/include/esp32h2/include/esp_bt.h | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/components/bt/controller/esp32h2/Kconfig.in b/components/bt/controller/esp32h2/Kconfig.in index 2f914a1075..5ff989a8b4 100644 --- a/components/bt/controller/esp32h2/Kconfig.in +++ b/components/bt/controller/esp32h2/Kconfig.in @@ -441,6 +441,12 @@ menu "Controller debug features" config BT_LE_PTR_CHECK_ENABLED bool "Enable boundary check for internal memory" default n + + config BT_LE_MEM_CHECK_ENABLED + bool "Enable memory allocation check" + default n + help + Used in internal tests only. Enable the memory allocation check. endmenu config BT_LE_LL_RESOLV_LIST_SIZE diff --git a/components/bt/controller/esp32h2/bt.c b/components/bt/controller/esp32h2/bt.c index c04e881cc6..4e05ff91cd 100644 --- a/components/bt/controller/esp32h2/bt.c +++ b/components/bt/controller/esp32h2/bt.c @@ -1693,3 +1693,10 @@ ble_capture_info_user_handler(uint8_t type, uint32_t reason, uint32_t param1, ui } return 0; } + +#if CONFIG_BT_LE_MEM_CHECK_ENABLED +void ble_memory_count_limit_set(uint16_t count_limit) +{ + bt_osi_mem_count_limit_set(count_limit); +} +#endif // CONFIG_BT_LE_MEM_CHECK_ENABLED diff --git a/components/bt/include/esp32h2/include/esp_bt.h b/components/bt/include/esp32h2/include/esp_bt.h index b33f8b7359..601f5816a3 100644 --- a/components/bt/include/esp32h2/include/esp_bt.h +++ b/components/bt/include/esp32h2/include/esp_bt.h @@ -462,6 +462,10 @@ uint32_t esp_bt_get_lpclk_freq(void); void esp_bt_set_lpclk_freq(uint32_t clk_freq); +#if CONFIG_BT_LE_MEM_CHECK_ENABLED +void ble_memory_count_limit_set(uint16_t count_limit); +#endif // CONFIG_BT_LE_MEM_CHECK_ENABLED + #ifdef __cplusplus } #endif From 910dee18f2f180ee8cf814c7fa9f705e7d7b236b Mon Sep 17 00:00:00 2001 From: Zhou Xiao Date: Wed, 9 Jul 2025 13:13:34 +0800 Subject: [PATCH 7/9] feat(ble): enable broker initialization on ESP32-H2 (cherry picked from commit 64f216ae5a2a6362069925267f077ade4a37a7bf) Co-authored-by: cjin --- components/bt/controller/esp32h2/ble.c | 54 +++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/components/bt/controller/esp32h2/ble.c b/components/bt/controller/esp32h2/ble.c index 8aef45a9a8..a0faf1c4e5 100644 --- a/components/bt/controller/esp32h2/ble.c +++ b/components/bt/controller/esp32h2/ble.c @@ -22,6 +22,21 @@ void conn_stack_deinitEnv(void); int conn_stack_enable(void); void conn_stack_disable(void); +int adv_stack_initEnv(void); +void adv_stack_deinitEnv(void); +int adv_stack_enable(void); +void adv_stack_disable(void); + +int extAdv_stack_initEnv(void); +void extAdv_stack_deinitEnv(void); +int extAdv_stack_enable(void); +void extAdv_stack_disable(void); + +int sync_stack_initEnv(void); +void sync_stack_deinitEnv(void); +int sync_stack_enable(void); +void sync_stack_disable(void); + #if CONFIG_BT_LE_ERROR_SIM_ENABLED int conn_errorSim_initEnv(void); void conn_errorSim_deinitEnv(void); @@ -85,6 +100,22 @@ int ble_stack_initEnv(void) return rc; } + rc = adv_stack_initEnv(); + if (rc) { + return rc; + } + + rc = extAdv_stack_initEnv(); + if (rc) { + return rc; + } + + rc = sync_stack_initEnv(); + if (rc) { + return rc; + } + + #if DEFAULT_BT_LE_MAX_CONNECTIONS rc = conn_stack_initEnv(); if (rc) { @@ -109,7 +140,9 @@ void ble_stack_deinitEnv(void) #endif // CONFIG_BT_LE_ERROR_SIM_ENABLED conn_stack_deinitEnv(); #endif // DEFAULT_BT_LE_MAX_CONNECTIONS - + sync_stack_deinitEnv(); + extAdv_stack_deinitEnv(); + adv_stack_deinitEnv(); base_stack_deinitEnv(); } @@ -122,6 +155,21 @@ int ble_stack_enable(void) return rc; } + rc = adv_stack_enable(); + if (rc) { + return rc; + } + + rc = extAdv_stack_enable(); + if (rc) { + return rc; + } + + rc = sync_stack_enable(); + if (rc) { + return rc; + } + #if DEFAULT_BT_LE_MAX_CONNECTIONS rc = conn_stack_enable(); if (rc) { @@ -160,6 +208,8 @@ void ble_stack_disable(void) #endif // CONFIG_BT_LE_ERROR_SIM_ENABLED conn_stack_disable(); #endif // DEFAULT_BT_LE_MAX_CONNECTIONS - + sync_stack_disable(); + extAdv_stack_disable(); + adv_stack_disable(); base_stack_disable(); } From 0077cba84d150f47f7f0aeb573aa65e0051db7e5 Mon Sep 17 00:00:00 2001 From: Zhou Xiao Date: Wed, 9 Jul 2025 13:13:37 +0800 Subject: [PATCH 8/9] feat(ble): enable broker initialization on ESP32-C6 (cherry picked from commit 3d93ce37da16d24c7378295ed3c219cc6e141880) Co-authored-by: cjin --- components/bt/controller/esp32c6/ble.c | 53 +++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/components/bt/controller/esp32c6/ble.c b/components/bt/controller/esp32c6/ble.c index a1eb137489..14374c11a4 100644 --- a/components/bt/controller/esp32c6/ble.c +++ b/components/bt/controller/esp32c6/ble.c @@ -22,6 +22,21 @@ void conn_stack_deinitEnv(void); int conn_stack_enable(void); void conn_stack_disable(void); +int adv_stack_initEnv(void); +void adv_stack_deinitEnv(void); +int adv_stack_enable(void); +void adv_stack_disable(void); + +int extAdv_stack_initEnv(void); +void extAdv_stack_deinitEnv(void); +int extAdv_stack_enable(void); +void extAdv_stack_disable(void); + +int sync_stack_initEnv(void); +void sync_stack_deinitEnv(void); +int sync_stack_enable(void); +void sync_stack_disable(void); + #if CONFIG_BT_LE_ERROR_SIM_ENABLED int conn_errorSim_initEnv(void); void conn_errorSim_deinitEnv(void); @@ -104,6 +119,21 @@ int ble_stack_initEnv(void) #endif // CONFIG_BT_LE_ERROR_SIM_ENABLED #endif // DEFAULT_BT_LE_MAX_CONNECTIONS + rc = adv_stack_initEnv(); + if (rc) { + return rc; + } + + rc = extAdv_stack_initEnv(); + if (rc) { + return rc; + } + + rc = sync_stack_initEnv(); + if (rc) { + return rc; + } + return 0; } @@ -116,6 +146,10 @@ void ble_stack_deinitEnv(void) conn_stack_deinitEnv(); #endif // DEFAULT_BT_LE_MAX_CONNECTIONS + + sync_stack_deinitEnv(); + extAdv_stack_deinitEnv(); + adv_stack_deinitEnv(); base_stack_deinitEnv(); } @@ -128,6 +162,21 @@ int ble_stack_enable(void) return rc; } + rc = adv_stack_enable(); + if (rc) { + return rc; + } + + rc = extAdv_stack_enable(); + if (rc) { + return rc; + } + + rc = sync_stack_enable(); + if (rc) { + return rc; + } + #if DEFAULT_BT_LE_MAX_CONNECTIONS rc = conn_stack_enable(); if (rc) { @@ -166,6 +215,8 @@ void ble_stack_disable(void) #endif // CONFIG_BT_LE_ERROR_SIM_ENABLED conn_stack_disable(); #endif // DEFAULT_BT_LE_MAX_CONNECTIONS - + sync_stack_disable(); + extAdv_stack_disable(); + adv_stack_disable(); base_stack_disable(); } From 40a333b58f3d118379b636bfdd8c6ef72ebb32e4 Mon Sep 17 00:00:00 2001 From: Zhou Xiao Date: Wed, 9 Jul 2025 13:13:40 +0800 Subject: [PATCH 9/9] fix(ble): updated rom linker script for ESP32-C2 (cherry picked from commit f1838aeec1172f1285d8180073fbd6bdb639a54e) Co-authored-by: Zhou Xiao --- .../esp_rom/esp32c2/ld/esp32c2.rom.ble-eco4.ld | 8 ++++---- components/esp_rom/esp32c2/ld/esp32c2.rom.ble.ld | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/components/esp_rom/esp32c2/ld/esp32c2.rom.ble-eco4.ld b/components/esp_rom/esp32c2/ld/esp32c2.rom.ble-eco4.ld index e6d3094d24..b25193abce 100644 --- a/components/esp_rom/esp32c2/ld/esp32c2.rom.ble-eco4.ld +++ b/components/esp_rom/esp32c2/ld/esp32c2.rom.ble-eco4.ld @@ -41,7 +41,7 @@ r_ble_hci_trans_cfg_hs = 0x40000aec; r_ble_hci_trans_cfg_ll = 0x40000af0; r_ble_hci_trans_deinit = 0x40000af4; //r_ble_hci_trans_env_init = 0x40000af8; -r_ble_hci_trans_init = 0x40000afc; +//r_ble_hci_trans_init = 0x40000afc; r_ble_hci_uart_acl_tx = 0x40000b00; r_ble_hci_uart_cmdevt_tx = 0x40000b04; r_ble_hci_uart_config = 0x40000b08; @@ -767,7 +767,7 @@ r_ble_lll_rfmgmt_deinit = 0x4000164c; //r_ble_lll_rfmgmt_enable = 0x40001654; //r_ble_lll_rfmgmt_enable_now = 0x40001658; r_ble_lll_rfmgmt_init = 0x4000165c; -r_ble_lll_rfmgmt_is_enabled = 0x40001660; +//r_ble_lll_rfmgmt_is_enabled = 0x40001660; r_ble_lll_rfmgmt_release = 0x40001664; r_ble_lll_rfmgmt_release_ev = 0x40001668; r_ble_lll_rfmgmt_reset = 0x4000166c; @@ -785,7 +785,7 @@ r_ble_lll_scan_aux_data_free = 0x40001698; r_ble_lll_scan_chk_resume = 0x4000169c; r_ble_lll_scan_clean_cur_aux_data = 0x400016a0; //r_ble_lll_scan_coex_event_cb = 0x400016a4; -r_ble_lll_scan_common_init = 0x400016a8; +//r_ble_lll_scan_common_init = 0x400016a8; r_ble_lll_scan_deinit = 0x400016ac; r_ble_lll_scan_duration_period_timers_restart = 0x400016b0; r_ble_lll_scan_duration_period_timers_stop = 0x400016b4; @@ -1184,7 +1184,7 @@ r_ble_ll_conn_is_lru_compare_with_sync = 0x40002f88; r_ble_ll_conn_rollback_last_unmapped_chan = 0x40002f8c; //r_ble_ll_hci_vs_csa_set = 0x40002f90; r_ble_ll_hci_reset = 0x40002f94; -r_ble_ll_adv_status_check = 0x40002f98; +//r_ble_ll_adv_status_check = 0x40002f98; r_ble_ll_conn_status_check = 0x40002f9c; r_ble_ll_scan_status_check = 0x40002fa0; r_ble_ll_sync_status_check = 0x40002fa4; diff --git a/components/esp_rom/esp32c2/ld/esp32c2.rom.ble.ld b/components/esp_rom/esp32c2/ld/esp32c2.rom.ble.ld index 4f89f0b638..9673a3aa29 100644 --- a/components/esp_rom/esp32c2/ld/esp32c2.rom.ble.ld +++ b/components/esp_rom/esp32c2/ld/esp32c2.rom.ble.ld @@ -34,7 +34,7 @@ r_ble_hci_trans_buf_alloc = 0x40000ae4; r_ble_hci_trans_buf_free = 0x40000ae8; r_ble_hci_trans_cfg_hs = 0x40000aec; r_ble_hci_trans_cfg_ll = 0x40000af0; -r_ble_hci_trans_init = 0x40000afc; +//r_ble_hci_trans_init = 0x40000afc; r_ble_hci_uart_acl_tx = 0x40000b00; r_ble_hci_uart_cmdevt_tx = 0x40000b04; r_ble_hci_uart_config = 0x40000b08; @@ -362,7 +362,7 @@ r_ble_ll_resolv_get_list = 0x40001160; r_ble_ll_resolv_get_priv_addr = 0x40001164; r_ble_ll_resolv_get_rpa_tmo = 0x40001168; r_ble_ll_resolv_irk_nonzero = 0x40001170; -r_ble_ll_resolv_list_add = 0x40001174; +//r_ble_ll_resolv_list_add = 0x40001174; r_ble_ll_resolv_list_chg_allowed = 0x40001178; r_ble_ll_resolv_list_clr = 0x4000117c; r_ble_ll_resolv_list_find = 0x40001180; @@ -510,7 +510,7 @@ r_ble_lll_adv_make_done = 0x40001438; r_ble_lll_adv_periodic_done = 0x4000143c; r_ble_lll_adv_periodic_event_done = 0x40001440; r_ble_lll_adv_periodic_rmvd_from_sched = 0x40001444; -r_ble_lll_adv_periodic_schedule_first = 0x40001448; +//r_ble_lll_adv_periodic_schedule_first = 0x40001448; r_ble_lll_adv_pri_schedule_tx_pdu = 0x40001458; r_ble_lll_adv_reschedule_event = 0x4000145c; r_ble_lll_adv_reschedule_periodic_event = 0x40001460; @@ -521,7 +521,7 @@ r_ble_lll_adv_sm_deinit = 0x40001478; r_ble_lll_adv_sm_event_init = 0x4000147c; r_ble_lll_adv_sm_event_restore = 0x40001480; r_ble_lll_adv_sm_event_store = 0x40001484; -r_ble_lll_adv_sm_init = 0x40001488; +//r_ble_lll_adv_sm_init = 0x40001488; r_ble_lll_adv_sm_reset = 0x4000148c; r_ble_lll_adv_start = 0x40001490; r_ble_lll_adv_stop = 0x40001494; @@ -609,7 +609,7 @@ r_ble_lll_per_adv_coex_dpc_update = 0x40001634; r_ble_lll_per_adv_coex_dpc_update_on_data_updated = 0x40001638; r_ble_lll_per_adv_coex_dpc_update_on_scheduled = 0x4000163c; r_ble_lll_per_adv_coex_dpc_update_on_start = 0x40001640; -r_ble_lll_rfmgmt_is_enabled = 0x40001660; +//r_ble_lll_rfmgmt_is_enabled = 0x40001660; //r_ble_lll_rfmgmt_release = 0x40001664; r_ble_lll_rfmgmt_scan_changed = 0x40001670; r_ble_lll_rfmgmt_sched_changed = 0x40001674; @@ -622,7 +622,7 @@ r_ble_lll_scan_abort_aux_sched = 0x40001694; r_ble_lll_scan_chk_resume = 0x4000169c; r_ble_lll_scan_clean_cur_aux_data = 0x400016a0; //r_ble_lll_scan_coex_event_cb = 0x400016a4; -r_ble_lll_scan_common_init = 0x400016a8; +//r_ble_lll_scan_common_init = 0x400016a8; r_ble_lll_scan_deinit = 0x400016ac; r_ble_lll_scan_duration_period_timers_restart = 0x400016b0; r_ble_lll_scan_duration_period_timers_stop = 0x400016b4;