Skip to content

Commit 9b00d28

Browse files
feat(ble): support enhanced controller log capabilities on ESP32-C5
1 parent bbcb4a2 commit 9b00d28

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

components/bt/controller/esp32c5/Kconfig.in

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,36 @@ config BT_LE_LOG_HCI_BUF_SIZE
392392
help
393393
Configure the size of the BLE HCI LOG buffer.
394394

395+
config BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
396+
bool "Enable wrap panic handler"
397+
depends on BT_LE_CONTROLLER_LOG_ENABLED
398+
default n
399+
help
400+
Wrap esp_panic_handler to get controller logs when PC pointer exception crashes.
401+
402+
config BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
403+
bool "Enable esp_task_wdt_isr_user_handler implementation"
404+
depends on BT_LE_CONTROLLER_LOG_ENABLED
405+
default n
406+
help
407+
Implement esp_task_wdt_isr_user_handler to get controller logs when task wdt issue is triggered.
408+
409+
config BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL
410+
int "The output level of controller log"
411+
depends on BT_LE_CONTROLLER_LOG_ENABLED
412+
range 0 5
413+
default 1
414+
help
415+
The output level of controller log.
416+
417+
config BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH
418+
hex "The switch of module log output"
419+
depends on BT_LE_CONTROLLER_LOG_ENABLED
420+
range 0 0xFFFFFFFF
421+
default 0xFFFFFFFF
422+
help
423+
The switch of module log output, this is an unsigned 32-bit hexadecimal value.
424+
395425
config BT_LE_LL_RESOLV_LIST_SIZE
396426
int "BLE LL Resolving list size"
397427
range 1 5

components/bt/controller/esp32c5/bt.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ extern int r_ble_log_deinit_async(void);
117117
extern void r_ble_log_async_select_dump_buffers(uint8_t buffers);
118118
extern void r_ble_log_async_output_dump_all(bool output);
119119
extern void esp_panic_handler_reconfigure_wdts(uint32_t timeout_ms);
120+
extern int r_ble_log_ctrl_level_and_mod(uint8_t log_level, uint32_t mod_switch);
121+
extern int r_ble_ctrl_mod_type(uint16_t mod, uint32_t mod_type_switch);
120122
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
121123
extern int r_ble_controller_deinit(void);
122124
extern int r_ble_controller_enable(uint8_t mode);
@@ -266,10 +268,14 @@ esp_err_t esp_bt_controller_log_init(uint8_t log_output_mode)
266268
}
267269

268270
ret = r_ble_log_init_async(bt_controller_log_interface, task_create, buffers, (uint32_t *)log_bufs_size);
271+
if (ret != ESP_OK) {
272+
return ret;
273+
}
274+
275+
ret = r_ble_log_ctrl_level_and_mod(CONFIG_BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL, CONFIG_BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH);
269276
if (ret == ESP_OK) {
270277
log_is_inited = true;
271278
}
272-
273279
return ret;
274280
}
275281

@@ -403,6 +409,22 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
403409
assert(err == ESP_OK);
404410
}
405411
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
412+
413+
#if CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
414+
void esp_task_wdt_isr_user_handler(void)
415+
{
416+
esp_ble_controller_log_dump_all(true);
417+
}
418+
#endif // CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
419+
420+
#if CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
421+
void __real_esp_panic_handler(void *info);
422+
void __wrap_esp_panic_handler (void *info)
423+
{
424+
esp_ble_controller_log_dump_all(true);
425+
__real_esp_panic_handler(info);
426+
}
427+
#endif // CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
406428
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
407429

408430
/* This variable tells if BLE is running */

0 commit comments

Comments
 (0)