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

   ## Summary
   
     * Why change is necessary (fix, update, new feature)? Fix — a boot-time
       hang/reset-loop bug.
     * What functional part of the code is being changed?
       `arch/xtensa/src/esp32s3/esp32s3_serial.c`, the `CONSOLE_DEV` macro
       selection logic used by the ESP32-S3 serial driver.
     * How does the change exactly work (what will change and how)?
       When `CONFIG_ESP32S3_USBSERIAL` is enabled at the same time as a real
       UART is selected as the system console (`CONFIG_UARTx_SERIAL_CONSOLE`),
       an unconditional `#define CONSOLE_DEV g_uart_usbserial` silently
       overrides the correct earlier definition that pointed `CONSOLE_DEV` at
       the chosen UART device. `xtensa_earlyserialinit()` then calls
       `esp32s3_setup(&CONSOLE_DEV)` — a function only valid for a
       `struct esp32s3_uart_s` — on what is actually `g_uart_usbserial`, whose
       `priv` points to an unrelated `struct esp32s3_usbserial_s`. Reading
       `priv->id` off the wrong struct returns garbage, which is then used to
       compute a UART register address; the resulting access to invalid IO
       hangs the CPU until the RTC watchdog resets the board, in a loop,
       before NSH ever starts. The fix guards the USBSERIAL assignment with
       `!defined(CONSOLE_DEV)`, mirroring the pattern already used a few lines
       below in the same file for `TTYS1_DEV`/`TTYS2_DEV`.
     * Related NuttX Issue: none filed yet.
   
   ## Impact
   
     * Is new feature added? Is existing feature changed? NO — pure bug fix,
       no behavior change for any config that was working correctly before
       (the only configs affected are ones where `CONSOLE_DEV` was silently
       wrong, i.e. already broken).
     * Impact on user (will user need to adapt to change)? NO.
     * Impact on build (will build process change)? NO.
     * Impact on hardware (will arch(s) / board(s) / driver(s) change)? YES —
       fixes any ESP32-S3 board/config that enables `CONFIG_ESP32S3_USBSERIAL`
       together with a UART console (previously boot-looped).
     * Impact on documentation (is update required / provided)? NO.
     * Impact on security (any sort of implications)? NO.
     * Impact on compatibility (backward/forward/interoperability)? NO.
     * Anything else to consider or add? None.
   
   ## Testing
   
     I confirm that changes are verified on local setup and works as intended:
     * Build Host(s): Linux (x86_64), GCC via the `xtensa-esp32s3-elf`
       toolchain (esp-elf 14.2.0).
     * Target(s): xtensa, Seeed XIAO ESP32-S3 (esp32s3-xiao), custom
       out-of-tree defconfig with `CONFIG_ESP32S3_UART0=y`,
       `CONFIG_UART0_SERIAL_CONSOLE=y`, `CONFIG_ESP32S3_USBSERIAL=y`.
     * Reproduction: flash a config with a UART selected as
       `SERIAL_CONSOLE` while `CONFIG_ESP32S3_USBSERIAL` is also enabled, and
       watch the UART console — it boot-loops instead of reaching NSH.
   
     Testing logs before change:
   
     ```
     ESP-ROM:esp32s3-20210327
     Build:Mar 27 2021
     rst:0x10 (RTCWDT_RTC_RST),boot:0x9 (SPI_FAST_FLASH_BOOT)
     ...
     *** Booting NuttX ***
     dram: lma 0x00000020 vma 0x3fc8e7e0 len 0x184c   (6220)
     iram: lma 0x00001874 vma 0x40374000 len 0x8494   (33940)
     ...
     total segments stored 7
     <hang here -- nothing else is ever printed>
   
     <~8s later, resets and repeats identically, forever>
     ```
   
     Testing logs after change:
   
     ```
     nsh> uname -a
     NuttX 13.0.1-RC0 734c06c4f3-dirty Sep  3 2026 11:50:28 xtensa esp32s3-xiao
     nsh> ls /dev
     /dev:
      console
      i2c0
      mmcsd0
      null
      ttyACM0
      ttyS0
      uorb/
      usensor
      zero
     nsh>
     ```
   
   ## PR verification Self-Check
   
     * [x] This PR introduces only one functional change.
     * [x] I have updated all required description fields above.
     * [x] My PR adheres to Contributing Guidelines
           (https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md) and
           Documentation (git commit title and message, coding standard, etc).
     * [ ] My PR is still work in progress (not ready for review).
     * [x] My PR is ready for review and can be safely merged into a codebase.
   


-- 
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