RPMsg Kernel Client Application

From Texas Instruments Wiki
Jump to: navigation, search

Introduction

The page illustrates how to build and run an rpmsg Linux kernel space client to communicate with a slave processor (e.g. DSP, IPU, etc) using IPC's RPMessage module.

Generally it is recommended to perform core-to-core communication from user space, typically using MessageQ. User space is a more application-friendly environment without GPL constraints, and with fewer compatibility breaks between kernel releases. But some use cases may require kernel space IPC, so this article describes how that can be done.

Requirements

  • IPC 3.10.02 or greater
  • Linux Kernel with rpmsg and Remoteproc features enabled

Build

This section outlines how to build both the Linux kernel rpmsg client and corresponding RPMessage slave-side application.

Linux client app

Recent Linux kernel releases contain an rpmsg client sample that can be built as a module. As of Linux kernel version 3.11 or less, the rpmsg client sample build is broken and requires some manual steps to build.

The Linux-side sample module is located in the samples/rpmsg directory of the Linux kernel sources.

Edit the Makefile in the samples/rpmsg directory to include only the following line:

obj-m := rpmsg_client_sample.o

NOTE: The $(CONFIG_SAMPLE_RPMSG_CLIENT) string was replaced with m in the Makefile.

Issue the following command to build the application as a module. Replace the variables below to the appropriate location of the Linux kernel sources and the ARM's cross-compiler tools.

make -C $(KERNEL_INSTALL_DIR) M=$(KERNEL_INSTALL_DIR)/samples/rpmsg ARCH=arm CROSS_COMPILE=$(TOOLCHAIN_INSTALL_DIR)/bin/arm-none-linux-gnueabi- modules

This results with an rpmsg_client_sample.ko file located in the samples/rpmsg directory of your Linux kernel. Copy the file to your device’s file-system.

SYS/BIOS slave app

The IPC distribution contains a corresponding RPMessage based slave application. Follow the IPC Install Guide for building the SYS/BIOS-side of IPC appropriate for your device. Once the build completes, navigate to the $(IPC_INSTALL_DIR)/packages/ti/ipc/tests/bin/<PLATFORM> directory. There you will find an ping_tasks.x<suffix> file. Copy the file to your device's file-system.

Run

This section outlines how to load and run the previous built applications.

Slave-side app

The Linux kernel's remoteproc features are used to load the slave core(s). The slave core binary(s) must be copied into the /lib/firmware directory of your device's file-system and renamed appropriately for the target device.

For DRA7XX, the files should be as follows:

dra7-dsp1-fw.xe66
dra7-dsp2-fw.xe66
dra7-ipu1-fw.xem4
dra7-ipu2-fw.xem4

Execute the following to load the slave core(s) on your target's file-system.

target# modprobe remoteproc
target# modprobe omap_remoteproc

The slave-core application(s) are now loaded.

Linux-side app

The Linux kernel's rpmsg driver must be installed onto the running kernel assuming the driver has been built as the kernel module. To install in, execute the following on the target.

target# modprobe rpmsg_proto

The rpmsg client application is implemented as a kernel module. It's written to send/receive 100 messages from the slave core(s). To run the rpmsg client module, execute the following on the target.

 target# modprobe rpmsg_server_sample

or

target# insmod rpmsg_server_sample.ko

The output should resemble the following:

rpmsg_client_sample rpmsg0: new channel: 0x400 -> 0x32!
rpmsg_client_sample rpmsg1: new channel: 0x401 -> 0x33!
rpmsg_client_sample rpmsg0: incoming msg 1 (src: 0x32)
rpmsg_client_sample rpmsg0: incoming msg 2 (src: 0x32)
rpmsg_client_sample rpmsg0: incoming msg 3 (src: 0x32)
.
.
.

To re-run the application, the module needs to be removed and re-installed (repeat step above).

 target# modprobe -r rpmsg_server_sample

or

target# rmmod rpmsg_server_sample