Skip to content

Commit 6aa557c

Browse files
committed
Merge branch 'feat/add_save_debug_context_250226' into 'master'
Feat/add save debug context 250226 Closes BLERP-1561 and BLERP-1604 See merge request espressif/esp-idf!37281
2 parents 132444c + da07b1f commit 6aa557c

File tree

9 files changed

+65
-10
lines changed

9 files changed

+65
-10
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/Kconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ menu "Bluetooth"
8181
So this option will disable the PMP (ESP_SYSTEM_PMP_IDRAM_SPLIT)
8282

8383
menu "Common Options"
84-
visible if (BT_BLUEDROID_ENABLED || BT_NIMBLE_ENABLED)
85-
8684
source "$IDF_PATH/components/bt/common/Kconfig.in"
8785
endmenu
8886

components/bt/common/Kconfig.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
config BT_ALARM_MAX_NUM
22
int "Maximum number of Bluetooth alarms"
33
default 50
4+
depends on (BT_BLUEDROID_ENABLED || BT_NIMBLE_ENABLED)
45
help
56
This option decides the maximum number of alarms which
67
could be used by Bluetooth host.

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

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)