diff --git a/components/esp_rom/CMakeLists.txt b/components/esp_rom/CMakeLists.txt index a3dd7ddf0c..d02e827c9b 100644 --- a/components/esp_rom/CMakeLists.txt +++ b/components/esp_rom/CMakeLists.txt @@ -75,6 +75,10 @@ if(CONFIG_ESP_ROM_HAS_CACHE_WRITEBACK_BUG) list(APPEND sources "patches/esp_rom_cache_writeback_esp32s3.S") endif() +if(CONFIG_ESP_ROM_NO_USB_SERIAL_OUTPUT_API) + list(APPEND sources "patches/esp_rom_usb_serial.c") +endif() + idf_component_register(SRCS ${sources} INCLUDE_DIRS ${include_dirs} PRIV_REQUIRES ${private_required_comp} diff --git a/components/esp_rom/esp32c2/Kconfig.soc_caps.in b/components/esp_rom/esp32c2/Kconfig.soc_caps.in index b2813b59ee..ff2127ca41 100644 --- a/components/esp_rom/esp32c2/Kconfig.soc_caps.in +++ b/components/esp_rom/esp32c2/Kconfig.soc_caps.in @@ -98,3 +98,7 @@ config ESP_ROM_HAS_VPRINTF_FUNC config ESP_ROM_HAS_OUTPUT_PUTC_FUNC bool default y + +config ESP_ROM_CONSOLE_OUTPUT_SECONDARY + bool + default y diff --git a/components/esp_rom/esp32c2/esp_rom_caps.h b/components/esp_rom/esp32c2/esp_rom_caps.h index 7bdaad7f69..b0753579ba 100644 --- a/components/esp_rom/esp32c2/esp_rom_caps.h +++ b/components/esp_rom/esp32c2/esp_rom_caps.h @@ -30,3 +30,4 @@ #define ESP_ROM_HAS_VERSION (1) // ROM has version/eco information #define ESP_ROM_HAS_VPRINTF_FUNC (1) // ROM has ets_vprintf #define ESP_ROM_HAS_OUTPUT_PUTC_FUNC (1) // ROM has esp_rom_output_putc (or ets_write_char_uart) +#define ESP_ROM_CONSOLE_OUTPUT_SECONDARY (1) // The console output functions will also output to the USB-serial secondary console diff --git a/components/esp_rom/esp32c3/Kconfig.soc_caps.in b/components/esp_rom/esp32c3/Kconfig.soc_caps.in index 8ddb541ea2..9bb1b5dbe0 100644 --- a/components/esp_rom/esp32c3/Kconfig.soc_caps.in +++ b/components/esp_rom/esp32c3/Kconfig.soc_caps.in @@ -94,3 +94,7 @@ config ESP_ROM_HAS_VERSION config ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB bool default y + +config ESP_ROM_CONSOLE_OUTPUT_SECONDARY + bool + default y diff --git a/components/esp_rom/esp32c3/esp_rom_caps.h b/components/esp_rom/esp32c3/esp_rom_caps.h index 47e4d236ab..68247f19c0 100644 --- a/components/esp_rom/esp32c3/esp_rom_caps.h +++ b/components/esp_rom/esp32c3/esp_rom_caps.h @@ -29,3 +29,4 @@ #define ESP_ROM_USB_OTG_NUM (-1) // No USB_OTG CDC in the ROM, set -1 for Kconfig usage. #define ESP_ROM_HAS_VERSION (1) // ROM has version/eco information #define ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB (1) // ROM supports the HP core to jump to the RTC memory to execute stub code after waking up from deepsleep. +#define ESP_ROM_CONSOLE_OUTPUT_SECONDARY (1) // The console output functions will also output to the USB-serial secondary console diff --git a/components/esp_rom/esp32c5/ld/esp32c5.rom.api.ld b/components/esp_rom/esp32c5/ld/esp32c5.rom.api.ld index 421134e7c2..8a17b836b3 100644 --- a/components/esp_rom/esp32c5/ld/esp32c5.rom.api.ld +++ b/components/esp_rom/esp32c5/ld/esp32c5.rom.api.ld @@ -31,6 +31,8 @@ PROVIDE ( esp_rom_uart_rx_string = UartRxString ); PROVIDE ( esp_rom_uart_set_as_console = uart_tx_switch ); PROVIDE ( esp_rom_uart_putc = ets_write_char_uart ); +PROVIDE ( esp_rom_usb_serial_putc = uart_tx_one_char3 ); + PROVIDE ( esp_rom_output_flush_tx = uart_tx_flush ); PROVIDE ( esp_rom_output_tx_one_char = uart_tx_one_char ); PROVIDE ( esp_rom_output_tx_wait_idle = uart_tx_wait_idle ); diff --git a/components/esp_rom/esp32c6/Kconfig.soc_caps.in b/components/esp_rom/esp32c6/Kconfig.soc_caps.in index 2e06155d09..b902f21855 100644 --- a/components/esp_rom/esp32c6/Kconfig.soc_caps.in +++ b/components/esp_rom/esp32c6/Kconfig.soc_caps.in @@ -110,3 +110,7 @@ config ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB config ESP_ROM_HAS_OUTPUT_PUTC_FUNC bool default y + +config ESP_ROM_NO_USB_SERIAL_OUTPUT_API + bool + default y diff --git a/components/esp_rom/esp32c6/esp_rom_caps.h b/components/esp_rom/esp32c6/esp_rom_caps.h index 1f98c7d2e8..c3a7470d7c 100644 --- a/components/esp_rom/esp32c6/esp_rom_caps.h +++ b/components/esp_rom/esp32c6/esp_rom_caps.h @@ -33,3 +33,4 @@ #define ESP_ROM_HAS_VERSION (1) // ROM has version/eco information #define ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB (1) // ROM supports the HP core to jump to the RTC memory to execute stub code after waking up from deepsleep. #define ESP_ROM_HAS_OUTPUT_PUTC_FUNC (1) // ROM has esp_rom_output_putc (or ets_write_char_uart) +#define ESP_ROM_NO_USB_SERIAL_OUTPUT_API (1) // ROM does not export the usb-serial-jtag write char function diff --git a/components/esp_rom/esp32c6/include/esp32c6/rom/efuse.h b/components/esp_rom/esp32c6/include/esp32c6/rom/efuse.h index 5854c3eb8a..d56b53dcc3 100644 --- a/components/esp_rom/esp32c6/include/esp32c6/rom/efuse.h +++ b/components/esp_rom/esp32c6/include/esp32c6/rom/efuse.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -272,6 +272,16 @@ int ets_jtag_enable_temporarily(const uint8_t *jtag_hmac_key, ets_efuse_block_t */ unsigned char esp_crc8(unsigned char const *p, unsigned int len); +/** + * @brief Read if usb print in ROM disabled by efuse + * + * + * @return + * - 0 for enable. + * - 1 for disable. + */ + uint32_t ets_efuse_usb_print_is_disabled(void); + /** * @} */ diff --git a/components/esp_rom/esp32c61/ld/esp32c61.rom.api.ld b/components/esp_rom/esp32c61/ld/esp32c61.rom.api.ld index 39cad62fcc..5189b24fa8 100644 --- a/components/esp_rom/esp32c61/ld/esp32c61.rom.api.ld +++ b/components/esp_rom/esp32c61/ld/esp32c61.rom.api.ld @@ -29,6 +29,8 @@ PROVIDE ( esp_rom_uart_rx_string = UartRxString ); PROVIDE ( esp_rom_uart_set_as_console = uart_tx_switch ); PROVIDE ( esp_rom_uart_putc = ets_write_char_uart ); +PROVIDE ( esp_rom_usb_serial_putc = uart_tx_one_char3 ); + PROVIDE ( esp_rom_output_flush_tx = uart_tx_flush ); PROVIDE ( esp_rom_output_tx_one_char = uart_tx_one_char ); PROVIDE ( esp_rom_output_tx_wait_idle = uart_tx_wait_idle ); diff --git a/components/esp_rom/esp32h2/Kconfig.soc_caps.in b/components/esp_rom/esp32h2/Kconfig.soc_caps.in index 237d488cad..502615e0e4 100644 --- a/components/esp_rom/esp32h2/Kconfig.soc_caps.in +++ b/components/esp_rom/esp32h2/Kconfig.soc_caps.in @@ -102,3 +102,7 @@ config ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB config ESP_ROM_HAS_OUTPUT_PUTC_FUNC bool default y + +config ESP_ROM_NO_USB_SERIAL_OUTPUT_API + bool + default y diff --git a/components/esp_rom/esp32h2/esp_rom_caps.h b/components/esp_rom/esp32h2/esp_rom_caps.h index 3d5a49dcea..84356d1ab2 100644 --- a/components/esp_rom/esp32h2/esp_rom_caps.h +++ b/components/esp_rom/esp32h2/esp_rom_caps.h @@ -31,3 +31,4 @@ #define ESP_ROM_HAS_VERSION (1) // ROM has version/eco information #define ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB (1) // ROM supports the HP core to jump to the RTC memory to execute stub code after waking up from deepsleep. #define ESP_ROM_HAS_OUTPUT_PUTC_FUNC (1) // ROM has esp_rom_output_putc (or ets_write_char_uart) +#define ESP_ROM_NO_USB_SERIAL_OUTPUT_API (1) // ROM does not export the usb-serial-jtag write char function diff --git a/components/esp_rom/esp32h2/include/esp32h2/rom/efuse.h b/components/esp_rom/esp32h2/include/esp32h2/rom/efuse.h index fbd1721211..7f4a566d9f 100644 --- a/components/esp_rom/esp32h2/include/esp32h2/rom/efuse.h +++ b/components/esp_rom/esp32h2/include/esp32h2/rom/efuse.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -273,6 +273,17 @@ int ets_jtag_enable_temporarily(const uint8_t *jtag_hmac_key, ets_efuse_block_t */ unsigned char esp_crc8(unsigned char const *p, unsigned int len); +/** + * @brief Read if usb print in ROM disabled by efuse + * + * + * @return + * - 0 for enable. + * - 1 for disable. + */ + uint32_t ets_efuse_usb_print_is_disabled(void); + + /** * @} */ diff --git a/components/esp_rom/esp32h21/ld/esp32h21.rom.api.ld b/components/esp_rom/esp32h21/ld/esp32h21.rom.api.ld index 31fced02bc..1a69c9e2e8 100644 --- a/components/esp_rom/esp32h21/ld/esp32h21.rom.api.ld +++ b/components/esp_rom/esp32h21/ld/esp32h21.rom.api.ld @@ -29,6 +29,8 @@ PROVIDE ( esp_rom_uart_rx_string = UartRxString ); PROVIDE ( esp_rom_uart_set_as_console = uart_tx_switch ); PROVIDE ( esp_rom_uart_putc = ets_write_char_uart ); +PROVIDE ( esp_rom_usb_serial_putc = uart_tx_one_char3 ); + PROVIDE ( esp_rom_output_flush_tx = uart_tx_flush ); PROVIDE ( esp_rom_output_tx_one_char = uart_tx_one_char ); PROVIDE ( esp_rom_output_tx_wait_idle = uart_tx_wait_idle ); diff --git a/components/esp_rom/esp32h4/ld/esp32h4.rom.api.ld b/components/esp_rom/esp32h4/ld/esp32h4.rom.api.ld index 3073e2ea14..43060b09f6 100644 --- a/components/esp_rom/esp32h4/ld/esp32h4.rom.api.ld +++ b/components/esp_rom/esp32h4/ld/esp32h4.rom.api.ld @@ -31,6 +31,8 @@ PROVIDE ( esp_rom_uart_rx_string = UartRxString ); PROVIDE ( esp_rom_uart_set_as_console = uart_tx_switch ); PROVIDE ( esp_rom_uart_putc = ets_write_char_uart ); +PROVIDE ( esp_rom_usb_serial_putc = uart_tx_one_char3 ); + PROVIDE ( esp_rom_output_flush_tx = uart_tx_flush ); PROVIDE ( esp_rom_output_tx_one_char = uart_tx_one_char ); PROVIDE ( esp_rom_output_tx_wait_idle = uart_tx_wait_idle ); diff --git a/components/esp_rom/esp32p4/ld/esp32p4.rom.api.ld b/components/esp_rom/esp32p4/ld/esp32p4.rom.api.ld index 1c006e38b5..77409b3198 100644 --- a/components/esp_rom/esp32p4/ld/esp32p4.rom.api.ld +++ b/components/esp_rom/esp32p4/ld/esp32p4.rom.api.ld @@ -31,6 +31,8 @@ PROVIDE ( esp_rom_uart_rx_string = UartRxString ); PROVIDE ( esp_rom_uart_set_as_console = uart_tx_switch ); PROVIDE ( esp_rom_uart_putc = ets_write_char_uart ); +PROVIDE ( esp_rom_usb_serial_putc = uart_tx_one_char3 ); + PROVIDE ( esp_rom_output_flush_tx = uart_tx_flush ); PROVIDE ( esp_rom_output_tx_one_char = uart_tx_one_char ); PROVIDE ( esp_rom_output_tx_wait_idle = uart_tx_wait_idle ); diff --git a/components/esp_rom/esp32s2/Kconfig.soc_caps.in b/components/esp_rom/esp32s2/Kconfig.soc_caps.in index 5fb2f1c99d..a4dc4de268 100644 --- a/components/esp_rom/esp32s2/Kconfig.soc_caps.in +++ b/components/esp_rom/esp32s2/Kconfig.soc_caps.in @@ -66,3 +66,7 @@ config ESP_ROM_HAS_OUTPUT_TO_CHANNELS_FUNC config ESP_ROM_HAS_OUTPUT_PUTC_FUNC bool default y + +config ESP_ROM_CONSOLE_OUTPUT_SECONDARY + bool + default y diff --git a/components/esp_rom/esp32s2/esp_rom_caps.h b/components/esp_rom/esp32s2/esp_rom_caps.h index 9608e5354b..c89f9c128c 100644 --- a/components/esp_rom/esp32s2/esp_rom_caps.h +++ b/components/esp_rom/esp32s2/esp_rom_caps.h @@ -22,3 +22,4 @@ #define ESP_ROM_HAS_VPRINTF_FUNC (1) // ROM has ets_vprintf #define ESP_ROM_HAS_OUTPUT_TO_CHANNELS_FUNC (1) // ROM has ets_write_char, alias is esp_rom_output_to_channels #define ESP_ROM_HAS_OUTPUT_PUTC_FUNC (1) // ROM has esp_rom_output_putc (or ets_write_char_uart) +#define ESP_ROM_CONSOLE_OUTPUT_SECONDARY (1) // The console output functions will also output to the USB-serial secondary console diff --git a/components/esp_rom/esp32s3/Kconfig.soc_caps.in b/components/esp_rom/esp32s3/Kconfig.soc_caps.in index d0ac6abc7f..00bef5ab69 100644 --- a/components/esp_rom/esp32s3/Kconfig.soc_caps.in +++ b/components/esp_rom/esp32s3/Kconfig.soc_caps.in @@ -114,3 +114,7 @@ config ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB config ESP_ROM_HAS_OUTPUT_PUTC_FUNC bool default y + +config ESP_ROM_CONSOLE_OUTPUT_SECONDARY + bool + default y diff --git a/components/esp_rom/esp32s3/esp_rom_caps.h b/components/esp_rom/esp32s3/esp_rom_caps.h index 4b5b14fbfc..f91b21a535 100644 --- a/components/esp_rom/esp32s3/esp_rom_caps.h +++ b/components/esp_rom/esp32s3/esp_rom_caps.h @@ -34,3 +34,4 @@ #define ESP_ROM_HAS_VERSION (1) // ROM has version/eco information #define ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB (1) // ROM supports the HP core to jump to the RTC memory to execute stub code after waking up from deepsleep. #define ESP_ROM_HAS_OUTPUT_PUTC_FUNC (1) // ROM has esp_rom_output_putc (or ets_write_char_uart) +#define ESP_ROM_CONSOLE_OUTPUT_SECONDARY (1) // The console output functions will also output to the USB-serial secondary console diff --git a/components/esp_rom/include/esp_rom_usb_serial.h b/components/esp_rom/include/esp_rom_usb_serial.h new file mode 100644 index 0000000000..84f59dc7d9 --- /dev/null +++ b/components/esp_rom/include/esp_rom_usb_serial.h @@ -0,0 +1,21 @@ +/* + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Output a char over usb-serial if printing has not been disabled + * + * @param c the char to output + */ +void esp_rom_usb_serial_putc(char c); + +#ifdef __cplusplus +} +#endif diff --git a/components/esp_rom/patches/esp_rom_usb_serial.c b/components/esp_rom/patches/esp_rom_usb_serial.c new file mode 100644 index 0000000000..74893bc936 --- /dev/null +++ b/components/esp_rom/patches/esp_rom_usb_serial.c @@ -0,0 +1,23 @@ +/* + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include "esp_rom_usb_serial.h" +#include +#include "rom/ets_sys.h" +#include "rom/efuse.h" + +extern ETS_STATUS usb_serial_device_tx_one_char(uint8_t TxChar); +extern void usb_serial_device_tx_flush(void); + +void esp_rom_usb_serial_putc(char c) +{ + uint32_t print_enabled = !ets_efuse_usb_print_is_disabled(); + if (print_enabled) { + usb_serial_device_tx_one_char(c); + if (c == '\n') { + usb_serial_device_tx_flush(); + } + } +} diff --git a/components/esp_system/CMakeLists.txt b/components/esp_system/CMakeLists.txt index af54c5d2a6..c94e9145b2 100644 --- a/components/esp_system/CMakeLists.txt +++ b/components/esp_system/CMakeLists.txt @@ -31,6 +31,7 @@ else() list(APPEND srcs "crosscore_int.c" "esp_ipc.c" "esp_err.c" + "esp_system_console.c" "freertos_hooks.c" "int_wdt.c" "panic.c" diff --git a/components/esp_system/esp_system_console.c b/components/esp_system/esp_system_console.c new file mode 100644 index 0000000000..d2c80081db --- /dev/null +++ b/components/esp_system/esp_system_console.c @@ -0,0 +1,18 @@ +/* + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include "esp_system_console.h" +#include "sdkconfig.h" +#include "esp_rom_uart.h" +#include "esp_rom_usb_serial.h" +#include "esp_rom_caps.h" + +void esp_system_console_put_char(char c) +{ + esp_rom_output_tx_one_char(c); +#if CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG && !ESP_ROM_CONSOLE_OUTPUT_SECONDARY + esp_rom_usb_serial_putc(c); +#endif // CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG && !ESP_ROM_CONSOLE_OUTPUT_SECONDARY +} diff --git a/components/esp_system/include/esp_system_console.h b/components/esp_system/include/esp_system_console.h new file mode 100644 index 0000000000..979d740eac --- /dev/null +++ b/components/esp_system/include/esp_system_console.h @@ -0,0 +1,21 @@ +/* + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Outputs a char to the configured primary and secondary console + * + * @param c char to output + */ +void esp_system_console_put_char(char c); + +#ifdef __cplusplus +} +#endif diff --git a/components/esp_system/test_apps/.build-test-rules.yml b/components/esp_system/test_apps/.build-test-rules.yml index 8b85daa297..d68503725d 100644 --- a/components/esp_system/test_apps/.build-test-rules.yml +++ b/components/esp_system/test_apps/.build-test-rules.yml @@ -8,6 +8,7 @@ components/esp_system/test_apps/console: disable: - if: CONFIG_NAME == "serial_jtag_only" and SOC_USB_SERIAL_JTAG_SUPPORTED != 1 - if: CONFIG_NAME == "serial_jtag_only_no_vfs" and SOC_USB_SERIAL_JTAG_SUPPORTED != 1 + - if: CONFIG_NAME == "console_no_vfs" and SOC_USB_SERIAL_JTAG_SUPPORTED != 1 disable_test: - if: CONFIG_NAME == "simple" and IDF_TARGET != "esp32" diff --git a/components/esp_system/test_apps/console/pytest_esp_system_console_tests.py b/components/esp_system/test_apps/console/pytest_esp_system_console_tests.py index e7506c0da8..a02b40fedb 100644 --- a/components/esp_system/test_apps/console/pytest_esp_system_console_tests.py +++ b/components/esp_system/test_apps/console/pytest_esp_system_console_tests.py @@ -19,7 +19,9 @@ JTAG_SERIAL_MARKS = [ pytest.mark.esp32s3, pytest.mark.esp32c2, pytest.mark.esp32c3, + pytest.mark.esp32c5, pytest.mark.esp32c6, + pytest.mark.esp32c61, pytest.mark.esp32h2, ] @@ -56,6 +58,18 @@ def test_esp_system_console_only_serial_jtag_no_vfs(dut: Dut) -> None: dut.expect('Hello World') +@pytest.mark.usb_serial_jtag +@idf_parametrize('config', ['console_no_vfs'], indirect=['config']) +@idf_parametrize('flash_port', ['/dev/serial_ports/ttyUSB-esp32'], indirect=['flash_port']) +@idf_parametrize('port', ['/dev/serial_ports/ttyACM-esp32'], indirect=['port']) +@idf_parametrize( + 'target', ['esp32c2', 'esp32c3', 'esp32c5', 'esp32c6', 'esp32c61', 'esp32h2', 'esp32s3'], indirect=['target'] +) +def test_esp_system_console_secondary_serial_jtag(dut: Dut) -> None: + dut.expect('2nd stage bootloader') + dut.expect('Hello World') + + @pytest.mark.generic @idf_parametrize('config', ['simple'], indirect=['config']) @idf_parametrize('target', ['supported_targets'], indirect=['target']) diff --git a/components/esp_system/test_apps/console/sdkconfig.ci.console_no_vfs b/components/esp_system/test_apps/console/sdkconfig.ci.console_no_vfs new file mode 100644 index 0000000000..73a54fb96e --- /dev/null +++ b/components/esp_system/test_apps/console/sdkconfig.ci.console_no_vfs @@ -0,0 +1,3 @@ +CONFIG_VFS_SUPPORT_IO=n +CONFIG_ESP_CONSOLE_UART_DEFAULT=y +CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG=y diff --git a/components/newlib/src/reent_syscalls.c b/components/newlib/src/reent_syscalls.c index f6eb75cb03..72f3a4ec18 100644 --- a/components/newlib/src/reent_syscalls.c +++ b/components/newlib/src/reent_syscalls.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -15,6 +15,7 @@ #include #include "sdkconfig.h" #include "esp_rom_uart.h" +#include "esp_system_console.h" static int syscall_not_implemented(struct _reent *r, ...) { @@ -34,9 +35,9 @@ ssize_t _write_r_console(struct _reent *r, int fd, const void * data, size_t siz if (fd == STDOUT_FILENO || fd == STDERR_FILENO) { for (size_t i = 0; i < size; ++i) { if (cdata[i] == '\n') { - esp_rom_output_tx_one_char('\r'); + esp_system_console_put_char('\r'); } - esp_rom_output_tx_one_char(cdata[i]); + esp_system_console_put_char(cdata[i]); } return size; } diff --git a/components/unity/unity_port_esp32.c b/components/unity/unity_port_esp32.c index dc812f61ff..42a93fa3e0 100644 --- a/components/unity/unity_port_esp32.c +++ b/components/unity/unity_port_esp32.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2016-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2016-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -9,6 +9,7 @@ #include "sdkconfig.h" #include "esp_cpu.h" #include "esp_rom_uart.h" +#include "esp_system_console.h" #include "esp_private/esp_clk.h" static uint32_t s_test_start, s_test_stop; @@ -16,11 +17,11 @@ static uint32_t s_test_start, s_test_stop; void unity_putc(int c) { if (c == '\n') { - esp_rom_output_tx_one_char('\r'); - esp_rom_output_tx_one_char('\n'); + esp_system_console_put_char('\r'); + esp_system_console_put_char('\n'); } else if (c == '\r') { } else { - esp_rom_output_tx_one_char(c); + esp_system_console_put_char(c); } }