Executing RPMsg Samples

= Setting Up FileSystem =

Setup FS
Please refer either to the Android project page or browse through the all the Android pages to get started on Android.

The following assumes that you have a pre-built Android FS and is able to successfully boot Android 4.0 on a target device, and you could use adb.

Copy Files
bash$ adb root restarting adbd as root bash$ adb remount remount succeeded bash$ adb push my-custom-ducati.bin /system/vendor/firmware/ducati-m3.bin 2835 KB/s (331336 bytes in 0.114s)
 * The firmware folder is at a different location in Android FS. It is typically /system/vendor/firmware. You can push a custom firmware binary after making sure the particular folder can be written to
 * Push any sample executables to /system/bin folder.
 * Push the rpmsg kernel sample modules to /system/lib folder

BusyBox
RPMsg samples can be readily executed on a small BusyBox filesystem, after configuring the udev or mdev in your FS properly. The following assumes that your Linux PC is configured to perform NFS boot, and the required options are enabled while building your kernel. See this section for details.

Configure udev/mdev
The filesystem must have one of mdev or udev to successfully load the remoteproc firmware binaries. Check the /sbin directory for one of those within your Busybox FS.

If you have trouble, check the init scripts in /etc/init.d to see if the kernel is programmed to use mdev or udev. There is a /proc entry where the path of the loader executable is written. Without this the kernel will not be able to call the firwmware loader. For example, init.d/rcS:       echo "/sbin/mdev" > /proc/sys/kernel/hotplug

Configure DebugFS
The debugfs can be auto-mounted in your Busybox filesystem. It can go anywhere, but the following examples are illustrated using /debug. Follow this procedure to have it automatically mounted: bash$ cd  bash$ mkdir /debug bash$ vi /etc/fstab Add this line to the fstab file. debugfs        /debug 		debugfs         defaults        0 0

Copy Files

 * Copy any sample executables to a folder in the PATH variable (like /bin or /usr/bin), or add it to a custom folder and add the custom folder to your PATH folder.
 * Copy the rpmsg kernel sample modules to any folder for using insmod or install modules for using modprobe.

Angstrom FS
Angstrom FS provides a prebuilt configured filesystem, avoiding the need to configure udev or mdev. Running RPMsg samples on Angstrom FS is very similar to running the samples on a BusyBox FS. The following assumes that your Linux PC is configured to perform NFS boot, and the required options are enabled while building your kernel.

Build FS
Base Settings:- Select the machine you want to build your rootfs image for: pandaboard Choose your image name: my-angstrom-fs Choose the complexity of the options below: simple User environment selection:- Console Only Build Me!
 * A minimal udev-ready FS can be readily built from Angstrom builer by using the following options:
 * Download the generated tarball onto your Linux PC, and untar it into an appropriate NFS-bootable location.

Copy Files
bash$ cp my-custom-ducati.bin /lib/firmware/ducati-m3.bin
 * You can copy the ducati firmware binary into the firmware folder, typically /lib/firmware.
 * Copy any sample executables to a folder in the PATH variable (like /bin or /usr/bin), or add it to a custom folder and add the custom folder to your PATH folder.
 * Copy the rpmsg kernel sample modules to /lib/modules folder

= Install RPMsg Driver = The following assumes that you have built your kernel driver as modules. If you have the rpmsg driver built-into the kernel, it is expected that the FS have all been configured properly with the firmware binaries in place. The rpmsg driver gets initialized during kernel boot, and the remote processors get loaded with the firmware binaries.
 * Install the absolute necessary kernel modules - virtio_rpmsg_bus, omap_rpmsg, rpmsg_omx and rpmsg_resmgr. The following is the sample kernel traces.

= Execute Samples =

Kernel RPMsg Server Sample
The RPMsg Server sample is implemented as a module. It will send 100 messages. The sample requires that the ducati-m3.bin is generated using the test_omx_sysm3.xem3 or test_omx_appm3.xem3 as one of the base images. modprobe rpmsg_server_sample or insmod /rpmsg_server_sample.ko. . . omap-rproc omap-rproc.1: remote processor ipu is now up omap_rpmsg_mbox_callback: received echo reply from ipu ! omap_rpmsg_mbox_callback: received echo reply from ipu ! omap_rpmsg_mbox_callback: received echo reply from ipu ! omap_rpmsg_mbox_callback: received echo reply from ipu ! virtio_rpmsg_bus virtio0: creating channel rpmsg-client-sample addr 0x32 rpmsg_server_sample rpmsg0: incoming msg 1 (src: 0x32) virtio_rpmsg_bus virtio0: creating channel rpmsg-client-sample addr 0x33 virtio_rpmsg_bus virtio0: creating channel rpmsg-omx addr 0x3c rpmsg_server_sample rpmsg0: incoming msg 2 (src: 0x32) virtio_rpmsg_bus virtio1: creating channel rpmsg-client-sample addr 0x32 virtio_rpmsg_bus virtio1: creating channel rpmsg-client-sample addr 0x33 virtio_rpmsg_bus virtio1: creating channel rpmsg-omx addr 0x3c rpmsg_server_sample rpmsg0: incoming msg 3 (src: 0x32) rpmsg_server_sample rpmsg0: incoming msg 4 (src: 0x32) rpmsg_server_sample rpmsg0: incoming msg 5 (src: 0x32) rpmsg_server_sample rpmsg0: incoming msg 6 (src: 0x32) . . . modprobe -r rpmsg_client_sample or rmmod rpmsg_client_sample
 * Execution starts when the module is loaded.
 * Sample output here:
 * To rerun the sample, the module needs to be removed and reinstalled (repeat step. #1)

Kernel RPMsg Client Sample
The RPMSG client sample is also implemented as a kernel module, and requires the same base images as the RPMsg kernel sample. It will send 100 messages. modprobe rpmsg_client_sample or insmod /rpmsg_client_sample.ko. . . rpmsg_dev_probe rpmsg_client_sample rpmsg1: new channel: 0x401 <-> 0x32! rpmsg_dev_probe rpmsg_client_sample rpmsg2: new channel: 0x402 <-> 0x33! rpmsg_client_sample rpmsg1: incoming msg 1 (src: 0x32) rpmsg_dev_probe rpmsg_client_sample rpmsg4: new channel: 0x401 <-> 0x32! rpmsg_dev_probe rpmsg_client_sample rpmsg5: new channel: 0x402 <-> 0x33! rpmsg_client_sample rpmsg2: incoming msg 2 (src: 0x33) rpmsg_client_sample rpmsg1: incoming msg 3 (src: 0x32) rpmsg_client_sample rpmsg4: incoming msg 4 (src: 0x32) rpmsg_client_sample rpmsg5: incoming msg 5 (src: 0x33) rpmsg_client_sample rpmsg2: incoming msg 6 (src: 0x33) modprobe -r rpmsg_client_sample or rmmod rpmsg_client_sample
 * Execution starts when the module is loaded.
 * Sample output here:
 * To rerun the sample, the module needs to be removed and reinstalled (repeat step #1)

OMX Sample
The OMX Sample is hosted within the SYS/BIOS RPMsg tree in the src/host folder, as there is no separate tree to host user-side samples/tests. The OMX sample uses the rpmsg_omx kernel module, and a ducati-m3.bin generated using the test_omx_sysm3.xem3 or test_omx_appm3.xem3 as one of the base images.

Build
A quick README in the tree gives the basic steps for building the sample. arm-none-linux-gnueabi-gcc omx_sample.c -o omx_sample -lpthread arm-none-linux-gnueabi-gcc omx_sample.c -o omx_sample -lpthread --static
 * For Linux, after copying the relevant files, you could build using
 * For Android, you need to either build it using an Android.mk file and build it in an existing userspace directory, or you could build within the kernel using static linkage to remove any external dependencies from Android FS.
 * Copy the resulting omx_sample binary to the target filesystem bin folder.

Execution
To execute the sample run the following commands, once all the rpmsg kernel modules are loaded: Following is a sample output: omx_sample: Connected to OMX omx_sample (1): OMX_GetHandle (H264_decoder). omx_sample (1): Got omx_handle: 0x5c0ffee5 omx_sample(1): OMX_SetParameter (0x5c0ffee5) omx_sample (1): Got result 0 omx_sample (2): OMX_GetHandle (H264_decoder). omx_sample (2): Got omx_handle: 0x5c0ffee5 omx_sample(2): OMX_SetParameter (0x5c0ffee5) omx_sample (2): Got result 0 omx_sample (3): OMX_GetHandle (H264_decoder). omx_sample (3): Got omx_handle: 0x5c0ffee5 omx_sample(3): OMX_SetParameter (0x5c0ffee5) omx_sample (3): Got result 0 omx_sample (4): OMX_GetHandle (H264_decoder). omx_sample (4): Got omx_handle: 0x5c0ffee5 omx_sample(4): OMX_SetParameter (0x5c0ffee5) omx_sample (4): Got result 0 omx_sample (5): OMX_GetHandle (H264_decoder). omx_sample (5): Got omx_handle: 0x5c0ffee5 omx_sample(5): OMX_SetParameter (0x5c0ffee5) omx_sample (5): Got result 0 omx_sample (6): OMX_GetHandle (H264_decoder). omx_sample (6): Got omx_handle: 0x5c0ffee5 omx_sample(6): OMX_SetParameter (0x5c0ffee5) omx_sample (6): Got result 0 omx_sample (7): OMX_GetHandle (H264_decoder). omx_sample (7): Got omx_handle: 0x5c0ffee5 omx_sample(7): OMX_SetParameter (0x5c0ffee5) omx_sample (7): Got result 0 omx_sample (8): OMX_GetHandle (H264_decoder). omx_sample (8): Got omx_handle: 0x5c0ffee5 omx_sample(8): OMX_SetParameter (0x5c0ffee5) omx_sample (8): Got result 0 omx_sample (9): OMX_GetHandle (H264_decoder). omx_sample (9): Got omx_handle: 0x5c0ffee5 omx_sample(9): OMX_SetParameter (0x5c0ffee5) omx_sample (9): Got result 0 omx_sample (10): OMX_GetHandle (H264_decoder). omx_sample (10): Got omx_handle: 0x5c0ffee5 omx_sample(10): OMX_SetParameter (0x5c0ffee5) omx_sample (10): Got result 0 omx_sample: Closed connection to OMX!
 * 1) ./omx_sample [ ]
 * 1) ./omx_sample 10

RPMsg ResMgr Sample
RPMsg supports resource (IVA, FDIF, GPT,etc) requests from the remote processors through the rpmsg_resmgr kernel module. This sample validates the request and release of resources, and also to test any PM constraints like Latency, BandWidth or Frequency on some of these constraints.

Build
The RPMsg ResMgr Sample also leverages the same base images as the RPMsg kernel or client samples. However, the resource manager task must be enabled specifically in the SYS/BIOS RPMsg sample source code. This is currently commented out since test_omx_sysm3.xem3 is being used as the default baseimage in various product releases, and enabling the task may conflict with actual MM usecases.

To enable it, edit sysbios-rpmsg/src/ti/examples/srvmgr/test_omx.c. At the end of the file, change the #if to include start_resmgr_task. /* Run a background task to test rpmsg_resmgr service */ start_resmgr_task;
 * 1) if CORE0
 * 1) endif

Execution
The sample is executed when rpmsg_resmgr module is installed modprobe rpmsg_resmgr The example output below may not be exactly what you will get. Other resources may be omitted or added, or traces may be disabled. Console output: omap_hwmod: iva: failed to hardreset omap_device: rpres.0: new worst case activate latency 0: 255645751 omap_hwmod: iva_seq0: failed to hardreset omap_device: rpres.1: new worst case activate latency 0: 257904052 omap_hwmod: iva_seq1: failed to hardreset Printing the trace0 output shows the following: CORE0 starting.. 4 resources at 0x8006a000 copyTask 50: Entered...: VirtQueue_startup: buf_addr address of 0xa0000000 received MessageQCopy_create endPt created: 50 registering rpmsg-client-sample service on 50 with HOST MessageQCopy_send: no object for endpoint: 53 copyTask 51: Entered...: MessageQCopy_create endPt created: 51 registering rpmsg-client-sample service on 51 with HOST Connecting to resmgr server ... MessageQCopy_create endPt created: 101 MessageQCopy_create endPt created: 60 serviceMgr: started on port: 60 registering rpmsg-omx service on 60 with HOST ...connected to resmgr server. Requesting IPU status -7 Requesting GPT 3 status -7 Releasing GPT 3 Requesting gpio 50 status 0 Releasing gpio 50 Requesting 5 sdma channels status 0 Releasing 5 sdma channels Requesting IVAHD status 0 Requesting IVASEQ0 status 0 Requesting IVASEQ1 status 0 Requesting SL2IF status 0 Releasing IVASEQ1 Releasing IVASEQ0 Releasing SL2IF Releasing IVAHD Requesting ISS status 0 Releasing ISS
 * 1) cat  /sys/kernel/debug/remoteproc/omap-rproc.1/trace0