CV-Bowen opened a new pull request, #22191:
URL: https://github.com/apache/nuttx/pull/22191
## Summary
Fixes and small additions to the rpmsg MTD client and server
(`drivers/mtd/rpmsgmtd.c`, `drivers/mtd/rpmsgmtd_server.c`), in the
order they were made:
- `add rpmsgmtd_unregister()`: there was no way to remove a client once
registered. It unregisters the MTD driver and the rpmsg callbacks and
frees the device.
- `wait for the server in every operation`: erase, the geometry query
and the read requests were sent with `rpmsg_send()` without waiting
for the endpoint to be bound, so an operation issued before the server
appeared failed. They now take their buffer from
`rpmsgmtd_get_tx_payload_buffer()`, which waits, like write and ioctl
already did.
- `initialize sval before nxsem_get_value()`: Coverity uninit_use.
- `run the client endpoint at RPMSG_PRIO_RT`: the client callbacks only
copy the reply and post a semaphore.
- `fix the build when CONFIG_MTD_BYTE_WRITE is disabled`:
`MTD_WRITE()` referenced `(d)->write`, which only exists with
`CONFIG_MTD_BYTE_WRITE`; it now returns `-ENOSYS` without it.
- `keep a copy of the remote cpu and path`: `rpmsgmtd_register()`
stored the caller's pointers and used them later from the rpmsg
callbacks.
- `convert the packed ioctl buffer through void *`: TASKING rejects
converting the `__unaligned` address of a packed member to an integer.
- `do not copy the ioctl argument from a NULL pointer`: UBSan "null
pointer passed as argument 2" when an ioctl with an argument size is
called with arg 0.
## Impact
- New `rpmsgmtd_unregister()` in `include/nuttx/mtd/mtd.h`.
- `MTD_WRITE()` returns `-ENOSYS` when `CONFIG_MTD_BYTE_WRITE` is
disabled instead of failing to compile.
- rpmsgmtd client callbacks run in the rx path (`RPMSG_PRIO_RT`).
- No protocol change; client and server stay compatible with the
current ones.
## 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
Every commit builds sim:rpserver, sim:rpproxy, qemu-armv8a:rpserver
(+`RPMSGMTD_SERVER`, `RAMMTD`), qemu-armv8a:rpproxy (+`RPMSGMTD`) and
sim:rpproxy without `CONFIG_MTD_BYTE_WRITE` with 0 warnings.
**Remote MTD.** sim:rpserver exports its `/dev/rammtd` and sim:rpproxy
registers it with `rpmsgmtd_register("server", "/dev/rammtd", NULL)`
(both in the in-tree configs); `CONFIG_FS_LITTLEFS=y` added to the
proxy (test only). On the proxy:
```
mkdir /mnt
mount -t littlefs -o forceformat /dev/rammtd /mnt
echo P130MTD > /mnt/a.txt
umount /mnt
mount -t littlefs /dev/rammtd /mnt
cat /mnt/a.txt
mount
rpmsg dump all
```
| | master | this PR |
|---|---|---|
| format, write, remount, read back over rpmsgmtd (2 runs) | `P130MTD`,
`/mnt type littlefs` | same |
| proxy `rpmsgmtd-/dev/rammtd` endpoint | priority=127 | priority=255 |
| sim:rpserver with `CONFIG_MTD_BYTE_WRITE` disabled |
`rpmsgmtd_server.c:275:9: error: 'struct mtd_dev_s' has no member named
'write'` | builds, 0 warnings |
Not tested: `rpmsgmtd_unregister()` (no in-tree caller); an operation
issued before the server endpoint is bound (the sim server is always up
first); the TASKING build; ioctl with arg 0 (no in-tree caller issues
one through rpmsgmtd).
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]