Skip to content

Commit da07b1f

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

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

components/bt/controller/esp32c5/Kconfig.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,12 @@ menu "Controller debug features"
396396
config BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
397397
bool "When ACL disconnects abnormally, assertion processing is performed(Experimental)"
398398
default n
399+
400+
config BT_LE_DEBUG_REMAIN_SCENE_ENABLED
401+
bool "Remain scene with GDB to capture relevant status info(Experimental)"
402+
default n
403+
help
404+
Retain scene with GDB to capture info, requires disabling WDT (CONFIG_ESP_INT_WDT, CONFIG_ESP_TASK_WDT_EN).
399405
endmenu
400406

401407
config BT_LE_LL_RESOLV_LIST_SIZE

components/bt/controller/esp32c5/bt.c

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

1643+
#if CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED
1644+
#include "esp_gdbstub.h"
1645+
#endif // CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED
1646+
16431647
int IRAM_ATTR
16441648
ble_capture_info_user_handler(uint8_t type, uint32_t reason)
16451649
{
@@ -1650,12 +1654,16 @@ ble_capture_info_user_handler(uint8_t type, uint32_t reason)
16501654
for (i = 0; i < 2; i++) {
16511655
esp_ble_controller_info_capture(0x010101);
16521656
}
1653-
1657+
#if CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED
1658+
uintptr_t sp;
1659+
__asm__ volatile ("mv %0, sp" : "=r" (sp));
1660+
esp_gdbstub_panic_handler(&sp);
1661+
#endif // CONFIG_BT_LE_DEBUG_REMAIN_SCENE_ENABLED
16541662
break;
16551663
#if CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
16561664
case 1:
16571665
if ((reason == 0x08) || (reason == 0x3d) || (reason == 0x28)) {
1658-
osi_assert_wrapper(__LINE__,__func__, type reason);
1666+
osi_assert_wrapper(__LINE__,__func__, type, reason);
16591667
}
16601668
break;
16611669
#endif // CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED

0 commit comments

Comments
 (0)