From b2d1c34a38fd2729294911c3b588ac689d4617f4 Mon Sep 17 00:00:00 2001 From: Chip Weinberger Date: Sat, 22 Oct 2022 17:13:00 -0700 Subject: [PATCH] [Panic] also print to secondary USB Serial/JTAG Console --- components/esp_system/panic.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/components/esp_system/panic.c b/components/esp_system/panic.c index 57c07fc9e110..8622a640ce71 100644 --- a/components/esp_system/panic.c +++ b/components/esp_system/panic.c @@ -55,7 +55,7 @@ #include "esp_gdbstub.h" #endif -#if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG +#if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG || CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG #include "hal/usb_serial_jtag_ll.h" #endif @@ -73,7 +73,7 @@ static wdt_hal_context_t rtc_wdt_ctx = {.inst = WDT_RWDT, .rwdt_dev = &RTCCNTL}; #if CONFIG_ESP_CONSOLE_UART static uart_hal_context_t s_panic_uart = { .dev = CONFIG_ESP_CONSOLE_UART_NUM == 0 ? &UART0 :&UART1 }; -void panic_print_char(const char c) +static void panic_print_char_uart(const char c) { uint32_t sz = 0; while (!uart_hal_get_txfifo_len(&s_panic_uart)); @@ -83,21 +83,21 @@ void panic_print_char(const char c) #if CONFIG_ESP_CONSOLE_USB_CDC -void panic_print_char(const char c) +static void panic_print_char_usb_cdc(const char c) { esp_usb_console_write_buf(&c, 1); /* result ignored */ } #endif // CONFIG_ESP_CONSOLE_USB_CDC -#if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG +#if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG || CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG //Timeout; if there's no host listening, the txfifo won't ever //be writable after the first packet. #define USBSERIAL_TIMEOUT_MAX_US 50000 static int s_usbserial_timeout = 0; -void panic_print_char(const char c) +static void panic_print_char_usb_serial_jtag(const char c) { while (!usb_serial_jtag_ll_txfifo_writable() && s_usbserial_timeout < (USBSERIAL_TIMEOUT_MAX_US / 100)) { esp_rom_delay_us(100); @@ -108,15 +108,21 @@ void panic_print_char(const char c) s_usbserial_timeout = 0; } } -#endif //CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG +#endif //CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG || CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG -#if CONFIG_ESP_CONSOLE_NONE void panic_print_char(const char c) { - /* no-op */ +#if CONFIG_ESP_CONSOLE_UART + panic_print_char_uart(c); +#endif +#if CONFIG_ESP_CONSOLE_USB_CDC + panic_print_char_usb_cdc(c); +#endif +#if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG || CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG + panic_print_char_usb_serial_jtag(c); +#endif } -#endif // CONFIG_ESP_CONSOLE_NONE void panic_print_str(const char *str) {