From f4a5108d49201512fad3ef92f84adeba55190409 Mon Sep 17 00:00:00 2001 From: Song Ruo Jing Date: Fri, 21 Nov 2025 20:39:33 +0800 Subject: [PATCH] fix(uart): fix clock deinitialization in uart_detect_bitrate_stop --- components/esp_driver_uart/src/uart.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/components/esp_driver_uart/src/uart.c b/components/esp_driver_uart/src/uart.c index 743f67f207..22b4defbfa 100644 --- a/components/esp_driver_uart/src/uart.c +++ b/components/esp_driver_uart/src/uart.c @@ -2398,12 +2398,15 @@ esp_err_t uart_detect_bitrate_stop(uart_port_t uart_num, bool deinit, uart_bitra if (deinit) { // release the port uart_release_pin(uart_num, true, true, true, true, true, true); - esp_clk_tree_enable_src(uart_context[uart_num].sclk_sel, false); + if (uart_num != CONFIG_ESP_CONSOLE_UART_NUM) { + esp_clk_tree_enable_src(uart_context[uart_num].sclk_sel, false); #if SOC_UART_SUPPORT_RTC_CLK - if (src_clk == (soc_module_clk_t)UART_SCLK_RTC) { - periph_rtc_dig_clk8m_disable(); - } + if (src_clk == (soc_module_clk_t)UART_SCLK_RTC) { + periph_rtc_dig_clk8m_disable(); + } #endif + uart_context[uart_num].sclk_sel = -1; + } uart_module_disable(uart_num); } return ret;