This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit bb88f1faffe816ee574c135a268a6fdca4c1b8b2 Author: Ricard Rosson <[email protected]> AuthorDate: Fri Nov 27 03:32:47 2026 +0000 arch/xtensa/esp32s3: Make UART0 usable when it is not the console. In a build with no serial console the HAL treats UART0 as an unused peripheral: esp_perip_clk_init() gates its clock and holds it in reset, and bootloader_console_init() connects its RX signal to a constant level in the GPIO matrix. The driver did not undo either: * esp32s3_lowputc_enable_sysclk() enabled the clock of UART1 and UART2 only, because UART0 has no entry in periph_module_t. The registers of UART0 then read as zero, and nothing was sent. * esp32s3_lowputc_config_pins() did not connect the RX signal when the pins are the IO_MUX ones, so nothing was received. Enable the clock of UART0 and release its reset in the system registers, and connect the RX signal to the RX pin. Assisted-by: Claude Code:claude-fable-5-2 Signed-off-by: Ricard Rosson <[email protected]> --- arch/xtensa/src/esp32s3/esp32s3_lowputc.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/xtensa/src/esp32s3/esp32s3_lowputc.c b/arch/xtensa/src/esp32s3/esp32s3_lowputc.c index ad90f963c94..816286aa3d1 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_lowputc.c +++ b/arch/xtensa/src/esp32s3/esp32s3_lowputc.c @@ -713,6 +713,17 @@ void esp32s3_lowputc_enable_sysclk(const struct esp32s3_uart_s *priv) { periph_module_enable(PERIPH_UART1_MODULE + (priv->id - 1)); } + else + { + /* UART0 has no entry in periph_module_t: it is normally the console + * and always clocked. With no serial console, however, + * esp_perip_clk_init() of the HAL gates its clock and holds it in + * reset as an unused peripheral, so enable it here. + */ + + modifyreg32(SYSTEM_PERIP_CLK_EN0_REG, 0, SYSTEM_UART_CLK_EN_M); + modifyreg32(SYSTEM_PERIP_RST_EN0_REG, SYSTEM_UART_RST_M, 0); + } } /**************************************************************************** @@ -899,6 +910,13 @@ void esp32s3_lowputc_config_pins(const struct esp32s3_uart_s *priv) INPUT_FUNCTION_1); esp_gpio_matrix_out(priv->rxpin, SIG_GPIO_OUT_IDX, 0, 0); + /* Take the RX signal from the pin. It is not always there: with no + * serial console bootloader_console_init() of the HAL connects the + * RX signal of UART0 to a constant level in the GPIO matrix. + */ + + esp_gpio_matrix_in(priv->rxpin, priv->rxsig, 0); + #ifdef CONFIG_SERIAL_IFLOWCONTROL if (priv->iflow) {
