diff --git a/components/bootloader_support/src/bootloader_console.c b/components/bootloader_support/src/bootloader_console.c index 62f22784c3..69b126fa55 100644 --- a/components/bootloader_support/src/bootloader_console.c +++ b/components/bootloader_support/src/bootloader_console.c @@ -44,12 +44,7 @@ void bootloader_console_init(void) { const int uart_num = CONFIG_ESP_CONSOLE_UART_NUM; -#if !ESP_ROM_SUPPORT_MULTIPLE_UART - /* esp_rom_install_channel_put is not available unless multiple UARTs are supported */ esp_rom_install_uart_printf(); -#else - esp_rom_install_channel_putc(1, esp_rom_uart_putc); -#endif // Wait for UART FIFO to be empty. esp_rom_uart_tx_wait_idle(0); diff --git a/components/esp_rom/esp32c3/esp_rom_caps.h b/components/esp_rom/esp32c3/esp_rom_caps.h index 977d73fc90..034a5c19d9 100644 --- a/components/esp_rom/esp32c3/esp_rom_caps.h +++ b/components/esp_rom/esp32c3/esp_rom_caps.h @@ -22,3 +22,4 @@ #define ESP_ROM_HAS_RETARGETABLE_LOCKING (1) // ROM was built with retargetable locking #define ESP_ROM_HAS_ERASE_0_REGION_BUG (1) // ROM has esp_flash_erase_region(size=0) bug #define ESP_ROM_NEEDS_SWSETUP_WORKAROUND (1) // ROM uses 32-bit time_t. A workaround is required to prevent printf functions from crashing +#define ESP_ROM_HAS_ETS_PRINTF_BUG (1) // ROM has ets_printf bug when disable the ROM log either by eFuse or RTC storage register diff --git a/components/esp_rom/esp32h2/esp_rom_caps.h b/components/esp_rom/esp32h2/esp_rom_caps.h index 7a210f1a53..5d1c583d35 100644 --- a/components/esp_rom/esp32h2/esp_rom_caps.h +++ b/components/esp_rom/esp32h2/esp_rom_caps.h @@ -21,3 +21,4 @@ #define ESP_ROM_USB_SERIAL_DEVICE_NUM (3) // UART uses USB_SERIAL_JTAG port in ROM. #define ESP_ROM_HAS_RETARGETABLE_LOCKING (1) // ROM was built with retargetable locking #define ESP_ROM_HAS_ERASE_0_REGION_BUG (1) // ROM has esp_flash_erase_region(size=0) bug +#define ESP_ROM_HAS_ETS_PRINTF_BUG (1) // ROM has ets_printf bug when disable the ROM log either by eFuse or RTC storage register diff --git a/components/esp_rom/esp32s3/esp_rom_caps.h b/components/esp_rom/esp32s3/esp_rom_caps.h index 65847c4064..32ca7ffd35 100644 --- a/components/esp_rom/esp32s3/esp_rom_caps.h +++ b/components/esp_rom/esp32s3/esp_rom_caps.h @@ -23,3 +23,4 @@ #define ESP_ROM_USB_SERIAL_DEVICE_NUM (4) // The serial port ID (UART, USB, ...) of USB_SERIAL_JTAG in the ROM. #define ESP_ROM_HAS_ERASE_0_REGION_BUG (1) // ROM has esp_flash_erase_region(size=0) bug #define ESP_ROM_NEEDS_SWSETUP_WORKAROUND (1) // ROM uses 32-bit time_t. A workaround is required to prevent printf functions from crashing +#define ESP_ROM_HAS_ETS_PRINTF_BUG (1) // ROM has ets_printf bug when disable the ROM log either by eFuse or RTC storage register diff --git a/components/esp_rom/patches/esp_rom_sys.c b/components/esp_rom/patches/esp_rom_sys.c index 4b87d2d081..30b5d8c34a 100644 --- a/components/esp_rom/patches/esp_rom_sys.c +++ b/components/esp_rom/patches/esp_rom_sys.c @@ -16,7 +16,7 @@ #include #include "esp_attr.h" -#include "sdkconfig.h" +#include "esp_rom_caps.h" IRAM_ATTR void esp_rom_install_channel_putc(int channel, void (*putc)(char c)) { @@ -34,14 +34,16 @@ IRAM_ATTR void esp_rom_install_channel_putc(int channel, void (*putc)(char c)) } } -#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2 +#if ESP_ROM_HAS_ETS_PRINTF_BUG IRAM_ATTR void esp_rom_install_uart_printf(void) { extern void ets_install_uart_printf(void); extern bool g_uart_print; + extern bool g_usb_print; // If ROM log is disabled permanently via eFuse or temporarily via RTC storage register, // this ROM symbol will be set to false, and cause ``esp_rom_printf`` can't work on esp-idf side. g_uart_print = true; + g_usb_print = true; ets_install_uart_printf(); } #endif