ricardgb opened a new pull request, #22463:
URL: https://github.com/apache/nuttx/pull/22463

   ## Summary
   
   Fixes #22462.
   
   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,
   so UART0 as an ordinary port (`/dev/ttyS0`) sent and received nothing.
   
   Two commits, both in `arch/xtensa/src/esp32s3/esp32s3_lowputc.c`:
   
   1. Style only: the blank line after the declarations in four functions. 
`checkpatch.sh` reports
      these four errors on the file as it is on master, so the fix alone would 
not pass the check.
   2. The fix:
      * `esp32s3_lowputc_enable_sysclk()`: for UART0, which has no entry in 
`periph_module_t`, set
        `SYSTEM_UART_CLK_EN` and clear `SYSTEM_UART_RST` in the system 
registers.
      * `esp32s3_lowputc_config_pins()`: in the IO_MUX case connect the RX 
signal to the RX pin
        (`esp_gpio_matrix_in()`).
   
   **This can not be tested on master alone.** A build with 
`CONFIG_NO_SERIAL_CONSOLE` needs the
   HAL fix of espressif/esp-hal-3rdparty#21 (open) to compile; the tests below 
use that branch
   through `ESP_HAL_3RDPARTY_URL` / `ESP_HAL_3RDPARTY_VERSION`. The PR does not 
depend on it to
   build, and can wait for it if the reviewers prefer.
   
   ## Impact
   
   ESP32-S3 only. With UART0 as the console both changes write what is already 
there (the clock is
   on, the reset released, and the RX signal comes from the same pin), so no 
change is expected;
   tested, see below. No change for UART1 and UART2, nor for UART0 on other 
pins than the IO_MUX
   ones (that case already connects the RX signal).
   
   ## Testing
   
   Host: Ubuntu, GCC 13 / xtensa-esp32s3-elf-gcc. Master `a8bb89bf680`, HAL 
`c657ca9`
   (espressif/esp-hal-3rdparty#21).
   
   **esp32s3-devkit:nsh** with `CONFIG_NO_SERIAL_CONSOLE` and the reproducer of 
the issue as the
   init task, on an ESP32-S3 (rev v0.2) with a USB-serial converter on UART0, 
115200:
   
   | | After the messages of the ROM | Answer to `hello 123` |
   |---|---|---|
   | master + HAL fix | nothing | nothing |
   | master + HAL fix + only the clock change | `UART0 is open, send a line` | 
nothing |
   | master + HAL fix + this PR | `UART0 is open, send a line` | `got: hello 
123` |
   
   **Custom ESP32-S3 board**, SLIP on UART0 at 921600, no console: master 
resets in a loop at the
   first open of UART0 (divide by zero in `esp32s3_lowputc_baud()`); with this 
PR ping 100 of 100
   with 900 bytes, HTTP 30 of 30, telnet session over the link.
   
   **UART0 as the console** (`esp32s3-devkit:nsh` unchanged, with this PR, same 
board): the nsh
   prompt comes up, `uname -a` and `ls /dev` answer as usual.
   
   `./tools/checkpatch.sh -g HEAD~2..HEAD`: all checks pass.
   
   *Disclosure: this change was prepared with the help of an AI agent (Claude 
Code, Anthropic); it
   was tested on real hardware and human-reviewed.*
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to