Skip to content

Commit 8e5aee2

Browse files
feat(ble): support enhanced controller log capabilities on ESP32-C5
1 parent 3c6236d commit 8e5aee2

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
@@ -349,6 +349,36 @@ config BT_LE_LOG_HCI_BUF_SIZE
349349
help
350350
Configure the size of the BLE HCI LOG buffer.
351351

352+
config BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
353+
bool "Enable wrap panic handler"
354+
depends on BT_LE_CONTROLLER_LOG_ENABLED
355+
default n
356+
help
357+
Wrap esp_panic_handler to get controller logs when PC pointer exception crashes.
358+
359+
config BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
360+
bool "Enable esp_task_wdt_isr_user_handler implementation"
361+
depends on BT_LE_CONTROLLER_LOG_ENABLED
362+
default n
363+
help
364+
Implement esp_task_wdt_isr_user_handler to get controller logs when task wdt issue is triggered.
365+
366+
config BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL
367+
int "The output level of controller log"
368+
depends on BT_LE_CONTROLLER_LOG_ENABLED
369+
range 0 5
370+
default 1
371+
help
372+
The output level of controller log.
373+
374+
config BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH
375+
hex "The switch of module log output"
376+
depends on BT_LE_CONTROLLER_LOG_ENABLED
377+
range 0 0xFFFFFFFF
378+
default 0xFFFFFFFF
379+
help
380+
The switch of module log output, this is an unsigned 32-bit hexadecimal value.
381+
352382
config BT_LE_LL_RESOLV_LIST_SIZE
353383
int "BLE LL Resolving list size"
354384
range 1 5

components/bt/controller/esp32c5/bt.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ extern int r_ble_log_deinit_async(void);
110110
extern void r_ble_log_async_select_dump_buffers(uint8_t buffers);
111111
extern void r_ble_log_async_output_dump_all(bool output);
112112
extern void esp_panic_handler_reconfigure_wdts(uint32_t timeout_ms);
113+
extern int r_ble_log_ctrl_level_and_mod(uint8_t log_level, uint32_t mod_switch);
114+
extern int r_ble_ctrl_mod_type(uint16_t mod, uint32_t mod_type_switch);
113115
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
114116
extern int r_ble_controller_deinit(void);
115117
extern int r_ble_controller_enable(uint8_t mode);
@@ -249,10 +251,14 @@ esp_err_t esp_bt_controller_log_init(uint8_t log_output_mode)
249251
}
250252

251253
ret = r_ble_log_init_async(bt_controller_log_interface, task_create, buffers, (uint32_t *)log_bufs_size);
254+
if (ret != ESP_OK) {
255+
return ret;
256+
}
257+
258+
ret = r_ble_log_ctrl_level_and_mod(CONFIG_BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL, CONFIG_BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH);
252259
if (ret == ESP_OK) {
253260
log_is_inited = true;
254261
}
255-
256262
return ret;
257263
}
258264

@@ -383,6 +389,22 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
383389
assert(err == ESP_OK);
384390
}
385391
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
392+
393+
#if CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
394+
void esp_task_wdt_isr_user_handler(void)
395+
{
396+
esp_ble_controller_log_dump_all(true);
397+
}
398+
#endif // CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
399+
400+
#if CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
401+
void __real_esp_panic_handler(void *info);
402+
void __wrap_esp_panic_handler (void *info)
403+
{
404+
esp_ble_controller_log_dump_all(true);
405+
__real_esp_panic_handler(info);
406+
}
407+
#endif // CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
386408
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
387409

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

0 commit comments

Comments
 (0)