Skip to content

Commit bc299e7

Browse files
feat(ble): add a debug way to retain scene on ESP32-C6
1 parent 5b8ac71 commit bc299e7

File tree

5 files changed

+48
-6
lines changed

5 files changed

+48
-6
lines changed

components/bt/CMakeLists.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,12 +870,27 @@ if(CONFIG_BT_ENABLED)
870870

871871
endif()
872872

873+
874+
set(bt_priv_requires
875+
nvs_flash
876+
soc
877+
esp_pm
878+
esp_phy
879+
esp_coex
880+
mbedtls
881+
esp_driver_uart
882+
vfs
883+
esp_ringbuf
884+
esp_driver_spi
885+
esp_driver_gpio
886+
esp_gdbstub
887+
)
888+
873889
idf_component_register(SRCS "${srcs}"
874890
INCLUDE_DIRS "${include_dirs}"
875891
PRIV_INCLUDE_DIRS "${priv_include_dirs}"
876892
REQUIRES esp_timer esp_wifi
877-
PRIV_REQUIRES nvs_flash soc esp_pm esp_phy esp_coex mbedtls esp_driver_uart vfs esp_ringbuf
878-
esp_driver_spi esp_driver_gpio
893+
PRIV_REQUIRES "${bt_priv_requires}"
879894
LDFRAGMENTS "${ldscripts}")
880895

881896
if(CONFIG_BT_ENABLED)

components/bt/controller/esp32c6/Kconfig.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,12 @@ menu "Controller debug features"
428428
config BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
429429
bool "When ACL disconnects abnormally, assertion processing is performed(Experimental)"
430430
default n
431+
432+
config BT_LE_DEBUG_REMAIN_SCENE_ENABLED
433+
bool "Remain scene with GDB to capture relevant status info(Experimental)"
434+
default n
435+
help
436+
Retain scene with GDB to capture info, requires disabling WDT (CONFIG_ESP_INT_WDT, CONFIG_ESP_TASK_WDT_EN).
431437
endmenu
432438

433439
config BT_LE_LL_RESOLV_LIST_SIZE

components/bt/controller/esp32c6/bt.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,6 +1661,10 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
16611661
#endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
16621662
#endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
16631663

1664+
#if CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED
1665+
#include "esp_gdbstub.h"
1666+
#endif // CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED
1667+
16641668
int IRAM_ATTR
16651669
ble_capture_info_user_handler(uint8_t type, uint32_t reason)
16661670
{
@@ -1671,12 +1675,16 @@ ble_capture_info_user_handler(uint8_t type, uint32_t reason)
16711675
for (i = 0; i < 2; i++) {
16721676
esp_ble_controller_info_capture(0x010101);
16731677
}
1674-
1678+
#if CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED
1679+
uintptr_t sp;
1680+
__asm__ volatile ("mv %0, sp" : "=r" (sp));
1681+
esp_gdbstub_panic_handler(&sp);
1682+
#endif // CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED
16751683
break;
16761684
#if CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
16771685
case 1:
16781686
if ((reason == 0x08) || (reason == 0x3d) || (reason == 0x28)) {
1679-
osi_assert_wrapper(__LINE__,__func__, type reason);
1687+
osi_assert_wrapper(__LINE__,__func__, type, reason);
16801688
}
16811689
break;
16821690
#endif // CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED

components/bt/controller/esp32h2/Kconfig.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,12 @@ menu "Controller debug features"
419419
config BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
420420
bool "When ACL disconnects abnormally, assertion processing is performed(Experimental)"
421421
default n
422+
423+
config BT_LE_DEBUG_REMAIN_SCENE_ENABLED
424+
bool "Remain scene with GDB to capture relevant status info(Experimental)"
425+
default n
426+
help
427+
Retain scene with GDB to capture info, requires disabling WDT (CONFIG_ESP_INT_WDT, CONFIG_ESP_TASK_WDT_EN).
422428
endmenu
423429

424430
config BT_LE_LL_RESOLV_LIST_SIZE

components/bt/controller/esp32h2/bt.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,6 +1633,9 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
16331633

16341634
#endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
16351635
#endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
1636+
#if CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED
1637+
#include "esp_gdbstub.h"
1638+
#endif // CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED
16361639

16371640
int IRAM_ATTR
16381641
ble_capture_info_user_handler(uint8_t type, uint32_t reason)
@@ -1644,12 +1647,16 @@ ble_capture_info_user_handler(uint8_t type, uint32_t reason)
16441647
for (i = 0; i < 2; i++) {
16451648
esp_ble_controller_info_capture(0x010101);
16461649
}
1647-
1650+
#if CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED
1651+
uintptr_t sp;
1652+
__asm__ volatile ("mv %0, sp" : "=r" (sp));
1653+
esp_gdbstub_panic_handler(&sp);
1654+
#endif // CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED
16481655
break;
16491656
#if CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
16501657
case 1:
16511658
if ((reason == 0x08) || (reason == 0x3d) || (reason == 0x28)) {
1652-
osi_assert_wrapper(__LINE__,__func__, type reason);
1659+
osi_assert_wrapper(__LINE__,__func__, type, reason);
16531660
}
16541661
break;
16551662
#endif // CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED

0 commit comments

Comments
 (0)