RPMsg from Linux User Space to PRU on Beaglebone Black

I am trying to use rpmsg from user space. I am following the PRU training of TI (http://processors.wiki.ti.com/index.php/PRU_Training:_Hands-on_Labs#Part_1:_Linux_Command_Line_LED_Toggling)

I use the latest beaglebone black image (Debian 8.3 2016-01-24 from https://beagleboard.org/latest-images).

The three kernel modules that are needed appear to be already part of this image (virtio_rpmsg_bus.ko, pruss_remoteproc.ko,rpmsg_pru.ko). It seems like I have to load them in this exact order. Unfortunately pruss_remoteproc.ko is already loaded and there seem to be a bug that prevents reloading the module (https://groups.google.com/forum/#!topic/beagleboard/EXBjL4TkBiU). So what could be a solution for this problem?

  • Can I load the modules in the right order on boot? (I cannot find the point where pruss_remoteproc.ko gets loaded)
  • Can I prevent pruss_remoteproc.ko from being loaded on boot and insmod it later on?
  • Or, is my problem something completely different and rpmsg doesn’t work like that from user space out of the box with the image that I am using i.e. I have to recompile the kernel?

Thank you!

Hi Lucas,

This seems to work just fine for me. What kernel version are you using?

I’m using V4.1.13-ti-r33. As you can see, all remoteproc/rpmsg kernel modules are loaded automatically at boot time.

[ 16.251480] pruss-rproc 4a300000.pruss: 8 PRU interrupts parsed
[ 16.251567] pruss-rproc 4a300000.pruss: memory dram0: pa 0x4a300000 size 0x2000 va e0ca0000
[ 16.251595] pruss-rproc 4a300000.pruss: memory dram1: pa 0x4a302000 size 0x2000 va e0ca4000
[ 16.251621] pruss-rproc 4a300000.pruss: memory shrdram2: pa 0x4a310000 size 0x3000 va e0ca8000
[ 16.251644] pruss-rproc 4a300000.pruss: memory intc: pa 0x4a320000 size 0x2000 va e0cac000
[ 16.251672] pruss-rproc 4a300000.pruss: memory cfg: pa 0x4a326000 size 0x2000 va e0cb0000
[ 16.252174] pruss-rproc 4a300000.pruss: creating platform devices for PRU cores
[ 16.374800] pru-rproc 4a334000.pru0: memory iram: pa 0x4a334000 size 0x2000 va e0cb4000
[ 16.374858] pru-rproc 4a334000.pru0: memory control: pa 0x4a322000 size 0x400 va e0876000
[ 16.374901] pru-rproc 4a334000.pru0: memory debug: pa 0x4a322400 size 0x100 va e0c9e400
[ 16.375152] remoteproc1: 4a334000.pru0 is available
[ 16.380153] remoteproc1: Note: remoteproc is still under development and considered experimental.
[ 16.572902] remoteproc1: THE BINARY FORMAT IS NOT YET FINALIZED, and backward compatibility isn’t yet guaranteed.
[ 16.778752] remoteproc1: registered virtio0 (type 7)
[ 16.811201] pru-rproc 4a334000.pru0: PRU rproc node /ocp/pruss@4a300000/pru@4a334000 probed successfully
[ 16.932818] pru-rproc 4a338000.pru1: memory iram: pa 0x4a338000 size 0x2000 va e0ccc000
[ 16.932891] pru-rproc 4a338000.pru1: memory control: pa 0x4a324000 size 0x400 va e0cd0000
[ 16.932918] pru-rproc 4a338000.pru1: memory debug: pa 0x4a324400 size 0x100 va e0cd2400
[ 16.933190] remoteproc2: 4a338000.pru1 is available
[ 16.938192] remoteproc2: Note: remoteproc is still under development and considered experimental.
[ 17.081421] remoteproc2: THE BINARY FORMAT IS NOT YET FINALIZED, and backward compatibility isn’t yet guaranteed.
[ 17.114912] remoteproc2: registered virtio1 (type 7)
[ 17.131205] pru-rproc 4a338000.pru1: PRU rproc node /ocp/pruss@4a300000/pru@4a338000 probed successfully
[ 17.231951] remoteproc1: powering up 4a334000.pru0
[ 17.243111] remoteproc1: Booting fw image am335x-pru0-fw, size 78652
[ 17.271252] pru-rproc 4a334000.pru0: version 0 event_chnl_map_size 1 event_chnl_map 0000039c
[ 17.271289] pru-rproc 4a334000.pru0: sysevt-to-ch[60] → 0
[ 17.271305] pru-rproc 4a334000.pru0: chnl-to-host[0] → 0
[ 17.271318] pru-rproc 4a334000.pru0: skip intr mapping for chnl 1
[ 17.271330] pru-rproc 4a334000.pru0: skip intr mapping for chnl 2
[ 17.271343] pru-rproc 4a334000.pru0: skip intr mapping for chnl 3
[ 17.271355] pru-rproc 4a334000.pru0: skip intr mapping for chnl 4
[ 17.271367] pru-rproc 4a334000.pru0: skip intr mapping for chnl 5
[ 17.271379] pru-rproc 4a334000.pru0: skip intr mapping for chnl 6
[ 17.271391] pru-rproc 4a334000.pru0: skip intr mapping for chnl 7
[ 17.271404] pru-rproc 4a334000.pru0: skip intr mapping for chnl 8
[ 17.271416] pru-rproc 4a334000.pru0: skip intr mapping for chnl 9
[ 17.271434] pruss-rproc 4a300000.pruss: SYSEV60 → CH0 (CMR15 0x00000000)
[ 17.271449] pruss-rproc 4a300000.pruss: CH0 → HOST0 (HMR0 0x00000000)
[ 17.271465] pruss-rproc 4a300000.pruss: configured system_events = 0x1000000000000000 intr_channels = 0x00000001 host_intr = 01
[ 17.309385] remoteproc1: starting PRU0: entry-point = 0x0
[ 17.309420] remoteproc1: remote processor 4a334000.pru0 is now up
[ 17.352939] remoteproc1: mbox msg: 0x0
[ 17.353069] virtio_rpmsg_bus virtio0: creating channel rpmsg-client-sample addr 0x1e
[ 17.361804] remoteproc1: kicking vqid 0 on PRU0
[ 17.361904] virtio_rpmsg_bus virtio0: rpmsg host is online
[ 17.394061] remoteproc1: kicking vqid 0 on PRU0
[ 17.410206] remoteproc2: powering up 4a338000.pru1
[ 17.463473] remoteproc2: Booting fw image am335x-pru1-fw, size 78644
[ 17.470075] pru-rproc 4a338000.pru1: version 0 event_chnl_map_size 1 event_chnl_map 00000394
[ 17.470094] pru-rproc 4a338000.pru1: sysevt-to-ch[59] → 1
[ 17.470108] pru-rproc 4a338000.pru1: skip intr mapping for chnl 0
[ 17.470122] pru-rproc 4a338000.pru1: chnl-to-host[1] → 1
[ 17.470134] pru-rproc 4a338000.pru1: skip intr mapping for chnl 2
[ 17.470145] pru-rproc 4a338000.pru1: skip intr mapping for chnl 3
[ 17.470158] pru-rproc 4a338000.pru1: skip intr mapping for chnl 4
[ 17.470170] pru-rproc 4a338000.pru1: skip intr mapping for chnl 5
[ 17.470182] pru-rproc 4a338000.pru1: skip intr mapping for chnl 6
[ 17.470194] pru-rproc 4a338000.pru1: skip intr mapping for chnl 7
[ 17.470206] pru-rproc 4a338000.pru1: skip intr mapping for chnl 8
[ 17.470218] pru-rproc 4a338000.pru1: skip intr mapping for chnl 9
[ 17.470235] pruss-rproc 4a300000.pruss: SYSEV59 → CH1 (CMR14 0x01000000)
[ 17.470249] pruss-rproc 4a300000.pruss: SYSEV60 → CH0 (CMR15 0x00000000)
[ 17.470264] pruss-rproc 4a300000.pruss: CH0 → HOST0 (HMR0 0x00000000)
[ 17.470279] pruss-rproc 4a300000.pruss: CH1 → HOST1 (HMR0 0x00000100)
[ 17.470294] pruss-rproc 4a300000.pruss: configured system_events = 0x1800000000000000 intr_channels = 0x00000003 host_intr = 03
[ 17.621116] remoteproc2: starting PRU1: entry-point = 0x0
[ 17.621151] remoteproc2: remote processor 4a338000.pru1 is now up
[ 17.690894] remoteproc2: mbox msg: 0x0
[ 17.691124] virtio_rpmsg_bus virtio1: creating channel rpmsg-pru addr 0x1f
[ 17.698850] remoteproc2: kicking vqid 0 on PRU1
[ 17.698906] virtio_rpmsg_bus virtio1: rpmsg host is online
[ 17.723089] remoteproc2: kicking vqid 0 on PRU1
[ 17.966768] rpmsg_pru rpmsg1: new rpmsg_pru device: /dev/rpmsg_pru31

root@beaglebone:~# lsmod
Module Size Used by
usb_f_acm 8098 0
u_serial 12463 1 usb_f_acm
usb_f_rndis 26352 0
usb_f_mass_storage 50100 0
u_ether 13493 1 usb_f_rndis
libcomposite 53637 3 usb_f_acm,usb_f_rndis,usb_f_mass_storage
rpmsg_pru 5295 0
virtio_rpmsg_bus 15318 1 rpmsg_pru
pruss_remoteproc 17160 2
tilcdc 30557 0
omap_rng 5239 0
rng_core 8893 1 omap_rng
snd_soc_davinci_mcasp 20886 0
snd_soc_edma 1174 1 snd_soc_davinci_mcasp
tda998x 14298 0
snd_soc_hdmi_codec 2522 0

The remoteproc/rpmsg modules should be located here.

root@beaglebone:/lib/modules/4.1.13-ti-r33/kernel/drivers/rpmsg# ls
rpmsg_pru.ko rpmsg-rpc.ko virtio_rpmsg_bus.ko
root@beaglebone:/lib/modules/4.1.13-ti-r33/kernel/drivers/rpmsg# cd …/remoteproc/
root@beaglebone:/lib/modules/4.1.13-ti-r33/kernel/drivers/remoteproc# ls
omap_remoteproc.ko pruss_remoteproc.ko

To load them manually, use modprobe which detects module dependencies automatically.

modprobe rpmsg_pru

Regards,
John

Hi John,

thank you very much for your answer.

I am using the 4.1.15-ti-rt-r43 kernel. It’s the kernel that came with the debian image from the beaglebone website.

Only the pruss_remoteproc module seems to be loaded on boot:

lsmod

Module Size Used by
8021q 17336 0
garp 5975 1 8021q
mrp 7322 1 8021q
stp 1911 1 garp
llc 5257 2 stp,garp
pruss_remoteproc 15296 2
omap_rng 4358 0
rng_core 7437 1 omap_rng
usb_f_acm 7180 1
u_serial 10596 3 usb_f_acm
usb_f_rndis 22734 1
g_multi 5316 0
usb_f_mass_storage 42745 2 g_multi
u_ether 12028 2 usb_f_rndis,g_multi
libcomposite 43810 4 usb_f_acm,usb_f_rndis,g_multi,usb_f_mass_storage
snd_soc_davinci_mcasp 17266 0
snd_soc_edma 1150 1 snd_soc_davinci_mcasp
spi_omap2_mcspi 10681 0
uio_pdrv_genirq 3521 0

Although the other modules do exist in the driver directory.

ls /lib/modules/4.1.15-ti-rt-r43/kernel/drivers/rpmsg
rpmsg_pru.ko rpmsg-rpc.ko virtio_rpmsg_bus.ko

I cannot modprob the modules:

modprobe virtio_rpmsg_bus.ko

root@beaglebone:/lib/modules/4.1.15-ti-rt-r43/kernel/drivers/rpmsg# modprobe virtio_rpmsg_bus.ko

But I can use insmod

root@beaglebone:/lib/modules/4.1.15-ti-rt-r43/kernel/drivers/rpmsg# insmod virtio_rpmsg_bus.ko
root@beaglebone:/lib/modules/4.1.15-ti-rt-r43/kernel/drivers/rpmsg# lsmod
Module Size Used by
virtio_rpmsg_bus 13437 0
8021q 17336 0
garp 5975 1 8021q

Should I try to switch to the kernel version you are using? Is there an image or should I recompile the kernel? Any other ideas?

Lucas

Sorry forgot to copy the error message for the modprobe command:

root@beaglebone:/lib/modules/4.1.15-ti-rt-r43/kernel/drivers/rpmsg# modprobe virtio_rpmsg_bus.ko
modprobe: FATAL: Module virtio_rpmsg_bus.ko not found.

Don’t include the .ko extension when using modprobe.

Regards,
John

Wow it worked :slight_smile: Thank you, John!

Short summary how to get it working:

1.) Compile PRU_RPMsg_LED0 project in CCS
2.) Transfer PRU_RPMsg_LED0.out onto beaglebone into the /lib/firmware directory
3.) Set symbolic link: sudo ln -s PRU_RPMsg_LED0.out am335x-pru0-fw
4.) restart
5.) modprobe virtio_rpmsg_bus
6.) modprobe rpmsg_pru
7.) check if /dev/rpmsg_pru30 exists
8.) echo “r” > /dev/rpmsg_pru30
9.) Observe red LED light up on PRU_cape :slight_smile:

Hi Lucas,

Good to hear this is working for you. Now for the real work :wink:

Regards,
John

I tried what you did but I am using 4.4.9-ti-rt-r26. I am still not seeing the /dev/rpmsg_pru*.

Was this changed in recent kernel versions? I have been trying to solve this since yesterday.

I’ve changed my kernel to the same version as the poster (I’m using ubuntu).
I still don’t see the device in /dev.

[ 17.581262] pru-rproc 4a338000.pru1: sysevt-to-ch[18] → 3
[ 17.581274] pru-rproc 4a338000.pru1: sysevt-to-ch[19] → 1
[ 17.581286] pru-rproc 4a338000.pru1: skip intr mapping for chnl 0
[ 17.581297] pru-rproc 4a338000.pru1: chnl-to-host[1] → 1
[ 17.581308] pru-rproc 4a338000.pru1: skip intr mapping for chnl 2
[ 17.581319] pru-rproc 4a338000.pru1: chnl-to-host[3] → 3
[ 17.581329] pru-rproc 4a338000.pru1: skip intr mapping for chnl 4
[ 17.581340] pru-rproc 4a338000.pru1: skip intr mapping for chnl 5
[ 17.581350] pru-rproc 4a338000.pru1: skip intr mapping for chnl 6
[ 17.581361] pru-rproc 4a338000.pru1: skip intr mapping for chnl 7
[ 17.581371] pru-rproc 4a338000.pru1: skip intr mapping for chnl 8
[ 17.581382] pru-rproc 4a338000.pru1: skip intr mapping for chnl 9
[ 17.581397] pruss-rproc 4a300000.pruss: SYSEV18 → CH3 (CMR4 0x00030000)
[ 17.581410] pruss-rproc 4a300000.pruss: SYSEV19 → CH1 (CMR4 0x01030000)
[ 17.581424] pruss-rproc 4a300000.pruss: CH1 → HOST1 (HMR0 0x00000100)
[ 17.581436] pruss-rproc 4a300000.pruss: CH3 → HOST3 (HMR0 0x03000100)
[ 17.581449] pruss-rproc 4a300000.pruss: configured system_events = 0x00000000000c0000 intr_channels = 0x0000000a host_intr = 0x0000000a
[ 17.581461] remoteproc2: starting PRU1: entry-point = 0x0
[ 17.581471] remoteproc2: remote processor 4a338000.pru1 is now up
[ 17.661101] remoteproc2: kicking vqid 0 on PRU1
[ 17.663720] virtio_rpmsg_bus virtio0: rpmsg host is online
ubuntu@arm:~$

What does lsmod show?

Regards,
John

Hi John!

It is working now. I tried 4.1 and 4.4.9-ti-rt-r25. The problem was with the version of the pru software package. I changed to v4.0.2 and it worked. I have not tested with the 4.4.9-ti-rt-r26 though.

Wonderful. If you change to the V4.4 kernel, you must update to PRU V5.0 examples because there is a change from mailbox to interrupt event.

Regards,
John

I was actually using 4.4.9-ti-rt-r26 and v5.0 of the pru software package when it did not load the rpmsg_pru.

Then I’m wondering if Robert had pulled in these changes from the https://git.ti.com/rpmsg V4.4 repo. If not, then the V4.0.2 examples should work fine.

Regards,
John

r31 was the first v4.4.x release with interrupt events, r32 had a fix,
so upgrade to:

4.4.12-ti-r32/4.4.12-ti-rt-r32

Regards,

Robert:
I uncovered an minor bug when upgrading to 4.4.12-ti-r32

apt-get install linux-image-4.4.12-ti-r32
Reading package lists… Done
Building dependency tree
Reading state information… Done
Suggested packages:
linux-firmware-image-4.4.12-ti-r32
The following NEW packages will be installed:
linux-image-4.4.12-ti-r32
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 22.2 MB of archives.
After this operation, 79.3 MB of additional disk space will be used.
Get:1 Index of /debian jessie/main linux-image-4.4.12-ti-r32 armhf 1jessie [22.2 MB]
Fetched 22.2 MB in 46s (473 kB/s)
Selecting previously unselected package linux-image-4.4.12-ti-r32.
(Reading database … 62740 files and directories currently installed.)
Preparing to unpack …/linux-image-4.4.12-ti-r32_1jessie_armhf.deb …
Unpacking linux-image-4.4.12-ti-r32 (1jessie) …
Setting up linux-image-4.4.12-ti-r32 (1jessie) …
update-initramfs: Generating /boot/initrd.img-4.4.12-ti-r32
zz-uenv_txt: Updating /boot/uEnv.txt [uname_r=4.4.12-ti-r32]
sed: -e expression #1, char 23: unterminated `s’ command
run-parts: /etc/kernel/postinst.d/zz-uenv_txt exited with return code 1
dpkg: error processing package linux-image-4.4.12-ti-r32 (–configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
linux-image-4.4.12-ti-r32
E: Sub-process /usr/bin/dpkg returned an error code (1)

Prior to running apt-get I had added a line to /boot/uEnv.txt

#Docs: http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0

# uname_r=4.4.12-ti-r31
uname_r=4.4.12-ti-r31
#uuid=
#dtb=

I though the added comment would remain so I could uncomment it later if I wanted to return to the old kernel, but
I seemed to have confused the script instead. I removed the commented uname line and the install worked fine.

–Mark

This is the script we are dealing with:

https://github.com/rcn-ee/repos/blob/master/bb-bb-customizations/suite/jessie/debian/zz-uenv_txt#L11-L23

the # before the first uname_r should have already been removed via grep..

Regards,