CV-Bowen opened a new pull request, #22021:
URL: https://github.com/apache/nuttx/pull/22021
## Summary
Three fixes to the rpmsg tty (`drivers/serial/uart_rpmsg.c`):
- `handle the uart_register() failures`: `uart_rpmsg_init()` ignored the
result of `uart_register()`. With a name that is already taken it
returned 0 and left its rpmsg callback registered, so the device
created a second endpoint with no tty behind it. Return the error and
undo the registration; unregister the tty when only the console
registration fails.
- `flush the tx buffer once the endpoint is bound`: data written before
the endpoint is bound (for example the nsh prompt) stayed in the tx
buffer until the next write, so `cu` showed no prompt on connect.
- `keep a copy of the device and cpu names`: the driver stored the
caller's string pointers.
## Impact
`uart_rpmsg_init()` can now return an error where it returned 0 before.
No other change.
## Testing
Host: Ubuntu 22.04.5 LTS x86_64, QEMU version 10.2.1, sim: cc (Ubuntu
13.1.0-8ubuntu1~22.04) 13.1.0, qemu-armv8a: aarch64-none-elf-gcc (Arm GNU
Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205
sim:rpserver + sim:rpproxy: the proxy's nsh console is a uart_rpmsg tty,
reached from the server with `cu /dev/ttyproxy`; every proxy command of
the baseline below goes through it.
Error path: a test-only patch (not in this PR) makes the server register
the same rpmsg tty twice in `rpmsg_serialinit()`:
```c
uart_rpmsg_init("proxy", "proxy", 4096, false);
syslog(LOG_EMERG, "DUPTEST second uart_rpmsg_init ret=%d\n",
uart_rpmsg_init("proxy", "proxy", 4096, false));
```
| | master | this PR |
|---|---|---|
| second `uart_rpmsg_init()` | returns 0 | returns -17 (`-EEXIST`) |
| `rpmsg dump all`, endpoints named `rpmsg-ttyproxy` | 2: the bound one and
an unbound one (`dest=4294967295`) | 1 |
Prompt on connect: boot both, run `cu /dev/ttyproxy` on the server and
wait 5 s without pressing Enter (test-only script driving the two sim
processes):
| | master | this PR |
|---|---|---|
| proxy nsh prompt shown after `cu /dev/ttyproxy` (3 runs) | no, no, no |
yes, yes, yes |
<details><summary>master</summary>
```
[server] DUPTEST second uart_rpmsg_init ret=0
[server] ept rpmsg-ttyproxy 0xe882de80: addr=1025 dest=1026 refcnt=1
priority=127 priv=0xe882ddb0
[server] ept rpmsg-ttyproxy 0xe8830020: addr=1026 dest=4294967295
refcnt=1 priority=127 priv=0xe882ff50
```
</details>
<details><summary>this PR</summary>
```
[server] DUPTEST second uart_rpmsg_init ret=-17
[server] ept rpmsg-ttyproxy 0xe4f17e80: addr=1025 dest=1026 refcnt=1
priority=127 priv=0xe4f17db0
```
</details>
No regression in rpmsg: sim:rpserver/rpproxy and
qemu-armv8a:rpserver/rpproxy boot and pass the fixed rpmsg cases (dump, ping,
rpmsgfs; 15/15). qemu-armv8a was built with LIBC_ENVPATH and BINFMT_CHECKEXEC
disabled, which current master needs for nxinit to start nsh there; unrelated
to this change.
--
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]