From f492c499a8a3dbb4d66a83f3b3b813febfb7f4b8 Mon Sep 17 00:00:00 2001 From: Zhou Xiao Date: Thu, 13 Mar 2025 12:53:40 +0800 Subject: [PATCH] fix(ble): add feed wdts during ble log dump for ESP32-C2 (cherry picked from commit e2e8e7dce18914c9091feb578600a1427ca829fc) Co-authored-by: Zhou Xiao --- components/bt/controller/esp32c2/bt.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/components/bt/controller/esp32c2/bt.c b/components/bt/controller/esp32c2/bt.c index 198e8472b5..f3f679e238 100644 --- a/components/bt/controller/esp32c2/bt.c +++ b/components/bt/controller/esp32c2/bt.c @@ -391,11 +391,11 @@ void esp_bt_read_ctrl_log_from_flash(bool output) portENTER_CRITICAL_SAFE(&spinlock); esp_panic_handler_feed_wdts(); ble_log_async_output_dump_all(true); - stop_write = true; esp_bt_ontroller_log_deinit(); - portEXIT_CRITICAL_SAFE(&spinlock); + stop_write = true; buffer = (const uint8_t *)mapped_ptr; + esp_panic_handler_feed_wdts(); if (is_filled) { read_index = next_erase_index; } else { @@ -407,7 +407,7 @@ void esp_bt_read_ctrl_log_from_flash(bool output) while (read_index != write_index) { esp_rom_printf("%02x ", buffer[read_index]); if (print_len > max_print_len) { - vTaskDelay(2); + esp_panic_handler_feed_wdts(); print_len = 0; } @@ -415,6 +415,7 @@ void esp_bt_read_ctrl_log_from_flash(bool output) read_index = (read_index + 1) % MAX_STORAGE_SIZE; } esp_rom_printf(":DUMP_END]\r\n"); + portEXIT_CRITICAL_SAFE(&spinlock); esp_partition_munmap(mmap_handle); err = esp_bt_controller_log_init(log_output_mode); assert(err == ESP_OK); @@ -428,6 +429,9 @@ static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, b esp_bt_controller_log_storage(len, addr, end); #endif //CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE } else { + portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED; + portENTER_CRITICAL_SAFE(&spinlock); + esp_panic_handler_feed_wdts(); for (int i = 0; i < len; i++) { esp_rom_printf("%02x ", addr[i]); } @@ -435,6 +439,7 @@ static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, b if (end) { esp_rom_printf("\n"); } + portEXIT_CRITICAL_SAFE(&spinlock); } }