feat(ble): add a debug way to retain scene on ESP32-C6

This commit is contained in:
zwl 2025-02-26 11:00:12 +08:00
parent 5b8ac71ace
commit bc299e784c
5 changed files with 48 additions and 6 deletions

View File

@ -870,12 +870,27 @@ if(CONFIG_BT_ENABLED)
endif() 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}" idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "${include_dirs}" INCLUDE_DIRS "${include_dirs}"
PRIV_INCLUDE_DIRS "${priv_include_dirs}" PRIV_INCLUDE_DIRS "${priv_include_dirs}"
REQUIRES esp_timer esp_wifi REQUIRES esp_timer esp_wifi
PRIV_REQUIRES nvs_flash soc esp_pm esp_phy esp_coex mbedtls esp_driver_uart vfs esp_ringbuf PRIV_REQUIRES "${bt_priv_requires}"
esp_driver_spi esp_driver_gpio
LDFRAGMENTS "${ldscripts}") LDFRAGMENTS "${ldscripts}")
if(CONFIG_BT_ENABLED) if(CONFIG_BT_ENABLED)

View File

@ -428,6 +428,12 @@ menu "Controller debug features"
config BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED config BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
bool "When ACL disconnects abnormally, assertion processing is performed(Experimental)" bool "When ACL disconnects abnormally, assertion processing is performed(Experimental)"
default n 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 endmenu
config BT_LE_LL_RESOLV_LIST_SIZE config BT_LE_LL_RESOLV_LIST_SIZE

View File

@ -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_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
#endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED) #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 int IRAM_ATTR
ble_capture_info_user_handler(uint8_t type, uint32_t reason) ble_capture_info_user_handler(uint8_t type, uint32_t reason)
{ {
@ -1671,12 +1675,16 @@ ble_capture_info_user_handler(uint8_t type, uint32_t reason)
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
esp_ble_controller_info_capture(0x010101); 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; break;
#if CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED #if CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
case 1: case 1:
if ((reason == 0x08) || (reason == 0x3d) || (reason == 0x28)) { if ((reason == 0x08) || (reason == 0x3d) || (reason == 0x28)) {
osi_assert_wrapper(__LINE__,__func__, type reason); osi_assert_wrapper(__LINE__,__func__, type, reason);
} }
break; break;
#endif // CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED #endif // CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED

View File

@ -419,6 +419,12 @@ menu "Controller debug features"
config BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED config BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
bool "When ACL disconnects abnormally, assertion processing is performed(Experimental)" bool "When ACL disconnects abnormally, assertion processing is performed(Experimental)"
default n 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 endmenu
config BT_LE_LL_RESOLV_LIST_SIZE config BT_LE_LL_RESOLV_LIST_SIZE

View File

@ -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_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
#endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED) #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 int IRAM_ATTR
ble_capture_info_user_handler(uint8_t type, uint32_t reason) 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)
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
esp_ble_controller_info_capture(0x010101); 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; break;
#if CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED #if CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED
case 1: case 1:
if ((reason == 0x08) || (reason == 0x3d) || (reason == 0x28)) { if ((reason == 0x08) || (reason == 0x3d) || (reason == 0x28)) {
osi_assert_wrapper(__LINE__,__func__, type reason); osi_assert_wrapper(__LINE__,__func__, type, reason);
} }
break; break;
#endif // CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED #endif // CONFIG_BT_LE_ASSERT_WHEN_ABNORMAL_DISCONN_ENABLED