Build and run of Multicore RPMsg-Lite demo

The Multicore RPMsg-Lite string echo project is a simple demonstration program that uses the MCUXpresso SDK software and the RPMsg-Lite library and shows how to implement the inter-core communicaton between cores of the multicore system.

It works with Linux RPMsg master peer to transfer string content back and forth. The name service handshake is performed first to create the communication channels. Next, Linux OS waits for user input to the RPMsg virtual tty. Anything which is received is sent to M4. M4 displays what is received, and echoes back the same message as an acknowledgement. The tty reader on the Linux side can get the message, and start another transaction. The demo demonstrates RPMsg’s ability to send arbitrary content back and forth.

precautions

The following precautions must be met to run the Multicore RPMsg-Lite demo:

  • the u-boot must support the bootaux command
  • the Linux must provide imx_rpmsg_tty kernel module
  • the Linux device tree must support the Cortex®-M4 and reserved memory areas for communication of the two cores.

please note

Ka-Ro electronics provides a special yocto layer in the download area that provides the necessary u-boot patches, kernel configs and device tree changes.

kernel configurations

add the IMX_RPMSG_TTY feature to your kernel configuration:

../../../_images/cm4-imx-rpmsg-tty-drivers.png

add the IMX_REOMOTEPROC feature to your kernel configuration:

../../../_images/cm4-remoteproc-support.png

device tree

setup reseved memory regions for intercore communication and specify imx8mm-cm4 node:

reserved-memory {
  #address-cells = <2>;
  #size-cells = <2>;
  ranges;

  m4_reserved: m4@0x80000000 {
    no-map;
    reg = <0 0x80000000 0 0x1000000>;
  };

  vdev0vring0: vdev0vring0@b8000000 {
    reg = <0 0xb8000000 0 0x8000>;
    no-map;
  };

  vdev0vring1: vdev0vring1@b8008000 {
     reg = <0 0xb8008000 0 0x8000>;
    no-map;
  };

  rsc-table {
     reg = <0 0xb80ff000 0 0x1000>;
    no-map;
  };

  vdevbuffer: vdevbuffer@b8400000 {
     compatible = "shared-dma-pool";
     reg = <0 0xb8400000 0 0x100000>;
     no-map;
  };

  rsc_table: rsc_table@b8000000 {
     reg = <0 0xb8000000 0 0x8000>;
  };
};

imx8mm-cm4 {
   compatible = "fsl,imx8mm-cm4";
   rsc-da = <0xb8000000>;
   clocks = <&clk IMX8MM_CLK_M4_DIV>;
   mbox-names = "tx", "rx", "rxdb";
   mboxes = <&mu 0 1
      &mu 1 1
      &mu 3 1>;
      memory-region = <&vdevbuffer>, <&vdev0vring0>, <&vdev0vring1>, <&rsc_table>;
      syscon = <&src>;
};

specify the reserved memory regions for the Remote Processor Messaging Framework:

&rpmsg{
/*
  * 64K for one rpmsg instance:
  * --0xb8000000~0xb800ffff: pingpong
  */
  vdev-nums = <1>;
  reg = <0x0 0xb8000000 0x0 0x10000>;
  memory-region = <&vdevbuffer>;
  status = "disabled";
};

do not forget to disable devices for Linux needed by the coprocessor :

&uart4 {
   status = "disabled";
};

&uart2 {
   status = "disabled";
};

boot cortxm4

Assuming the coprocessor firmware is stored in the bootfs partition, the coprocessor is booted with the following commands:

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

boot Linux

Boot the Linux with the boot command from u-boot.

load module

Load the imx_rpmsg_tty kernel module:

insmod /lib/modules/5.10.35-1.0.0+g99a35ce31539/kernel/drivers/rpmsg/imx_rpmsg_tty.ko

you should now find a virtual device /dev/ttyRPMSG30.

using a yocto layer meta-karo-nxp-m4 for setup

The Ka-Ro download area provides a Yocto layer that provides all features to run the multicore example on a TX8M. Look into the Cortex-M4 folder in the TX8M download area.

Setup your build-directory with the desired machine and distro like explained in Bitbake Setup.

DISTRO=karo-minimal MACHINE=tx8m-1610 source karo-setup-release.sh -b build-tx8m-1610

Copy the m4-layer meta-karo-nxp-m4 to your sources folder.

To make your layer available, add it to conf/bblayers.conf inside your build-directory.

(...)
BBLAYERS += "${BSPDIR}/sources/meta-karo-nxp"
BBLAYERS += "${BSPDIR}/sources/meta-karo-nxp-distro"
BBLAYERS += "${BSPDIR}/sources/meta-karo-nxp-m4"