Skip to content

drivers/rptun: refactor rptun to decoupling the rptun and rpmsg virtio, make rptun can work with any virtio devices#17816

Merged
GUIDINGLI merged 38 commits intoapache:masterfrom
CV-Bowen:rptun-refactor
Jan 19, 2026
Merged

drivers/rptun: refactor rptun to decoupling the rptun and rpmsg virtio, make rptun can work with any virtio devices#17816
GUIDINGLI merged 38 commits intoapache:masterfrom
CV-Bowen:rptun-refactor

Conversation

@CV-Bowen
Copy link
Contributor

@CV-Bowen CV-Bowen commented Jan 9, 2026

Summary

This PR represents a comprehensive refactoring and modernization of the NuttX RPTUN (Remote Processor Tunnel) and RPMSG framework, introducing a clean separation between remoteproc, virtio, and RPMSG layers while adding virtio/vhost device support and improving cross-platform compatibility.

Bofore this PR

image Rptun has two important features:
  • remoteproc: manage remote processor's life cycle;
  • rpmsg virtio: rpmsg virtio transport layer, use the share memory and cross-core interrupts to implement the rpmsg communication;

And the virtio drivers can only work with the virtio mmio/pci transport layer so it can only work in the virtualization environment.

After this PR

image Decoupling the remoteproc and rpmsg virtio in rptun:
  • Now the rptun is a pure virtio remoteproc transport layer and this remoteproc transport layer can work with all the virtio/vhost devices instead only rpmsg virtio devices;
  • The rpmsg virtio now is a standalone virtio/vhost drivers so it can work with any virtio transport layer.

Based on this PR, we implemented cross-core communication for VirtIO Devices and can achieve better performance in cross-core communication compared with the rpmsg based communication.

Major Architectural Changes:

RPTUN Framework Refactoring (~935 lines refactored, net -143 lines):

Removed RPMSG virtio device from RPTUN core, positioning RPTUN purely as remoteproc and remoteproc_virtio transport layer
Removed power management code to simplify architecture (-139 lines)
Added debug configuration macros and Kconfig options (+50 lines)
Optimized code size by calling rpmsg_virtio_probe() directly in RPTUN

RPMSG Virtio Common Implementation (+701 lines):

Added standalone rpmsg_virtio.c providing common RPMSG virtio implementation
New public API in include/nuttx/rpmsg/rpmsg_virtio.h
Enables RPMSG virtio devices to exist as independent virtio/vhost drivers

Virtio/Vhost RPMSG Device Support (+272 lines):

Added virtio-rpmsg and vhost-rpmsg device drivers
Enables RPMSG communication over standard virtio bus
Fixed vhost-rng compile errors and CMake typos

OpenAMP Integration Enhancements:

Added mm_priv field to struct virtio_device for memory management
Enhanced remoteproc virtio to support multiple virtio device types
Added virtio_alloc_buf() for shared memory allocation in RPMSG virtio
Synchronized virtio RPMSG config with Linux standards
Improved CMake support for OpenAMP header inclusion

Multi-Architecture RPTUN Port (+89 insertions, -26 deletions):

Ported all chip-specific RPTUN drivers to new framework:
ARM: mx8mp, nrf53, stm32h7
RISC-V: k230, qemu-rv
Simulator: sim_rptun, sim_rpmsg_virtio
Other: rptun_ivshmem, rptun_bmp
Updated resource tables to use fw_rsc_carveout for shared memory

Simulator Reliability Improvements:

Fixed shared memory initialization race condition
Added host_kill() API to properly terminate proxy cores
Moved rptun_boot() to work queue to prevent deadlocks
Removed unnecessary command initialization

Configuration Updates (+16 lines):

Refreshed sim/qemu RPMSG configs for new framework:
boards/sim/sim/sim/configs/{rpproxy,rpserver}
boards/arm/qemu/qemu-armv7a/configs/{rpproxy,rpserver}
boards/arm64/qemu/qemu-armv8a/configs/{rpproxy,rpserver}

Benefits:

Clear separation between remoteproc, virtio, and RPMSG layers

Impact

All boards that use the rptun framework

Testing

qemu-armv7a:rpserver and rpproxy
qemu-armv8a:rpserver and rpproxy
sim:rpserver and rpproxy
nucleo-h745zi:nsh_cm7_rptun and nsh_cm4_rptun

qemu-armv8a test log:

qemu-system-aarch64 -cpu cortex-a53 -nographic \
-machine virt,virtualization=on,gic-version=3 \
-chardev stdio,id=con,mux=on -serial chardev:con \
-object memory-backend-file,discard-data=on,id=shmmem-shmem0,mem-path=/dev/shm/my_shmem0,size=4194304,share=yes \
-device ivshmem-plain,id=shmem0,memdev=shmmem-shmem0,addr=0xb \
-device virtio-serial-device,bus=virtio-mmio-bus.0 \
-chardev socket,path=/tmp/rpmsg_port_uart_socket,server=on,wait=off,id=foo \
-device virtconsole,chardev=foo \
-mon chardev=con,mode=readline -kernel ./nuttx/cmake_out/v8a_server/nuttx \
-gdb tcp::7775
[    0.000000] [ 0] [  INFO] [server] pci_register_rptun_ivshmem_driver: Register ivshmem driver, id=0, cpuname=proxy, master=1
[    0.000000] [ 3] [  INFO] [server] pci_scan_bus: pci_scan_bus for bus 0
[    0.000000] [ 3] [  INFO] [server] pci_scan_bus: class = 00000600, hdr_type = 00000000
[    0.000000] [ 3] [  INFO] [server] pci_scan_bus: 00:00 [1b36:0008]
[    0.000000] [ 3] [  INFO] [server] pci_setup_device: pbar0 set bad mask
[    0.000000] [ 3] [  INFO] [server] pci_setup_device: pbar1 set bad mask
[    0.000000] [ 3] [  INFO] [server] pci_setup_device: pbar2 set bad mask
[    0.000000] [ 3] [  INFO] [server] pci_setup_device: pbar3 set bad mask
[    0.000000] [ 3] [  INFO] [server] pci_setup_device: pbar4 set bad mask
[    0.000000] [ 3] [  INFO] [server] pci_setup_device: pbar5 set bad mask
[    0.000000] [ 3] [  INFO] [server] pci_scan_bus: class = 00000200, hdr_type = 00000000
[    0.000000] [ 3] [  INFO] [server] pci_scan_bus: 00:08 [1af4:1000]
[    0.000000] [ 3] [  INFO] [server] pci_setup_device: pbar0: mask64=fffffffe 32bytes
[    0.000000] [ 3] [  INFO] [server] pci_setup_device: pbar1: mask64=fffffff0 4096bytes
[    0.000000] [ 3] [  INFO] [server] pci_setup_device: pbar2 set bad mask
[    0.000000] [ 3] [  INFO] [server] pci_setup_device: pbar3 set bad mask
[    0.000000] [ 3] [  INFO] [server] pci_setup_device: pbar4: mask64=fffffffffffffff0 16384bytes
[    0.000000] [ 3] [  INFO] [server] pci_scan_bus: class = 00000500, hdr_type = 00000000
[    0.000000] [ 3] [  INFO] [server] pci_scan_bus: 00:58 [1af4:1110]
[    0.000000] [ 3] [  INFO] [server] pci_setup_device: pbar0: mask64=fffffff0 256bytes
[    0.000000] [ 3] [  INFO] [server] pci_setup_device: pbar1 set bad mask
[    0.000000] [ 3] [  INFO] [server] pci_setup_device: pbar2: mask64=fffffffffffffff0 4194304bytes
[    0.000000] [ 3] [  INFO] [server] pci_setup_device: pbar4 set bad mask
[    0.000000] [ 3] [  INFO] [server] pci_setup_device: pbar5 set bad mask
[    0.000000] [ 3] [  INFO] [server] ivshmem_probe: shmem addr=0x10400000 size=4194304 reg=0x10008000
[    0.000000] [ 3] [  INFO] [server] rptun_ivshmem_probe: shmem addr=0x10400000 size=4194304

NuttShell (NSH) NuttX-12.10.0
server> 
server> 
server> 
server> [    0.000000] [ 0] [  INFO] [proxy] pci_register_rptun_ivshmem_driver: Register ivshmem driver, id=0, cpuname=server, master=0
[    0.000000] [ 3] [  INFO] [proxy] pci_scan_bus: pci_scan_bus for bus 0
[    0.000000] [ 3] [  INFO] [proxy] pci_scan_bus: class = 00000600, hdr_type = 00000000
[    0.000000] [ 3] [  INFO] [proxy] pci_scan_bus: 00:00 [1b36:0008]
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar0 set bad mask
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar1 set bad mask
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar2 set bad mask
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar3 set bad mask
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar4 set bad mask
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar5 set bad mask
[    0.000000] [ 3] [  INFO] [proxy] pci_scan_bus: class = 00000200, hdr_type = 00000000
[    0.000000] [ 3] [  INFO] [proxy] pci_scan_bus: 00:08 [1af4:1000]
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar0: mask64=fffffffe 32bytes
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar1: mask64=fffffff0 4096bytes
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar2 set bad mask
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar3 set bad mask
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar4: mask64=fffffffffffffff0 16384bytes
[    0.000000] [ 3] [  INFO] [proxy] pci_scan_bus: class = 00000500, hdr_type = 00000000
[    0.000000] [ 3] [  INFO] [proxy] pci_scan_bus: 00:58 [1af4:1110]
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar0: mask64=fffffff0 256bytes
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar1 set bad mask
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar2: mask64=fffffffffffffff0 4194304bytes
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar4 set bad mask
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar5 set bad mask
[    0.000000] [ 3] [  INFO] [proxy] ivshmem_probe: shmem addr=0x10400000 size=4194304 reg=0x10008000
[    0.000000] [ 3] [  INFO] [proxy] rptun_ivshmem_probe: shmem addr=0x10400000 size=4194304
[    0.000000] [ 3] [  INFO] [proxy] rptun_ivshmem_probe: Start the wdog

server> 
server> 
server> 
server> ls
/:
 dev/
 proc/
 tmp/
server> ls /dev
/dev:
 console
 log
 logrpmsg
 null
 pci
 random
 random1
 rpmsg/
 rptun/
 ttyS1
 ttyV0
 zero
server> hexdump /dev/random count=128
/dev/random at 00000000:
0000: 78 3b c9 5d db da b3 46 f7 f3 d5 cd 13 0d f8 54 x;.]...F.......T
0010: 2f 26 1a dc 4b 3f 3c 63 67 58 5e ea 83 71 80 71 /&..K?<cgX^..q.q
0020: 9f 8a a2 f8 bb a3 c4 7f d7 bc e6 06 f3 d5 08 8e ................
0030: 0f ef 2a 15 2b 08 4d 9c 47 21 6f 23 63 3a 91 aa ..*.+.M.G!o#c:..
0040: 7f 53 b3 31 9b 6c d5 b8 b7 85 f7 3f d3 9e 19 c7 .S.1.l.....?....
0050: ef b7 3b 4e 0b d1 5d d5 27 ea 7f 5c 43 03 a2 e3 ..;N..].'..\C...
0060: 5f 1c c4 6a 7b 35 e6 f1 97 4e 08 79 b3 67 2a 00 _..j{5...N.y.g*.
0070: cf 80 4c 87 eb 99 6e 0e 07 b3 90 95 23 cc b2 1c ..L...n.....#...
server> hexdump /dev/random count=128
/dev/random at 00000000:
0000: c7 85 8b 1c e3 9e ad a3 ff b7 cf 2a 1b d1 f1 b1 ...........*....
0010: 37 ea 13 39 53 03 36 c0 6f 1c 58 47 8b 35 7a ce 7..9S.6.o.XG.5z.
0020: a7 4e 9c 55 c3 67 be dc df 80 e0 63 fb 99 02 eb .N.U.g.....c....
0030: 17 b3 24 72 33 cc 46 f9 4f e5 68 80 6b fe 8a 07 ..$r3.F.O.h.k...
0040: 87 17 ad 8e a3 30 cf 15 bf 49 f1 9c db 62 13 24 .....0...I...b.$
0050: f7 7b 35 ab 13 95 57 32 2f ae 79 b9 4b c7 9b 40 .{5...W2/.y.K..@
0060: 67 e0 bd c7 ca 7f a8 b0 e6 98 ca 37 02 b2 ec be g..........7....
0070: 1e cb 0e 46 3a e4 30 cd 56 fd 52 54 72 16 75 db ...F:.0.V.RTr.u.
server> hexdump /dev/random1 count=128
/dev/random1 at 00000000:
0000: ca d5 c9 83 e6 ee eb 0a 02 08 0e 92 1e 21 30 19 .............!0.
0010: 3a 3a 52 a0 56 53 74 27 72 6c 96 ae 8e 85 b8 35 ::R.VSt'rl.....5
0020: aa 9e da bc c6 b7 fc 43 e2 d0 1e cb fe e9 40 52 .......C......@R
0030: 1a 03 63 d9 36 1c 85 60 52 35 a7 e7 6e 4e c9 6e ..c.6..`R5..nN.n
0040: 8a 67 eb f5 a6 80 0d 7d c2 99 2f 04 de b2 51 8b .g.....}../...Q.
0050: fa cb 73 12 5d 6b 5e fb 79 84 80 82 95 9d a2 09 ..s.]k^.y.......
0060: b1 b6 c4 90 cd cf e6 17 e9 e8 08 9f 05 02 2b 26 ..............+&
0070: 21 1b 4d ad 3d 34 6f 34 59 4d 91 bb 75 66 b3 42 !.M.=4o4YM..uf.B
server> rpmsg ping all 1 1 1 1 
[    0.000000] [ 7] [ EMERG] [server] ping times: 1
[    0.000000] [ 7] [ EMERG] [server] buffer_len: 1520, send_len: 17
[    0.000000] [ 7] [ EMERG] [server] avg: 0 s, 17653872 ns
[    0.000000] [ 7] [ EMERG] [server] min: 0 s, 17653872 ns
[    0.000000] [ 7] [ EMERG] [server] max: 0 s, 17653872 ns
[    0.000000] [ 7] [ EMERG] [server] rate: 0.007703 Mbits/sec
[    0.000000] [ 7] [ EMERG] [server] ping times: 1
[    0.000000] [ 7] [ EMERG] [server] buffer_len: 2024, send_len: 17
[    0.000000] [ 7] [ EMERG] [server] avg: 0 s, 7482720 ns
[    0.000000] [ 7] [ EMERG] [server] min: 0 s, 7482720 ns
[    0.000000] [ 7] [ EMERG] [server] max: 0 s, 7482720 ns
[    0.000000] [ 7] [ EMERG] [server] rate: 0.018175 Mbits/sec
server> rpmsg ping all 1 1 1 1 
[    0.000000] [ 7] [ EMERG] [server] ping times: 1
[    0.000000] [ 7] [ EMERG] [server] buffer_len: 1520, send_len: 17
[    0.000000] [ 7] [ EMERG] [server] avg: 0 s, 7696016 ns
[    0.000000] [ 7] [ EMERG] [server] min: 0 s, 7696016 ns
[    0.000000] [ 7] [ EMERG] [server] max: 0 s, 7696016 ns
[    0.000000] [ 7] [ EMERG] [server] rate: 0.017671 Mbits/sec
[    0.000000] [ 7] [ EMERG] [server] ping times: 1
[    0.000000] [ 7] [ EMERG] [server] buffer_len: 2024, send_len: 17
[    0.000000] [ 7] [ EMERG] [server] avg: 0 s, 6250912 ns
[    0.000000] [ 7] [ EMERG] [server] min: 0 s, 6250912 ns
[    0.000000] [ 7] [ EMERG] [server] max: 0 s, 6250912 ns
[    0.000000] [ 7] [ EMERG] [server] rate: 0.021756 Mbits/sec

qemu-armv7a test log:

qemu-system-arm -cpu cortex-a7 -nographic -machine virt,highmem=off \
        -object memory-backend-file,id=shmmem-shmem0,mem-path=/dev/shm/ivshmem0,size=4194304,share=yes \
        -device ivshmem-plain,id=shmem0,memdev=shmmem-shmem0,addr=0xb \
        -device virtio-serial-device,bus=virtio-mmio-bus.0 \
        -chardev socket,path=/tmp/rpmsg_port_uart_socket,server=on,wait=off,id=foo \
        -device virtconsole,chardev=foo \
        -kernel ./nuttx/cmake_out/v7a_server/nuttx -nographic
[    0.000000] [ 0] [  INFO] [server] pci_register_rptun_ivshmem_driver: Register ivshmem driver, id=0, cpuname=proxy, master=1
[    0.000000] [ 4] [  INFO] [server] pci_scan_bus: pci_scan_bus for bus 0
[    0.000000] [ 4] [  INFO] [server] pci_scan_bus: class = 00000600, hdr_type = 00000000
[    0.000000] [ 4] [  INFO] [server] pci_scan_bus: 00:00 [1b36:0008]
[    0.000000] [ 4] [  INFO] [server] pci_setup_device: pbar0 set bad mask
[    0.000000] [ 4] [  INFO] [server] pci_setup_device: pbar1 set bad mask
[    0.000000] [ 4] [  INFO] [server] pci_setup_device: pbar2 set bad mask
[    0.000000] [ 4] [  INFO] [server] pci_setup_device: pbar3 set bad mask
[    0.000000] [ 4] [  INFO] [server] pci_setup_device: pbar4 set bad mask
[    0.000000] [ 4] [  INFO] [server] pci_setup_device: pbar5 set bad mask
[    0.000000] [ 4] [  INFO] [server] pci_scan_bus: class = 00000200, hdr_type = 00000000
[    0.000000] [ 4] [  INFO] [server] pci_scan_bus: 00:08 [1af4:1000]
[    0.000000] [ 4] [  INFO] [server] pci_setup_device: pbar0: mask64=fffffffe 32bytes
[    0.000000] [ 4] [  INFO] [server] pci_setup_device: pbar1: mask64=fffffff0 4096bytes
[    0.000000] [ 4] [  INFO] [server] pci_setup_device: pbar2 set bad mask
[    0.000000] [ 4] [  INFO] [server] pci_setup_device: pbar3 set bad mask
[    0.000000] [ 4] [  INFO] [server] pci_setup_device: pbar4: mask64=fffffffffffffff0 16384bytes
[    0.000000] [ 4] [  INFO] [server] pci_scan_bus: class = 00000500, hdr_type = 00000000
[    0.000000] [ 4] [  INFO] [server] pci_scan_bus: 00:58 [1af4:1110]
[    0.000000] [ 4] [  INFO] [server] pci_setup_device: pbar0: mask64=fffffff0 256bytes
[    0.000000] [ 4] [  INFO] [server] pci_setup_device: pbar1 set bad mask
[    0.000000] [ 4] [  INFO] [server] pci_setup_device: pbar2: mask64=fffffffffffffff0 4194304bytes
[    0.000000] [ 4] [  INFO] [server] pci_setup_device: pbar4 set bad mask
[    0.000000] [ 4] [  INFO] [server] pci_setup_device: pbar5 set bad mask
[    0.000000] [ 4] [  INFO] [server] ivshmem_probe: shmem addr=0x10400000 size=4194304 reg=0x10008000
[    0.000000] [ 4] [  INFO] [server] rptun_ivshmem_probe: shmem addr=0x10400000 size=4194304

NuttShell (NSH) NuttX-12.10.0
server> 
server> [    0.000000] [ 0] [  INFO] [proxy] pci_register_rptun_ivshmem_driver: Register ivshmem driver, id=0, cpuname=server, master=0
[    0.000000] [ 3] [  INFO] [proxy] pci_scan_bus: pci_scan_bus for bus 0
[    0.000000] [ 3] [  INFO] [proxy] pci_scan_bus: class = 00000600, hdr_type = 00000000
[    0.000000] [ 3] [  INFO] [proxy] pci_scan_bus: 00:00 [1b36:0008]
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar0 set bad mask
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar1 set bad mask
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar2 set bad mask
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar3 set bad mask
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar4 set bad mask
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar5 set bad mask
[    0.000000] [ 3] [  INFO] [proxy] pci_scan_bus: class = 00000200, hdr_type = 00000000
[    0.000000] [ 3] [  INFO] [proxy] pci_scan_bus: 00:08 [1af4:1000]
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar0: mask64=fffffffe 32bytes
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar1: mask64=fffffff0 4096bytes
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar2 set bad mask
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar3 set bad mask
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar4: mask64=fffffffffffffff0 16384bytes
[    0.000000] [ 3] [  INFO] [proxy] pci_scan_bus: class = 00000500, hdr_type = 00000000
[    0.000000] [ 3] [  INFO] [proxy] pci_scan_bus: 00:58 [1af4:1110]
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar0: mask64=fffffff0 256bytes
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar1 set bad mask
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar2: mask64=fffffffffffffff0 4194304bytes
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar4 set bad mask
[    0.000000] [ 3] [  INFO] [proxy] pci_setup_device: pbar5 set bad mask
[    0.000000] [ 3] [  INFO] [proxy] ivshmem_probe: shmem addr=0x10400000 size=4194304 reg=0x10008000
[    0.000000] [ 3] [  INFO] [proxy] rptun_ivshmem_probe: shmem addr=0x10400000 size=4194304
[    0.000000] [ 3] [  INFO] [proxy] rptun_ivshmem_probe: Start the wdog

server> 
server> 
server> ps
  TID   PID  PPID PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK            STACK    USED FILLED COMMAND
    0     0     0   0 FIFO     Kthread   - Ready              0000000000000000 0004080 0000836  20.4%  Idle_Task
    1     0     0 224 FIFO     Kthread   - Waiting  Semaphore 0000000000000000 0001976 0000728  36.8%  rpmsgdev_server 0x40205380 0x402053c8
    2     0     0 192 FIFO     Kthread   - Waiting  Semaphore 0000000000000000 0001984 0000728  36.6%  hpwork 0x40200108 0x40200150
    3     0     0 100 FIFO     Kthread   - Waiting  Semaphore 0000000000000000 0001984 0000728  36.6%  lpwork 0x4020016c 0x402001b4
    6     0     0 224 FIFO     Kthread   - Waiting  Semaphore 0000000000000000 0001984 0001264  63.7%  rpmsg-uart-rx proxy2 0x40213540
    7     0     0 224 FIFO     Kthread   - Waiting  Semaphore 0000000000000000 0001984 0001156  58.2%  rpmsg-uart-tx proxy2 0x40213540
    8     8     0 100 FIFO     Task      - Running            0000000000000000 0004056 0002280  56.2%  nsh_main
    9     0     0 224 FIFO     Kthread   - Waiting  Semaphore 0000000000000000 0001984 0001040  52.4%  rpmsg-virtio proxy 0x40226238
server> 
server> 
server> rpmsg ping all 1 1 1 1
[    0.000000] [ 8] [ EMERG] [server] ping times: 1
[    0.000000] [ 8] [ EMERG] [server] buffer_len: 1520, send_len: 17
[    0.000000] [ 8] [ EMERG] [server] avg: 0 s, 14191632 ns
[    0.000000] [ 8] [ EMERG] [server] min: 0 s, 14191632 ns
[    0.000000] [ 8] [ EMERG] [server] max: 0 s, 14191632 ns
[    0.000000] [ 8] [ EMERG] [server] rate: 0.009583 Mbits/sec
[    0.000000] [ 8] [ EMERG] [server] ping times: 1
[    0.000000] [ 8] [ EMERG] [server] buffer_len: 2024, send_len: 17
[    0.000000] [ 8] [ EMERG] [server] avg: 0 s, 7359952 ns
[    0.000000] [ 8] [ EMERG] [server] min: 0 s, 7359952 ns
[    0.000000] [ 8] [ EMERG] [server] max: 0 s, 7359952 ns
[    0.000000] [ 8] [ EMERG] [server] rate: 0.018478 Mbits/sec
server> 
server> 
server> uname -a
NuttX server 12.10.0 32f5f24ff4e Jan 14 2026 22:22:14 arm qemu-armv7a
server> rpmsg dump all
[    0.000000] [ 8] [ EMERG] [server] Dump rpmsg info between cpu (master: yes)server <==> proxy:
[    0.000000] [ 8] [ EMERG] [server] rpmsg vq RX:
[    0.000000] [ 8] [ EMERG] [server] rpmsg vq TX:
[    0.000000] [ 8] [ EMERG] [server]   rpmsg ept list:
[    0.000000] [ 8] [ EMERG] [server]     ept NS
[    0.000000] [ 8] [ EMERG] [server]     ept rpmsg-sensor
[    0.000000] [ 8] [ EMERG] [server]     ept rpmsg-ping
[    0.000000] [ 8] [ EMERG] [server]     ept rpmsg-syslog
[    0.000000] [ 8] [ EMERG] [server]   rpmsg buffer list:
[    0.000000] [ 8] [ EMERG] [server]     RX buffer, total 8, pending 0
[    0.000000] [ 8] [ EMERG] [server]     TX buffer, total 8, pending 0
[    0.000000] [ 8] [ EMERG] [server] Remote: proxy2 state: 1
[    0.000000] [ 8] [ EMERG] [server] ept NS
[    0.000000] [ 8] [ EMERG] [server] ept rpmsg-sensor
[    0.000000] [ 8] [ EMERG] [server] ept rpmsg-ping
[    0.000000] [ 8] [ EMERG] [server] rpmsg_port queue RX: {used: 0, avail: 8}
[    0.000000] [ 8] [ EMERG] [server] rpmsg buffer list:
[    0.000000] [ 8] [ EMERG] [server] rpmsg_port queue TX: {used: 0, avail: 8}
[    0.000000] [ 8] [ EMERG] [server] rpmsg buffer list:
server> 

nucleo-h745zi test log:

NuttShell (NSH) NuttX-12.10.0
nsh-cm7> 
nsh-cm7> 
nsh-cm7> 
nsh-cm7> 
nsh-cm7> uname -a
NuttX 12.10.0 5d5aa3b6a1e-dirty Jan 14 2026 21:12:13 arm nucleo-h745zi
nsh-cm7> 
nsh-cm7> rpmsg dump all
Dump rpmsg info between cpu (master: yes)cm7 <==> cm4:
rpmsg vq RX:
rpmsg vq TX:
  rpmsg ept list:
    ept NS
    ept rpmsg-ttyproxy
    ept rpmsg-ping
  rpmsg buffer list:
    RX buffer, total 8, pending 0
    TX buffer, total 8, pending 0
nsh-cm7> rpmsg ping all 1 1 1 1
ping times: 1
buffer_len: 496, send_len: 17
avg: 0 s, 73922 ns
min: 0 s, 73922 ns
max: 0 s, 73922 ns
rate: 1.839777 Mbits/sec
nsh-cm7> 
nsh-cm7> 
nsh-cm7> ps
  TID   PID  PPID PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK            STACK COMMAND
    0     0     0   0 FIFO     Kthread   - Ready              0000000000000000 0001008 Idle_Task
    1     1     0 100 RR       Task      - Running            0000000000000000 0002008 nsh_main
    3     0     0 224 RR       Kthread   - Waiting  Semaphore 0000000000000000 0001984 rpmsg-virtio cm4 0x20004330
    4     0     0 224 RR       Kthread   - Waiting  Semaphore 0000000000000000 0004056 stm32-rptun
nsh-cm7> 

@CV-Bowen CV-Bowen marked this pull request as draft January 9, 2026 15:05
@github-actions github-actions bot added Arch: arm Issues related to ARM (32-bit) architecture Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Arch: simulator Issues related to the SIMulator Area: Drivers Drivers issues Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. labels Jan 9, 2026
jerpelea
jerpelea previously approved these changes Jan 12, 2026
@jerpelea jerpelea changed the title Rptun refactor: decoupling the rptun and rpmsg virtio, make rptun can work with any virtio devices drivers/rptun: refactor decoupling the rptun and rpmsg virtio, make rptun can work with any virtio devices Jan 12, 2026
@CV-Bowen CV-Bowen dismissed stale reviews from jerpelea and xiaoxiang781216 via 3b248c2 January 13, 2026 13:29
@CV-Bowen CV-Bowen changed the title drivers/rptun: refactor decoupling the rptun and rpmsg virtio, make rptun can work with any virtio devices drivers/rptun: refactor rptun to decoupling the rptun and rpmsg virtio, make rptun can work with any virtio devices Jan 13, 2026
@CV-Bowen CV-Bowen force-pushed the rptun-refactor branch 2 times, most recently from bb33a34 to 62ff879 Compare January 13, 2026 15:00
@CV-Bowen CV-Bowen marked this pull request as ready for review January 13, 2026 15:00
CV-Bowen and others added 14 commits January 16, 2026 10:45
…work

Now the sim, qemu-armv7a, qemu-armv8a can work with the new
rptun framework.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Support user pass it own heap struct to the mm_initialize_heap() to
avoid the heap struct is reserved from the heap range

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Because heap->lock will use atomic operation and may can't use in
share memory.

Signed-off-by: Bowen Wnag <wangbowen6@xiaomi.com>
Because fs always need malloc the small memory for inode or filep,
so enable the mempool by default to optimize the memory
fragmentation issue.

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
To avoid add new parameters to the mm_initialize_heap() and
mm_initialize_pool()

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Support enable/disable the kasan when initialize the heap.
This requirement is from rptun, because rptun use share memory init
the heap and share memory is precious, so we need disable the kasan
feature for rptun's heap to save the share memory.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
Previous patch is not corrected:
5518135: mm/mm_heap: add nokasan flag in mm_heap_config_s structure |
https://gerrit.pt.mioffice.cn/c/vela/nuttx/+/5518135

Because rptun do not want part of the share memory is used by the
struct mm_heap_s to:
1. Save the share memory;
2. Some platfrom can't use atomic operation at the share memory,
and struct mm_heap_s contains a mutex.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Memleak Bug fix, when file_read() failed in rptun_store_open(),
memleak occur.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Use share memory to send PANIC and RESET command to peer if the rptun
driver do not support panic() and reset ops.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
so we can mix rptun and rpmsg_virtio_lite in the same system.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Support use the drivers provided stack to initialize the rptun
kthread.

Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
If there are multiple virtio devices in rsc, it must wait for the previous
device to be created before creating the next one. In this case, if the
driver configuration of a device is not be set Y, the subsequent virtio
devices cannot be created.

Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
Because virtio device do not need manager the share memory heap
for now.

But later we will make the virtio device be able to manager a
standalone heap, so let this logic can be easily to extend.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
1. call virtqueue_notification() only when buffer exist to avoid unnecessary
calls to virtqueue callback.

2. call virtqueue_notification() only when vq != NULL, because
rproc_virtio_notified() may be called when the virtqueues is not created:
virtqueue created in the virtio/vhost driver but the virtio devices
has been added to the remoteproc virtio devices list after the remoteproc
transport layer create the virtio devices.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
@github-actions github-actions bot added the Area: Documentation Improvements or additions to documentation label Jan 16, 2026
Rmove the old rptun document and add new folder to add the new
rptun frameworks documents.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
@CV-Bowen
Copy link
Contributor Author

@acassis Of course, done.

@CV-Bowen
Copy link
Contributor Author

@acassis @jerpelea @raiden00pl Could you help review this PR?

@GUIDINGLI GUIDINGLI merged commit 949b519 into apache:master Jan 19, 2026
41 checks passed
@raiden00pl
Copy link
Member

raiden00pl commented Jan 19, 2026

@GUIDINGLI @CV-Bowen this PR broke HCI over rpmsg on nrf53

on app core:

bt_driver_register error: -12
ERROR: nrf53_appcore_bleinit failed: -12

NuttShell (NSH) NuttX-10.4.0
nsh>

@CV-Bowen
Copy link
Contributor Author

@raiden00pl Could you enable CONFIG_DEBUG_RPMSG_ERROR and CONFIG_DEBUG_RPTUN_ERROR to see whether there is rptun/rpmsg init error and then use ps command to see whether the rpmsg virtio thread is created or not, and use command rpmsg dump all to output some debug messages.

@raiden00pl
Copy link
Member

@CV-Bowen there is nothing in debug messages.

rpmsg dump all on app core returns this:

nsh> rpmsg dump all
Dump rpmsg info between cpu (master: yes)appcore <==> netcore:
rpmsg vq RX:
rpmsg vq TX:
  rpmsg ept list:
    ept NS
    ept rpmsg-ping
  rpmsg buffer list:
    RX buffer, total 8, pending 0
    TX buffer, total 8, pending 0

on netcore it's not possible to run this command, because NSH with network stack doesn't fit on FLASH.

One IPC interrupt happens on the netcore and appcore and rptun callback is executed, so IPC works. But for some reason nothing else happens

@CV-Bowen
Copy link
Contributor Author

@raiden00pl Seems rpmsg is initialized success but there are only the rpmsg name service and rpsmg ping services in this channel.

  1. Could you use command rpmsg ping all 1 1 1 1 to verify the rpmsg channel is OK or not.
  2. Does the HCI over rpmsg use the CONFIG_RPMSG_UART? if so, there are no rpmsg uart service in the rpmsg dump log, seems the uart_rpmsg_init() failed and leads the bt_driver_register() failed?
  3. Could you then enable CONFIG_DEBUG_NET_ERROR to output more log to see why bt_driver_register() failed?

@raiden00pl
Copy link
Member

@CV-Bowen I found the issue with rptun: cpu names doesn't match for nrf53. But unfortunately the BLE net stack is broken on master and I can't check if this fix all issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm Issues related to ARM (32-bit) architecture Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Arch: simulator Issues related to the SIMulator Area: Documentation Improvements or additions to documentation Area: Drivers Drivers issues Area: File System File System issues Area: Memory Management Memory Management issues Area: OS Components OS Components issues Board: arm Board: arm64 Board: simulator Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces.

Projects

None yet

Development

Successfully merging this pull request may close these issues.