yangsong8-a1 opened a new pull request, #21786:
URL: https://github.com/apache/nuttx/pull/21786
## Summary
The serial gdbstub used to take over the UART: it skipped
`register_driver()` for CONFIG_SERIAL_GDBSTUB_PATH and replaced
`ops->receive` to catch Ctrl-C. That only works for UARTs that receive in
interrupt mode, because a DMA UART never calls `receive()`.
- `uart_register()` now always registers the tty first and then calls
`uart_gdbstub_register()`.
- gdbstub opens the tty and attaches with `file_poll()`. The poll callback
starts `gdb_process()` when data arrives. `uart_gdbstub_receive()` first
takes the bytes already in the RX buffer, then reads the UART directly.
This works with interrupt and DMA UARTs.
- The tty is opened in `uart_gdbstub_attach()`, not in
`uart_gdbstub_register()`. A failed open no longer fails
`uart_register()`, and without AUTO_ATTACH the tty is only opened when
the panic handler attaches. This helps devices that cannot be opened at
registration time, such as USB CDC/ACM before enumeration.
## Impact
Only builds with CONFIG_SERIAL_GDBSTUB. The gdbstub port now also shows up
as a normal tty in /dev. gdbstub keeps it open, and nothing else should
read from it.
## Testing
Ubuntu 22.04, gcc 13.1, aarch64-none-elf-gcc, arm-none-eabi-gcc 10.3.
- qemu-armv8a:gdbstub, qemu-armv7a:gdbstub, mps3-an547:gdbstub,
stm32f429i-disco:gdbstub build with no new warnings.
- sim:nsh with LIB_GDBSTUB + SERIAL_GDBSTUB on /dev/ttySIM0 (host PTY),
with SIM_UART_DMA off and on. A host script talks GDB remote protocol
on the PTY:
| Case | Before | This PR |
|---|---|---|
| auto, interrupt UART: Ctrl-C gives `T05`, `?` gives `S00` | PASS | PASS |
| auto, DMA UART: Ctrl-C gives `T05` | FAIL (no stop packet) | PASS |
| wait, interrupt UART: boot waits for gdb | not run | PASS |
| wait, DMA UART: boot waits for gdb | not run | PASS |
| panic: "Press Y/y" prompt times out after 3 s | not run | PASS |
| panic, answer `y`: enters panic gdbstub mode | not run | PASS |
--
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]