diff --git a/components/bootloader_support/src/bootloader_console.c b/components/bootloader_support/src/bootloader_console.c index 18cf6ffa15..b7d6d42a6e 100644 --- a/components/bootloader_support/src/bootloader_console.c +++ b/components/bootloader_support/src/bootloader_console.c @@ -95,7 +95,7 @@ void bootloader_console_init(void) #endif esp_rom_uart_usb_acm_init(s_usb_cdc_buf, sizeof(s_usb_cdc_buf)); - esp_rom_uart_set_as_console(ESP_ROM_UART_USB); + esp_rom_uart_set_as_console(ESP_ROM_USB_OTG_NUM); esp_rom_install_channel_putc(1, bootloader_console_write_char_usb); } #endif //CONFIG_ESP_CONSOLE_USB_CDC diff --git a/components/esp_rom/esp32s2/Kconfig.soc_caps.in b/components/esp_rom/esp32s2/Kconfig.soc_caps.in index 6abec76432..dfc6803d27 100644 --- a/components/esp_rom/esp32s2/Kconfig.soc_caps.in +++ b/components/esp_rom/esp32s2/Kconfig.soc_caps.in @@ -26,3 +26,7 @@ config ESP_ROM_HAS_REGI2C_BUG config ESP_ROM_HAS_NEWLIB_NANO_FORMAT bool default y + +config ESP_ROM_USB_OTG_NUM + int + default 3 diff --git a/components/esp_rom/esp32s2/esp_rom_caps.h b/components/esp_rom/esp32s2/esp_rom_caps.h index 4e01c0d44f..f95ce45e7a 100644 --- a/components/esp_rom/esp32s2/esp_rom_caps.h +++ b/components/esp_rom/esp32s2/esp_rom_caps.h @@ -12,3 +12,4 @@ #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_REGI2C_BUG (1) // ROM has the regi2c bug #define ESP_ROM_HAS_NEWLIB_NANO_FORMAT (1) // ROM has the newlib nano version of formatting functions +#define ESP_ROM_USB_OTG_NUM (3) // The serial port ID (UART, USB, ...) of USB_OTG CDC in the ROM. diff --git a/components/esp_rom/esp32s3/Kconfig.soc_caps.in b/components/esp_rom/esp32s3/Kconfig.soc_caps.in index 5216a3d2e0..5733b5ad16 100644 --- a/components/esp_rom/esp32s3/Kconfig.soc_caps.in +++ b/components/esp_rom/esp32s3/Kconfig.soc_caps.in @@ -27,6 +27,10 @@ config ESP_ROM_HAS_RETARGETABLE_LOCKING bool default y +config ESP_ROM_USB_OTG_NUM + int + default 3 + config ESP_ROM_USB_SERIAL_DEVICE_NUM int default 4 diff --git a/components/esp_rom/esp32s3/esp_rom_caps.h b/components/esp_rom/esp32s3/esp_rom_caps.h index 682f37b464..b7e56c3c80 100644 --- a/components/esp_rom/esp32s3/esp_rom_caps.h +++ b/components/esp_rom/esp32s3/esp_rom_caps.h @@ -12,6 +12,7 @@ #define ESP_ROM_HAS_JPEG_DECODE (1) // ROM has JPEG decode library #define ESP_ROM_UART_CLK_IS_XTAL (1) // UART clock source is selected to XTAL in ROM #define ESP_ROM_HAS_RETARGETABLE_LOCKING (1) // ROM was built with retargetable locking +#define ESP_ROM_USB_OTG_NUM (3) // The serial port ID (UART, USB, ...) of USB_OTG CDC in the ROM. #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_GET_CLK_FREQ (1) // Get clk frequency with rom function `ets_get_cpu_frequency` diff --git a/components/esp_system/port/soc/esp32s2/usb_console.c b/components/esp_system/port/soc/esp32s2/usb_console.c index 16a6360762..c2a5783ce9 100644 --- a/components/esp_system/port/soc/esp32s2/usb_console.c +++ b/components/esp_system/port/soc/esp32s2/usb_console.c @@ -27,6 +27,7 @@ #include "hal/soc_hal.h" #include "esp_rom_uart.h" #include "esp_rom_sys.h" +#include "esp_rom_caps.h" #include "esp32s2/rom/usb/usb_dc.h" #include "esp32s2/rom/usb/cdc_acm.h" #include "esp32s2/rom/usb/usb_dfu.h" @@ -288,7 +289,8 @@ esp_err_t esp_usb_console_init(void) #ifdef CONFIG_ESP_CONSOLE_USB_CDC_SUPPORT_ETS_PRINTF /* Install esp_rom_printf handler */ - ets_install_putc1(&esp_usb_console_write_char); + esp_rom_uart_set_as_console(ESP_ROM_USB_OTG_NUM); + esp_rom_install_channel_putc(1, &esp_usb_console_write_char); #endif // CONFIG_ESP_CONSOLE_USB_CDC_SUPPORT_ETS_PRINTF return ESP_OK;