From d9e28fe0880fb7766888487ad48faacd405c644b Mon Sep 17 00:00:00 2001 From: Peter Dragun Date: Mon, 16 Feb 2026 10:15:30 +0100 Subject: [PATCH 1/2] fix(esp32c5): Do not disable UART0 sclk when USB Serial/JTAG is primary console This is a workaround for rom code issue, which can cause the chip to end in infinite loop when reset is triggered from esptool/idf-monitor. This is only applicable to ESP32-C5 rev <= 1.0. Closes https://github.com/espressif/esp-idf/issues/18089 --- components/esp_system/port/soc/esp32c5/clk.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/components/esp_system/port/soc/esp32c5/clk.c b/components/esp_system/port/soc/esp32c5/clk.c index 55b80fc5219..c1691be2f87 100644 --- a/components/esp_system/port/soc/esp32c5/clk.c +++ b/components/esp_system/port/soc/esp32c5/clk.c @@ -251,5 +251,15 @@ __attribute__((weak)) void esp_perip_clk_init(void) clk_gate_config.disable_pvt_clk = true; #endif +#if defined(CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG) && CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG + /* ESP32-C5 rev <= 1.0: Do not disable UART0 sclk when USB Serial/JTAG is primary console. + * Disabling it would cause the chip to end in infinite loop on reset (workaround for rom code issue). + * See: IDFGH-17050 + */ + if (efuse_hal_chip_revision() <= 100) { + clk_gate_config.disable_uart0_clk = false; + } +#endif + periph_ll_clk_gate_set_default(rst_reason, &clk_gate_config); } From f49e195afc4edd6c36685ddc55c0f9bce0e25c5b Mon Sep 17 00:00:00 2001 From: Peter Dragun Date: Mon, 16 Feb 2026 15:51:00 +0100 Subject: [PATCH 2/2] ci: enable esp32c5 for usb_serial_jtag tests --- .../test_apps/.build-test-rules.yml | 4 ++-- .../usb_serial_jtag/pytest_usb_serial_jtag.py | 10 +++++++--- .../usb_serial_jtag_vfs/pytest_usb_serial_jtag_vfs.py | 10 +++++++--- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/components/esp_driver_usb_serial_jtag/test_apps/.build-test-rules.yml b/components/esp_driver_usb_serial_jtag/test_apps/.build-test-rules.yml index e66b8eb9e0a..daa1d1749cf 100644 --- a/components/esp_driver_usb_serial_jtag/test_apps/.build-test-rules.yml +++ b/components/esp_driver_usb_serial_jtag/test_apps/.build-test-rules.yml @@ -7,7 +7,7 @@ components/esp_driver_usb_serial_jtag/test_apps/usb_serial_jtag: temporary: true reason: p4 rev3 migration # TODO: IDF-14364 disable_test: - - if: IDF_TARGET in ["esp32c5", "esp32h4", "esp32h21"] + - if: IDF_TARGET in ["esp32h4", "esp32h21"] temporary: true reason: No runners. depends_components: @@ -24,7 +24,7 @@ components/esp_driver_usb_serial_jtag/test_apps/usb_serial_jtag_vfs: temporary: true reason: p4 rev3 migration # TODO: IDF-14364 disable_test: - - if: IDF_TARGET in ["esp32c5", "esp32h4", "esp32h21"] + - if: IDF_TARGET in ["esp32h4", "esp32h21"] temporary: true reason: No runners. depends_components: diff --git a/components/esp_driver_usb_serial_jtag/test_apps/usb_serial_jtag/pytest_usb_serial_jtag.py b/components/esp_driver_usb_serial_jtag/test_apps/usb_serial_jtag/pytest_usb_serial_jtag.py index c2309eea949..58327aed9d1 100644 --- a/components/esp_driver_usb_serial_jtag/test_apps/usb_serial_jtag/pytest_usb_serial_jtag.py +++ b/components/esp_driver_usb_serial_jtag/test_apps/usb_serial_jtag/pytest_usb_serial_jtag.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: CC0-1.0 import pytest from pytest_embedded import Dut @@ -13,7 +13,9 @@ from pytest_embedded_idf.utils import idf_parametrize ], indirect=True, ) -@idf_parametrize('target', ['esp32s3', 'esp32c3', 'esp32c6', 'esp32h2', 'esp32c61', 'esp32p4'], indirect=['target']) +@idf_parametrize( + 'target', ['esp32s3', 'esp32c3', 'esp32c6', 'esp32h2', 'esp32c61', 'esp32p4', 'esp32c5'], indirect=['target'] +) def test_usb_serial_jtag_dev(dut: Dut) -> None: # type: ignore dut.expect_exact('Press ENTER to see the list of tests') dut.write('"test print via usb_serial_jtag driver multiple times in different tasks"') @@ -35,7 +37,9 @@ def test_usb_serial_jtag_dev(dut: Dut) -> None: # type: ignore ], indirect=True, ) -@idf_parametrize('target', ['esp32s3', 'esp32c3', 'esp32c6', 'esp32h2', 'esp32c61', 'esp32p4'], indirect=['target']) +@idf_parametrize( + 'target', ['esp32s3', 'esp32c3', 'esp32c6', 'esp32h2', 'esp32c61', 'esp32p4', 'esp32c5'], indirect=['target'] +) def test_usb_serial_jtag_rom_dev(dut: Dut) -> None: # type: ignore dut.expect_exact('Press ENTER to see the list of tests') dut.write('"test rom printf work after driver installed"') diff --git a/components/esp_driver_usb_serial_jtag/test_apps/usb_serial_jtag_vfs/pytest_usb_serial_jtag_vfs.py b/components/esp_driver_usb_serial_jtag/test_apps/usb_serial_jtag_vfs/pytest_usb_serial_jtag_vfs.py index 969b81d423f..737dc801429 100644 --- a/components/esp_driver_usb_serial_jtag/test_apps/usb_serial_jtag_vfs/pytest_usb_serial_jtag_vfs.py +++ b/components/esp_driver_usb_serial_jtag/test_apps/usb_serial_jtag_vfs/pytest_usb_serial_jtag_vfs.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: CC0-1.0 import pytest from pytest_embedded import Dut @@ -13,7 +13,9 @@ from pytest_embedded_idf.utils import idf_parametrize ], indirect=True, ) -@idf_parametrize('target', ['esp32s3', 'esp32c3', 'esp32c6', 'esp32h2', 'esp32c61', 'esp32p4'], indirect=['target']) +@idf_parametrize( + 'target', ['esp32s3', 'esp32c3', 'esp32c6', 'esp32h2', 'esp32c61', 'esp32p4', 'esp32c5'], indirect=['target'] +) def test_usj_vfs_select(dut: Dut) -> None: test_message = 'test123456789!@#%^&*' @@ -33,7 +35,9 @@ def test_usj_vfs_select(dut: Dut) -> None: ], indirect=True, ) -@idf_parametrize('target', ['esp32s3', 'esp32c3', 'esp32c6', 'esp32h2', 'esp32c61', 'esp32p4'], indirect=['target']) +@idf_parametrize( + 'target', ['esp32s3', 'esp32c3', 'esp32c6', 'esp32h2', 'esp32c61', 'esp32p4', 'esp32c5'], indirect=['target'] +) def test_usj_vfs_read_return(dut: Dut) -> None: test_message = '!(@*#&(!*@&#((SDasdkjhad\nce'