From 907e11c880ff15408478b92c7190cd49d5081138 Mon Sep 17 00:00:00 2001 From: Zhao Wei Liang Date: Wed, 26 Feb 2025 15:03:44 +0800 Subject: [PATCH 1/3] fix(ble): fixed common kconfig error when controller enable only (cherry picked from commit 5b8ac71ace864a7bb9100a68dc650b8502315411) Co-authored-by: zwl --- components/bt/Kconfig | 2 -- components/bt/common/Kconfig.in | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/components/bt/Kconfig b/components/bt/Kconfig index 65c757a25f..417a8c18e9 100644 --- a/components/bt/Kconfig +++ b/components/bt/Kconfig @@ -81,8 +81,6 @@ menu "Bluetooth" So this option will disable the PMP (ESP_SYSTEM_PMP_IDRAM_SPLIT) menu "Common Options" - visible if (BT_BLUEDROID_ENABLED || BT_NIMBLE_ENABLED) - source "$IDF_PATH/components/bt/common/Kconfig.in" endmenu diff --git a/components/bt/common/Kconfig.in b/components/bt/common/Kconfig.in index f24dbd22f2..74b201b12a 100644 --- a/components/bt/common/Kconfig.in +++ b/components/bt/common/Kconfig.in @@ -1,6 +1,7 @@ config BT_ALARM_MAX_NUM int "Maximum number of Bluetooth alarms" default 50 + depends on (BT_BLUEDROID_ENABLED || BT_NIMBLE_ENABLED) help This option decides the maximum number of alarms which could be used by Bluetooth host. From ea463572a28d2c76704ee304789cb524febfcf9e Mon Sep 17 00:00:00 2001 From: Zhao Wei Liang Date: Wed, 26 Feb 2025 15:03:46 +0800 Subject: [PATCH 2/3] feat(ble): add a debug way to retain scene on ESP32-C6 (cherry picked from commit bc299e784cd4ffd08abd2e6727c478bec79a7a14) Co-authored-by: zwl --- components/bt/CMakeLists.txt | 19 +++++++++++++++++-- components/bt/controller/esp32c6/Kconfig.in | 6 ++++++ components/bt/controller/esp32c6/bt.c | 10 +++++++++- components/bt/controller/esp32h2/Kconfig.in | 6 ++++++ components/bt/controller/esp32h2/bt.c | 9 ++++++++- 5 files changed, 46 insertions(+), 4 deletions(-) diff --git a/components/bt/CMakeLists.txt b/components/bt/CMakeLists.txt index 568635f51f..14d14694a2 100644 --- a/components/bt/CMakeLists.txt +++ b/components/bt/CMakeLists.txt @@ -855,12 +855,27 @@ if(CONFIG_BT_ENABLED) endif() + +set(bt_priv_requires + nvs_flash + soc + esp_pm + esp_phy + esp_coex + mbedtls + esp_driver_uart + vfs + esp_ringbuf + esp_driver_spi + esp_driver_gpio + esp_gdbstub +) + idf_component_register(SRCS "${srcs}" INCLUDE_DIRS "${include_dirs}" PRIV_INCLUDE_DIRS "${priv_include_dirs}" REQUIRES esp_timer esp_wifi - PRIV_REQUIRES nvs_flash soc esp_pm esp_phy esp_coex mbedtls esp_driver_uart vfs esp_ringbuf - esp_driver_spi esp_driver_gpio + PRIV_REQUIRES "${bt_priv_requires}" LDFRAGMENTS "${ldscripts}") if(CONFIG_BT_ENABLED) diff --git a/components/bt/controller/esp32c6/Kconfig.in b/components/bt/controller/esp32c6/Kconfig.in index 77ad51cf02..fa5bcd247c 100644 --- a/components/bt/controller/esp32c6/Kconfig.in +++ b/components/bt/controller/esp32c6/Kconfig.in @@ -428,6 +428,12 @@ menu "Controller debug features" config BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED bool "When ACL disconnects abnormally, assertion processing is performed(Experimental)" default n + + config BT_LE_DEBUG_REMAIN_SCENE_ENABLED + bool "Remain scene with GDB to capture relevant status info(Experimental)" + default n + help + Retain scene with GDB to capture info, requires disabling WDT (CONFIG_ESP_INT_WDT, CONFIG_ESP_TASK_WDT_EN). 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 5af71a487b..66fcd8716c 100644 --- a/components/bt/controller/esp32c6/bt.c +++ b/components/bt/controller/esp32c6/bt.c @@ -1661,6 +1661,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_DEBUG_REMAIN_SCENE_ENABLED +#include "esp_gdbstub.h" +#endif // CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED + int IRAM_ATTR ble_capture_info_user_handler(uint8_t type, uint32_t reason) { @@ -1671,7 +1675,11 @@ ble_capture_info_user_handler(uint8_t type, uint32_t reason) for (i = 0; i < 2; i++) { esp_ble_controller_info_capture(0x010101); } - +#if CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED + uintptr_t sp; + __asm__ volatile ("mv %0, sp" : "=r" (sp)); + esp_gdbstub_panic_handler(&sp); +#endif // CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED break; #if CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED case 1: diff --git a/components/bt/controller/esp32h2/Kconfig.in b/components/bt/controller/esp32h2/Kconfig.in index 92299131fe..8b3262ef37 100644 --- a/components/bt/controller/esp32h2/Kconfig.in +++ b/components/bt/controller/esp32h2/Kconfig.in @@ -419,6 +419,12 @@ menu "Controller debug features" config BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED bool "When ACL disconnects abnormally, assertion processing is performed(Experimental)" default n + + config BT_LE_DEBUG_REMAIN_SCENE_ENABLED + bool "Remain scene with GDB to capture relevant status info(Experimental)" + default n + help + Retain scene with GDB to capture info, requires disabling WDT (CONFIG_ESP_INT_WDT, CONFIG_ESP_TASK_WDT_EN). 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 cc4220d163..cecaa97e78 100644 --- a/components/bt/controller/esp32h2/bt.c +++ b/components/bt/controller/esp32h2/bt.c @@ -1633,6 +1633,9 @@ 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_DEBUG_REMAIN_SCENE_ENABLED +#include "esp_gdbstub.h" +#endif // CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED int IRAM_ATTR ble_capture_info_user_handler(uint8_t type, uint32_t reason) @@ -1644,7 +1647,11 @@ ble_capture_info_user_handler(uint8_t type, uint32_t reason) for (i = 0; i < 2; i++) { esp_ble_controller_info_capture(0x010101); } - +#if CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED + uintptr_t sp; + __asm__ volatile ("mv %0, sp" : "=r" (sp)); + esp_gdbstub_panic_handler(&sp); +#endif // CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED break; #if CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED case 1: From 86585699a7e138764aeb6dd2eb2893d120050469 Mon Sep 17 00:00:00 2001 From: Zhao Wei Liang Date: Wed, 26 Feb 2025 15:03:49 +0800 Subject: [PATCH 3/3] feat(ble): add a debug way to retain scene on ESP32-C5 (cherry picked from commit da07b1fabe9db277ae0e1973d324b48bdd75e54f) Co-authored-by: zwl --- components/bt/controller/esp32c5/Kconfig.in | 6 ++++++ components/bt/controller/esp32c5/bt.c | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/components/bt/controller/esp32c5/Kconfig.in b/components/bt/controller/esp32c5/Kconfig.in index 79aecce76c..ac5bdcf74c 100644 --- a/components/bt/controller/esp32c5/Kconfig.in +++ b/components/bt/controller/esp32c5/Kconfig.in @@ -396,6 +396,12 @@ menu "Controller debug features" config BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED bool "When ACL disconnects abnormally, assertion processing is performed(Experimental)" default n + + config BT_LE_DEBUG_REMAIN_SCENE_ENABLED + bool "Remain scene with GDB to capture relevant status info(Experimental)" + default n + help + Retain scene with GDB to capture info, requires disabling WDT (CONFIG_ESP_INT_WDT, CONFIG_ESP_TASK_WDT_EN). endmenu config BT_LE_LL_RESOLV_LIST_SIZE diff --git a/components/bt/controller/esp32c5/bt.c b/components/bt/controller/esp32c5/bt.c index d9114ccc19..b48390edfa 100644 --- a/components/bt/controller/esp32c5/bt.c +++ b/components/bt/controller/esp32c5/bt.c @@ -1620,6 +1620,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_DEBUG_REMAIN_SCENE_ENABLED +#include "esp_gdbstub.h" +#endif // CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED + int IRAM_ATTR ble_capture_info_user_handler(uint8_t type, uint32_t reason) { @@ -1630,7 +1634,11 @@ ble_capture_info_user_handler(uint8_t type, uint32_t reason) for (i = 0; i < 2; i++) { esp_ble_controller_info_capture(0x010101); } - +#if CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED + uintptr_t sp; + __asm__ volatile ("mv %0, sp" : "=r" (sp)); + esp_gdbstub_panic_handler(&sp); +#endif // CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED break; #if CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED case 1: