Colibri IMX7 RPMsg kernel upgrade

On the Colibri iMX7D we are using both, Linux as main OS and the M4-Core running with FreeRTOS.

  • The M4 is programmed in u-boot during boot.
  • For communication we use a the imx_rpmsg_tty.ko kernel modul.

Everything works as expected on Kernel toradex_5.4-2.3.x-imx
https://git.toradex.com/cgit/linux-toradex.git/log/?h=toradex_5.4-2.3.x-imx

In our devicetree the only modifications required were adding:

...
&rpmsg {
	status = "okay";
};
&uart2 {
	 status = "disabled"; // for m4 
};
...

Now I’m trying to update our Linux Kernel to a more recent version. I’would prefer going mainline but if I’m correctly informed the RPMsg from NXP is not supported.
Therefore I started some test with newer Kernel versions from Toradex and NXP:
https://git.toradex.com/cgit/linux-toradex.git/log/?h=toradex_ti-linux-6.1.y

Unfortunately I’m not able to bring it up.

What I did so far:

  • Extended the Devicetree with the missing parts
  • Enabled debug level in involved kernel drivers

Devicetree modifications (not sure yet if I need all the ocram parts)

diff --git a/arch/arm/boot/dts/nxp/imx/imx7s.dtsi b/arch/arm/boot/dts/nxp/imx/imx7s.dtsi
index fe220d3d225c..3cdcf7731232 100644
--- a/arch/arm/boot/dts/nxp/imx/imx7s.dtsi
+++ b/arch/arm/boot/dts/nxp/imx/imx7s.dtsi
@@ -143,6 +143,40 @@ soc: soc {
 		interrupt-parent = <&gpc>;
 		ranges;
 
+		ocrams_ddr: sram@900000 {
+			compatible = "fsl,ddr-lpm-sram";
+			reg = <0x900000 0x1000>;
+			clocks = <&clks IMX7D_OCRAM_CLK>;
+		};
+
+		ocram: sram@901000 {
+			compatible = "mmio-sram";
+			reg = <0x901000 0x1f000>;
+			clocks = <&clks IMX7D_OCRAM_CLK>;
+		};
+
+		ocrams: sram@180000 {
+			compatible = "fsl,lpm-sram";
+			reg = <0x180000 0x8000>;
+			clocks = <&clks IMX7D_OCRAM_S_CLK>;
+			status = "disabled";
+		};
+
+		ocrams_mf: sram-mf@900000 {
+			compatible = "fsl,mega-fast-sram";
+			reg = <0x900000 0x20000>;
+			clocks = <&clks IMX7D_OCRAM_CLK>;
+		};
+
+		ocram_optee {
+			compatible = "fsl,optee-lpm-sram";
+			reg = <0x180000 0x8000>;
+			overw_reg = <&ocrams_ddr 0x904000 0x1000>,
+					<&ocram 0x905000 0x1b000>,
+					<&ocrams 0x900000 0x4000>;
+			overw_clock = <&ocrams &clks IMX7D_OCRAM_CLK>;
+		};
+
 		funnel@30041000 {
 			compatible = "arm,coresight-dynamic-funnel", "arm,primecell";
 			reg = <0x30041000 0x1000>;
@@ -1153,6 +1187,15 @@ uart7: serial@30a90000 {
 				status = "disabled";
 			};
 
+			mu: mu@30aa0000 {
+				compatible = "fsl,imx7d-mu";
+				reg = <0x30aa0000 0x10000>;
+				interrupts = <GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&clks IMX7D_MU_ROOT_CLK>;
+				clock-names = "mu";
+				#mbox-cells = <2>;
+			};
+
 			mu0a: mailbox@30aa0000 {
 				compatible = "fsl,imx7s-mu", "fsl,imx6sx-mu";
 				reg = <0x30aa0000 0x10000>;
@@ -1294,6 +1337,20 @@ fec1: ethernet@30be0000 {
 				fsl,stop-mode = <&gpr 0x10 3>;
 				status = "disabled";
 			};
+
+			rpmsg: rpmsg{
+				compatible = "fsl,imx7d-rpmsg";
+				/* up to now, the following channels are used in imx rpmsg
+				* - tx1/rx1: messages channel.
+				* - general interrupt1: remote proc finish re-init rpmsg stack
+				*   when A core is partition reset.
+				*/
+				mbox-names = "tx", "rx", "rxdb";
+				mboxes = <&mu 0 1
+					&mu 1 1
+					&mu 3 1>;
+				status = "disabled";
+			};
 		};
 
 		dma_apbh: dma-controller@33000000 {

Our top level devicetree

/ {
       ...
	memory {
		linux,usable-memory = <0x80000000 0x1ff00000>;
	};
	reserved-memory {
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;

		m4_reserved: m4@9fe00000 {
			no-map;
			reg = <0x9fe00000 0x1fffff>;
		};
		rpmsg_vrings: vrings0@8ff00000 {
			compatible = "shared-dma-pool";
			no-map;
			reg = <0x8ff00000 0x100000>;
		};
	};
	m4_tcm: tcml@7f8000 {
		compatible = "fsl, m4_tcml";
		reg = <0x007f8000 0x8000>;
	};
};
&ocram {
	reg = <0x00901000 0xf000>;
};
&mu {
	status = "okay";
};
&rpmsg {
	vdev-nums = <1>;
	reg = <0x8fff0000 0x10000>;
	memory-region = <&rpmsg_vrings>;
	status = "okay";
};
&uart2 {
	status = "disabled"; // used by M4
};
...

kernel boot log (dmesg | grep ‘rpmsg|mu’)

[    0.036894] imx mu driver is registered.
[    0.036935] imx rpmsg driver is registered.
[    0.060903] imx-rpmsg 8fff0000.rpmsg: assigned reserved memory node vrings0@8ff00000
[    0.060923] imx-rpmsg 8fff0000.rpmsg: imx_rpmsg_probe rpdev vdev1: vring0 0x8fff0000, vring1 0x8fff8000
[    0.060958] virtio virtio0: imx_rpmsg_set_status new status: 1
[    0.067363] MU is ready for cross core communication!
[    0.095430] virtio_rpmsg_bus virtio0: imx_rpmsg_set_status new status: 2
[    0.095489] imx-rpmsg 8fff0000.rpmsg: vring0: phys 0x8fff0000, virt 0x(ptrval)
[    0.095540] imx-rpmsg 8fff0000.rpmsg: vring1: phys 0x8fff8000, virt 0x(ptrval)
[    0.095673] virtio_rpmsg_bus virtio0: buffers: va (ptrval), dma 0x8ff00000
[    0.096191] virtio_rpmsg_bus virtio0: imx_rpmsg_set_status new status: 4
[    0.120184] virtio_rpmsg_bus virtio0: rpmsg host is online
[    0.120198] virtio_rpmsg_bus virtio0: imx_rpmsg_set_status new status: 4
cat /sys/firmware/devicetree/base/soc/aips-bus@30800000/rpmsg/status
okay

kernel boot log (dmesg | grep ‘rpmsg|mu’) from a system with Kernel version toradex_5.4-2.3.x-imx

[    0.051690] imx mu driver is registered.
[    0.052410] imx rpmsg driver is registered.
[    0.053600] MU is ready for cross core communication!
[    0.089199] virtio_rpmsg_bus virtio0: rpmsg host is online
[    0.089238] virtio_rpmsg_bus virtio0: creating channel rpmsg-openamp-demo-channel addr 0x0

What I’m missing in the log is the following output line:

...
[    0.089238] virtio_rpmsg_bus virtio0: creating channel rpmsg-openamp-demo-channel addr 0x0
...

I’ve also seen that the interrupt is not starting to count but I think this is a consecutive fault

cat /proc/interrupts | grep imx_mu
 30:          0          0     GPCV2  88 Edge      imx_mu_chan[0-1], imx_mu_chan[1-1], imx_mu_chan[3-1], imx-mu-lp

from a system with Kernel version toradex_5.4-2.3.x-imx

cat /proc/interrupts | grep imx_mu
 53:          3          0     GPCV2  88 Edge      imx_mu_chan[0-1], imx_mu_chan[1-1], mx_mu_chan[3-1], imx-mu-lp

Can someone point me to the right direction what part I’m missing to bring it up.

Thanks in advice

Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Handshake,

Transitioning to a newer Linux kernel version while maintaining RPMsg functionality requires careful attention to compatibility and configuration details. Based on the information you’ve provided, it seems you have made significant progress in adapting your device tree for the newer kernel version. However, the absence of the expected log message and the interrupt not counting suggest there might be issues with the RPMsg channel initialization or interrupt configuration.

Here are a few suggestions and areas to investigate:

  1. RPMsg Channel Initialization: The missing log message about the RPMsg channel creation might indicate that the channel initialization between the Linux side and the M4 side is not happening as expected. Ensure that the RPMsg channel names used in your FreeRTOS application on the M4 core match those expected by the Linux side. Any mismatch in channel names or IDs can prevent successful communication establishment.

  2. Interrupt Configuration: The fact that the interrupt count for the imx_mu is not increasing suggests that the interrupt is either not being triggered or not correctly configured. Double-check the interrupt configuration in your device tree, especially the interrupts and interrupt-parent properties for the MU (Messaging Unit) and ensure they match the hardware specifications and the Linux kernel’s expectations for the newer version.

  3. Device Tree Consistency: Ensure that your device tree modifications for the newer kernel version are consistent with any changes or requirements introduced in the newer kernel. This includes verifying compatibility strings, required properties, and the structure of the device tree nodes related to RPMsg, MU, and reserved memory regions.

  4. Kernel Configuration: Verify that the kernel configuration (defconfig) includes all necessary options for RPMsg, VirtIO, and the Messaging Unit (MU). The configuration options you listed (CONFIG_RPMSG_CHAR, CONFIG_RPMSG_VIRTIO, etc.) are essential, but ensure no additional configurations are required by the newer kernel version.

  5. Debugging and Logs: Increase the verbosity of the kernel log messages related to RPMsg and the Messaging Unit to gain more insights into what might be going wrong. Look for any errors or warnings during the boot process that could indicate issues with the RPMsg subsystem initialization or communication.

  6. Software Versions: Ensure that the versions of the software running on the M4 core are compatible with the newer Linux kernel version you are moving to. Incompatibilities between the RPMsg implementations on the two cores can lead to communication failures.

  7. Community and Kernel Sources: While direct support from Toradex or reviewing specific documentation is

Please, also check if these links can help you solve your problem:

Running FreeRTOS on the Cortex-M4 of a Colibri iMX7 | Toradex Developer Center.

Hello @msommer,

Welcome to the Toradex Community! Thanks for posting the question and for providing all the necessary information.

I see a mistake regarding the kernel verison on a first look. You are using the wrong kernel branch from Toradex. The branch toradex_ti-linux-6.1.y is for our Texas Instruments-based modules. You are using a NXP-based module and you want to have the upstream kernel. Therefore you should use linux.git, and the branch linux-6.1.y. This is also documented here: Build Linux Kernel from Source Code | Toradex Developer Center
and
First Steps with Device Trees | Toradex Developer Center

Could you please try again with the right kernel version? In the meantime, I am going to check internally to see if we have any progress on the HMP overlay file for colibri imx7.

Hello

What happens if you remove above line? If U-Boot launches M4, which writes to vring memory announcing device is present, then on Linux only virtio/rpmsg drivers should be able to overwrite that memory, else announcement may be lost and no dice.

Hello @rudhi.tx

Thank you for your answer.
I will try the correct kernel version. I’ll come back with the outcome.

Hello @Edward

Thank you for your answer.
Without the compatible = "shared-dma-pool";

[    0.036987] imx mu driver is registered.
[    0.037028] imx rpmsg driver is registered.
[    0.061839] imx-rpmsg 8fff0000.rpmsg: dev doesn't have specific DMA pool.
[    0.061857] imx-rpmsg 8fff0000.rpmsg: imx_rpmsg_probe rpdev vdev1: vring0 0x8fff0000, vring1 0x8fff8000
[    0.061891] virtio virtio0: imx_rpmsg_set_status new status: 1
[    0.067271] MU is ready for cross core communication!
[    0.095215] virtio_rpmsg_bus virtio0: imx_rpmsg_set_status new status: 2
[    0.095272] imx-rpmsg 8fff0000.rpmsg: vring0: phys 0x8fff0000, virt 0x(ptrval)
[    0.095322] imx-rpmsg 8fff0000.rpmsg: vring1: phys 0x8fff8000, virt 0x(ptrval)
[    0.095719] virtio_rpmsg_bus virtio0: buffers: va (ptrval), dma 0x9c040000
[    0.096237] virtio_rpmsg_bus virtio0: imx_rpmsg_set_status new status: 4
[    0.120279] virtio_rpmsg_bus virtio0: rpmsg host is online
[    0.120293] virtio_rpmsg_bus virtio0: imx_rpmsg_set_status new status: 4
...
[    0.061839] imx-rpmsg 8fff0000.rpmsg: dev doesn't have specific DMA pool.
...

It makes no difference.

I’ starting now on the linux-6.1.y branch. I’ll come back with the outcome.