The example shows how to use rpmsg endpoints to communicate between ARM and other SHARC cores. The example uses fork of rpmsg-lite library by NXP with adsp-sc5xx-sharc platform support added (feature/add_sc5xx_sharc_platform branch).
#define RL_USE_STATIC_API (1)
, currently only static API is supported on sc5xx-sharc platform.Using Linux command line start cores with the echo example.
The example firmware announces created endpoints on rpmsg bus,
Linux creates a rpmsg device for each endpoint in /sys/bus/rpmsg/devices
To communicate to the endpoints from userspace kernel must be compiled with CONFIG_RPMSG_CHAR
which enables rpmsg-char driver. Bind a rpmsg device to the driver manually or using rpmsg-bind-chardev
which is a helper application for binding rpmsg devices to the rpmsg-char driver. It can be found in the rpmsg-utils package from meta-adi Yocto layer. The bind creates a /dev/rpmsgX
file which an user space application can use to communicate with an endpoint created in SHARC firmware.
SHARC Core1 initialization script for the echo example:
#!/bin/sh
echo echo_core1.ldr > /sys/class/remoteproc/remoteproc0/firmware
echo start > /sys/class/remoteproc/remoteproc0/state
rpmsg-bind-chardev -p virtio0.sharc-echo.-1. -n 1 -e 151 -s 50
rpmsg-bind-chardev -p virtio0.sharc-echo-cap.-1. -n 1 -e 161 -s 61
SHARC Core2 initialization script for the echo example:
#!/bin/sh
echo echo_core2.ldr > /sys/class/remoteproc/remoteproc1/firmware
echo start > /sys/class/remoteproc/remoteproc1/state
rpmsg-bind-chardev -p virtio1.sharc-echo.-1. -n 1 -e 152 -s 51
rpmsg-bind-chardev -p virtio1.sharc-echo-cap.-1. -n 1 -e 162 -s 62
It is possible to send a messages to an endpoint on SHARC using regular echo
root@adsp-sc594-som-ezkit:~# echo "Hello!" > /dev/rpmsg0
But the messages coming from the endpoint are being dropped if the /dev/rpmsg0 file is closed. Therefore the rpmsg-utils package also contains an rpmsg-xmit helper application which reads a message from stdin, writes it to the /dev/rpmsgX file, while keeping the file open reads response and prints on stdout.
root@adsp-sc594-som-ezkit:~# echo hello | rpmsg-xmit -n 5 /dev/rpmsg0
hello => echo from Core1
root@adsp-sc594-som-ezkit:~# echo hello | rpmsg-xmit -n 5 /dev/rpmsg1
HELLO => capitalized echo from Core1
root@adsp-sc594-som-ezkit:~# echo hello | rpmsg-xmit -n 5 /dev/rpmsg2
hello => echo from Core2
root@adsp-sc594-som-ezkit:~# echo hello | rpmsg-xmit -n 5 /dev/rpmsg3
HELLO => capitalized echo from Core2