Multicore RPMsg-Lite demo

The Multicore RPMsg-Lite string echo project from the MCUXpresso SDK demonstrates inter-core communication between Linux (Cortex-A) and the Cortex-M coprocessor on NXP i.MX8 (8M Mini/Nano/Plus) and i.MX9 (93) modules.

Linux acts as the RPMsg master: it waits for user input on the RPMsg virtual tty, sends it to the coprocessor, which echoes it back as an acknowledgement.

Precautions

The following must be in place (all are covered by the Ka-Ro BSP — see Development environment setup):

  • U-Boot supports the bootaux command

  • the distro feature copro is enabled (DISTRO_FEATURES:append = " copro")

  • the karo-copro devicetree overlay is loaded (provides the reserved memory areas and the Cortex-M remoteproc/boot support in the Linux devicetree)

  • the Linux kernel provides the imx_rpmsg_tty module

Starting the coprocessor firmware from U-Boot

Assuming the firmware (rpmsg_lite_str_echo_rtos.bin) is stored in the bootfs partition. The TCM and DRAM addresses differ per SoC:

SoC (coprocessor)

TCM boot (copy to / bootaux)

DRAM boot (load address / bootaux)

i.MX 8M Mini/Nano (Cortex-M4)

cp.b ${fileaddr} 0x7e0000 0x20000 / bootaux 0x7e0000

load mmc ${mmcdev}:1 0x77000000 ... / bootaux 0x77000000

i.MX 8M Plus (Cortex-M7)

cp.b ${fileaddr} 0x7e0000 0x20000 / bootaux 0x7e0000

load mmc ${mmcdev}:1 0x80000000 ... / bootaux 0x80000000

i.MX 93 (Cortex-M33)

cp.b ${fileaddr} 0x201e0000 0x20000 / bootaux 0x1ffe0000 0

use the remoteproc method below

For a DRAM boot, the firmware’s linker script (MEMORY section in the board’s linker file) must be adapted to the addresses defined in the Linux devicetree (for the shared RPMsg memory, adjust VDEV0_VRING_BASE and RESOURCE_TABLE_OFFSET in board.h, e.g. 0x81100000 / 0xFF000 on i.MX8M Plus). Always run dcache flush after loading to DRAM.

Example (i.MX 8M Mini, TCM boot):

load mmc ${mmcdev}:1 ${loadaddr} rpmsg_lite_str_echo_rtos.bin
cp.b ${fileaddr} 0x7e0000 0x20000
bootaux 0x7e0000

The coprocessor starts and prints on its debug UART:

RPMSG String Echo FreeRTOS RTOS API Demo...

Note

On i.MX93 the MCUXpresso SDK board files target NXP eval boards; the debug UART pins differ on Ka-Ro devkits (QSBASE93 / MB7). Use LPUART3 on pads GPIO_IO14/GPIO_IO15 instead — set BOARD_DEBUG_UART_INSTANCE 3U and mux IOMUXC_PAD_GPIO_IO15__LPUART3_RX / IOMUXC_PAD_GPIO_IO14__LPUART3_TX in pin_mux.c.

Linux side

Boot Linux from U-Boot. When the RPMsg link comes up, the coprocessor prints:

Nameservice sent, ready for incoming messages...

Load the RPMsg tty module:

modprobe imx_rpmsg_tty

You now have the virtual device /dev/ttyRPMSG30 — send a test string:

echo "hello world!" > /dev/ttyRPMSG30

Starting the firmware via remoteproc (sysfs)

Instead of bootaux from U-Boot, Linux can start/stop the coprocessor firmware through the remoteproc framework (e.g. imx8mp-cm7 on i.MX8M Plus, imx93-cm33 on i.MX93).

Optionally set a custom firmware search path (default paths are described in the kernel firmware search path documentation), either via the kernel command line:

setenv append_bootargs debug clk_ignore_unused firmware_class.path=/mnt
saveenv

or from Linux:

echo -n /mnt > /sys/module/firmware_class/parameters/path

Then select the firmware and start the remote processor (example for i.MX93):

echo -n rpmsg_lite_str_echo_rtos_imxcm33.elf > /sys/devices/platform/imx93-cm33/remoteproc/remoteproc0/firmware
echo start > /sys/devices/platform/imx93-cm33/remoteproc/remoteproc0/state

Stop it with echo stop > .../state and check the state with cat /sys/class/remoteproc/remoteproc0/state (stop an online remote processor before starting a new firmware). Afterwards load imx_rpmsg_tty as shown above.