mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 10:47:19 +02:00
feat(ble): support enhanced controller log capabilities on ESP32-C6 and ESP32-H2
(cherry picked from commit f598976c6b
)
Co-authored-by: zwl <zhaoweiliang@espressif.com>
This commit is contained in:
@ -890,6 +890,9 @@ if(CONFIG_BT_ENABLED)
|
|||||||
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app)
|
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app)
|
||||||
endif()
|
endif()
|
||||||
elseif(CONFIG_BT_CONTROLLER_ENABLED)
|
elseif(CONFIG_BT_CONTROLLER_ENABLED)
|
||||||
|
if(CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE)
|
||||||
|
target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=esp_panic_handler")
|
||||||
|
endif()
|
||||||
if(CONFIG_IDF_TARGET_ESP32C6)
|
if(CONFIG_IDF_TARGET_ESP32C6)
|
||||||
add_prebuilt_library(libble_app "controller/lib_${target}/${target}-bt-lib/esp32c6/libble_app.a")
|
add_prebuilt_library(libble_app "controller/lib_${target}/${target}-bt-lib/esp32c6/libble_app.a")
|
||||||
else()
|
else()
|
||||||
|
@ -381,6 +381,36 @@ config BT_LE_LOG_HCI_BUF_SIZE
|
|||||||
help
|
help
|
||||||
Configure the size of the BLE HCI LOG buffer.
|
Configure the size of the BLE HCI LOG buffer.
|
||||||
|
|
||||||
|
config BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
||||||
|
bool "Enable wrap panic handler"
|
||||||
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
Wrap esp_panic_handler to get controller logs when PC pointer exception crashes.
|
||||||
|
|
||||||
|
config BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
||||||
|
bool "Enable esp_task_wdt_isr_user_handler implementation"
|
||||||
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
Implement esp_task_wdt_isr_user_handler to get controller logs when task wdt issue is triggered.
|
||||||
|
|
||||||
|
config BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL
|
||||||
|
int "The output level of controller log"
|
||||||
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
|
range 0 5
|
||||||
|
default 1
|
||||||
|
help
|
||||||
|
The output level of controller log.
|
||||||
|
|
||||||
|
config BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH
|
||||||
|
hex "The switch of module log output"
|
||||||
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
|
range 0 0xFFFFFFFF
|
||||||
|
default 0xFFFFFFFF
|
||||||
|
help
|
||||||
|
The switch of module log output, this is an unsigned 32-bit hexadecimal value.
|
||||||
|
|
||||||
config BT_LE_LL_RESOLV_LIST_SIZE
|
config BT_LE_LL_RESOLV_LIST_SIZE
|
||||||
int "BLE LL Resolving list size"
|
int "BLE LL Resolving list size"
|
||||||
range 1 5
|
range 1 5
|
||||||
|
@ -114,6 +114,8 @@ extern int r_ble_log_deinit_async(void);
|
|||||||
extern void r_ble_log_async_select_dump_buffers(uint8_t buffers);
|
extern void r_ble_log_async_select_dump_buffers(uint8_t buffers);
|
||||||
extern void r_ble_log_async_output_dump_all(bool output);
|
extern void r_ble_log_async_output_dump_all(bool output);
|
||||||
extern void esp_panic_handler_reconfigure_wdts(uint32_t timeout_ms);
|
extern void esp_panic_handler_reconfigure_wdts(uint32_t timeout_ms);
|
||||||
|
extern int r_ble_log_ctrl_level_and_mod(uint8_t log_level, uint32_t mod_switch);
|
||||||
|
extern int r_ble_ctrl_mod_type(uint16_t mod, uint32_t mod_type_switch);
|
||||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
extern int r_ble_controller_deinit(void);
|
extern int r_ble_controller_deinit(void);
|
||||||
extern int r_ble_controller_enable(uint8_t mode);
|
extern int r_ble_controller_enable(uint8_t mode);
|
||||||
@ -253,10 +255,14 @@ esp_err_t esp_bt_controller_log_init(uint8_t log_output_mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = r_ble_log_init_async(bt_controller_log_interface, task_create, buffers, (uint32_t *)log_bufs_size);
|
ret = r_ble_log_init_async(bt_controller_log_interface, task_create, buffers, (uint32_t *)log_bufs_size);
|
||||||
|
if (ret != ESP_OK) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = r_ble_log_ctrl_level_and_mod(CONFIG_BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL, CONFIG_BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH);
|
||||||
if (ret == ESP_OK) {
|
if (ret == ESP_OK) {
|
||||||
log_is_inited = true;
|
log_is_inited = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,6 +393,22 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
|
|||||||
assert(err == ESP_OK);
|
assert(err == ESP_OK);
|
||||||
}
|
}
|
||||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||||
|
|
||||||
|
#if CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
||||||
|
void esp_task_wdt_isr_user_handler(void)
|
||||||
|
{
|
||||||
|
esp_ble_controller_log_dump_all(true);
|
||||||
|
}
|
||||||
|
#endif // CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
||||||
|
|
||||||
|
#if CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
||||||
|
void __real_esp_panic_handler(void *info);
|
||||||
|
void __wrap_esp_panic_handler (void *info)
|
||||||
|
{
|
||||||
|
esp_ble_controller_log_dump_all(true);
|
||||||
|
__real_esp_panic_handler(info);
|
||||||
|
}
|
||||||
|
#endif // CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
||||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
|
|
||||||
/* This variable tells if BLE is running */
|
/* This variable tells if BLE is running */
|
||||||
|
@ -372,6 +372,36 @@ config BT_LE_LOG_HCI_BUF_SIZE
|
|||||||
help
|
help
|
||||||
Configure the size of the BLE HCI LOG buffer.
|
Configure the size of the BLE HCI LOG buffer.
|
||||||
|
|
||||||
|
config BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
||||||
|
bool "Enable wrap panic handler"
|
||||||
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
Wrap esp_panic_handler to get controller logs when PC pointer exception crashes.
|
||||||
|
|
||||||
|
config BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
||||||
|
bool "Enable esp_task_wdt_isr_user_handler implementation"
|
||||||
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
Implement esp_task_wdt_isr_user_handler to get controller logs when task wdt issue is triggered.
|
||||||
|
|
||||||
|
config BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL
|
||||||
|
int "The output level of controller log"
|
||||||
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
|
range 0 5
|
||||||
|
default 1
|
||||||
|
help
|
||||||
|
The output level of controller log.
|
||||||
|
|
||||||
|
config BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH
|
||||||
|
hex "The switch of module log output"
|
||||||
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
|
range 0 0xFFFFFFFF
|
||||||
|
default 0xFFFFFFFF
|
||||||
|
help
|
||||||
|
The switch of module log output, this is an unsigned 32-bit hexadecimal value.
|
||||||
|
|
||||||
config BT_LE_LL_RESOLV_LIST_SIZE
|
config BT_LE_LL_RESOLV_LIST_SIZE
|
||||||
int "BLE LL Resolving list size"
|
int "BLE LL Resolving list size"
|
||||||
range 1 5
|
range 1 5
|
||||||
|
@ -108,6 +108,8 @@ extern int r_ble_log_deinit_async(void);
|
|||||||
extern void r_ble_log_async_select_dump_buffers(uint8_t buffers);
|
extern void r_ble_log_async_select_dump_buffers(uint8_t buffers);
|
||||||
extern void r_ble_log_async_output_dump_all(bool output);
|
extern void r_ble_log_async_output_dump_all(bool output);
|
||||||
extern void esp_panic_handler_reconfigure_wdts(uint32_t timeout_ms);
|
extern void esp_panic_handler_reconfigure_wdts(uint32_t timeout_ms);
|
||||||
|
extern int r_ble_log_ctrl_level_and_mod(uint8_t log_level, uint32_t mod_switch);
|
||||||
|
extern int r_ble_ctrl_mod_type(uint16_t mod, uint32_t mod_type_switch);
|
||||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
extern int r_ble_controller_deinit(void);
|
extern int r_ble_controller_deinit(void);
|
||||||
extern int r_ble_controller_enable(uint8_t mode);
|
extern int r_ble_controller_enable(uint8_t mode);
|
||||||
@ -250,6 +252,11 @@ esp_err_t esp_bt_controller_log_init(uint8_t log_output_mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = r_ble_log_init_async(bt_controller_log_interface, task_create, buffers, (uint32_t *)log_bufs_size);
|
ret = r_ble_log_init_async(bt_controller_log_interface, task_create, buffers, (uint32_t *)log_bufs_size);
|
||||||
|
if (ret != ESP_OK) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = r_ble_log_ctrl_level_and_mod(CONFIG_BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL, CONFIG_BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH);
|
||||||
if (ret == ESP_OK) {
|
if (ret == ESP_OK) {
|
||||||
log_is_inited = true;
|
log_is_inited = true;
|
||||||
}
|
}
|
||||||
@ -383,6 +390,22 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
|
|||||||
assert(err == ESP_OK);
|
assert(err == ESP_OK);
|
||||||
}
|
}
|
||||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||||
|
|
||||||
|
#if CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
||||||
|
void esp_task_wdt_isr_user_handler(void)
|
||||||
|
{
|
||||||
|
esp_ble_controller_log_dump_all(true);
|
||||||
|
}
|
||||||
|
#endif // CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
||||||
|
|
||||||
|
#if CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
||||||
|
void __real_esp_panic_handler(void *info);
|
||||||
|
void __wrap_esp_panic_handler (void *info)
|
||||||
|
{
|
||||||
|
esp_ble_controller_log_dump_all(true);
|
||||||
|
__real_esp_panic_handler(info);
|
||||||
|
}
|
||||||
|
#endif // CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
||||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
|
|
||||||
/* This variable tells if BLE is running */
|
/* This variable tells if BLE is running */
|
||||||
@ -917,6 +940,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
|||||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "controller_sleep_init failed %d", ret);
|
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "controller_sleep_init failed %d", ret);
|
||||||
goto free_controller;
|
goto free_controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_read_mac((uint8_t *)mac, ESP_MAC_BT));
|
ESP_ERROR_CHECK(esp_read_mac((uint8_t *)mac, ESP_MAC_BT));
|
||||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Bluetooth MAC: %02x:%02x:%02x:%02x:%02x:%02x",
|
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Bluetooth MAC: %02x:%02x:%02x:%02x:%02x:%02x",
|
||||||
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||||
@ -1027,6 +1051,7 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
|||||||
#if CONFIG_SW_COEXIST_ENABLE
|
#if CONFIG_SW_COEXIST_ENABLE
|
||||||
coex_enable();
|
coex_enable();
|
||||||
#endif // CONFIG_SW_COEXIST_ENABLE
|
#endif // CONFIG_SW_COEXIST_ENABLE
|
||||||
|
|
||||||
#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||||
r_ble_ll_scan_start_time_init_compensation(500);
|
r_ble_ll_scan_start_time_init_compensation(500);
|
||||||
r_priv_sdk_config_insert_proc_time_set(500);
|
r_priv_sdk_config_insert_proc_time_set(500);
|
||||||
|
Reference in New Issue
Block a user