RPMSG on Torizon 5 not working

Few days ago I decided to update my Verdin module. Installed latest TorizonCore image available on Easy Installer (TorizonCore 5.1.0+build.1.container).

I then tried to start rpmsg_echo example (it was working on 4.14.170-4.0.0 version of TorizonCore), i successfully flashed M4 core and got hello message on M4 UART, but didn’t detect Linux booted, I then try and run modprobe imx-rpmsg-tty but nothing happened on M4 side and no /dev/ttyRPMSG0 was created.

I had similar issue with TorizonCore 4 so I enabled rpmsg node in imx8mm.dtsi :

rpmsg: rpmsg{
		compatible = "fsl,imx8mq-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";
		status = "okay";
	};

I compiled the device tree and booted Linux with new .dtb file, but nothing changed, rpmsg link is still down and no /dev/ttyRPMSG0.

How do you enable RPMSG in new TorizonCore ?

Hi @spasoye,

Can you config and recompile kernel and drivers as well (I don’t know how hard it is for Torizon). Trying it on iMX7D, it looks to me like CONFIG_RPMSG_CHAR=y is show stopper for /dev/ttyRPMSG0. Disabling it in kernel config may help.

You should edit not device tree include file *.dtsi but higher level *.dts. Something like this in dts should do the same switch of status property to okay:

&rpmsg {
        status = "okay";
};

Edward

Thank you for your advice @Edward. But yes at this time we haven’t done the work yet from the Toradex side to validate and document RPSMG support on TorizonCore. Though it is something we plan to do.

@spasoye Could you please try what Edward has suggested and please let us know the results. It may help us in the future when it comes time for us to tackle this.

Best Regards,
Jeremias

Greetings @Edward and @jeremias.tx!

After loading that overlay, I get the following output on dmesg:

[    0.047507] imx rpmsg driver is registered.
[    1.327610] imx-rpmsg rpmsg: No vring buffer.
[    1.332023] imx-rpmsg: probe of rpmsg failed with error -12

12 is ENOMEM (out of memory). I’m kind of stuck here, I remember this indeed used to work on Torizon 4 with the 4.14 kernel. I’ve also tried the following overlay, which is based on the EVK one, but had the same results:

/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/clock/imx8mm-clock.h>

/ {
	compatible = "toradex,verdin-imx8mm";
    reserved-memory {
		#address-cells = <2>;
		#size-cells = <2>;
		ranges;

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

		vdev0vring0: vdev0vring0@b8000000 {
			compatible = "shared-dma-pool";
			reg = <0 0xb8000000 0 0x8000>;
			no-map;
		};

		vdev0vring1: vdev0vring1@b8008000 {
			compatible = "shared-dma-pool";
			reg = <0 0xb8008000 0 0x8000>;
			no-map;
		};

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

    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 = <&vdev0vring0>, <&vdev0vring1>, <&vdevbuffer>;
		syscon = <&src>;
	};
};

&rpmsg {
    status = "okay";
};

Ok, the following overlay fixes the error above:

/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/clock/imx8mm-clock.h>

/ {
	compatible = "toradex,verdin-imx8mm";
    reserved-memory {
		#address-cells = <2>;
		#size-cells = <2>;
		ranges;

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

		vdev0vring0: vdev0vring0@b8000000 {
			compatible = "shared-dma-pool";
			reg = <0 0xb8000000 0 0x8000>;
			no-map;
		};

		vdev0vring1: vdev0vring1@b8008000 {
			compatible = "shared-dma-pool";
			reg = <0 0xb8008000 0 0x8000>;
			no-map;
		};

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

    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 = <&vdev0vring0>, <&vdev0vring1>, <&vdevbuffer>;
		syscon = <&src>;
	};
};

&clk {
	init-on-array = <IMX8MM_CLK_UART4_ROOT
	IMX8MM_CLK_AHB IMX8MM_CLK_DRAM_CORE
	IMX8MM_CLK_NOC IMX8MM_CLK_NOC_APB
	IMX8MM_CLK_USB_BUS
	IMX8MM_CLK_MAIN_AXI IMX8MM_CLK_AUDIO_AHB
	IMX8MM_CLK_DRAM_APB IMX8MM_CLK_A53_DIV
	IMX8MM_ARM_PLL_OUT IMX8MM_CLK_DISP_AXI
	IMX8MM_CLK_DISP_APB
	>;
};

/*
 * ATTENTION: M4 may use IPs like below
 * ECSPI0/ECSPI2, GPIO1/GPIO5, GPT1, I2C3, I2S3, WDOG1, UART4, PWM3, SDMA1
 */

&i2c3 {
	status = "disabled";
};

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

&sdma1{
	status = "disabled";
};

&uart4 {
	status = "disabled";
};

&sdma3 {
	status = "disabled";
};

&sai3 {
	status = "disabled";
};

&sai1 {
	status = "disabled";
};

&sai2 {
	status = "disabled";
};

&flexspi {
	status = "disabled";
};

Now I have the following output on dmesg:

verdin-imx8mm-06602794:~$ dmesg | grep rpmsg
[    0.047611] imx rpmsg driver is registered.
[    1.392557] virtio_rpmsg_bus virtio0: rpmsg host is online

Can you please try that with your M4 firmware loaded?

Ok, so I was able to make this work.

Use this overlay. Start the rpmsg tty demo via U-Boot. In my case, I did the following:

Verdin iMX8MM # tftp 0x48000000 rpmsg_lite_str_echo_rtos_imxcm4.bin
Using ethernet@30be0000 device
TFTP from server 10.22.1.60; our IP address is 10.22.1.59
Filename 'rpmsg_lite_str_echo_rtos_imxcm4.bin'.
Load address: 0x48000000
Loading: ###
	 6.4 MiB/s
done
Bytes transferred = 33660 (837c hex)
Verdin iMX8MM # cp.b 0x48000000 0x7e0000 0x20000
Verdin iMX8MM # bootaux 0x7e0000
## Starting auxiliary core stack = 0x20020000, pc = 0x1FFE02FD...
Verdin iMX8MM # boot

You’ll get the following output on the M4 UART:

RPMSG String Echo FreeRTOS RTOS API Demo...

Nameservice sent, ready for incoming messages...

Linux will start and once you modprobe imx_rpmsg_tty, the /dev/ttyRPMSG30 device is going to show up and the M4 UART will print:

Get Message From Master Side : "hello world!" [len : 12]

Let me know whether this works for you.

Oops, sorry.
I meant RPMSG_VIRTIO_CHAR=y and not CONFIG_RPMSG_CHAR. With RPMSG_VIRTIO_CHAR enabled modprobing of imx_rpmsg_tty doesn’t create /dev/ttyRPMSG0. I had to disable it to make imx_rpmsg_tty working on iMX7D. But with RPMSG_VIRTIO_CHAR=y you have /dev/rpmsg_ctrl0 and multiple RPMSG endpoints.

Edward

@gustavo.tx @Edward @jeremias.tx thanks guys for prompt response.

I still haven’t managed to compile overlays, so I decided to modify and compile my imx8mm-verdin-wifi-rpmsg.dts file, I used @gustavo.tx code:

/dts-v1/;

#include "imx8mm-verdin.dtsi"
#include "imx8mm-verdin-wifi.dtsi"
#include "imx8mm-verdin-dev.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/clock/imx8mm-clock.h>

/ {
	model = "Toradex Verdin iMX8M Mini WB on Verdin Development Board";
	compatible = "toradex,verdin-imx8mm-wifi-dev",
		     "toradex,verdin-imx8mm-wifi",
		     "toradex,verdin-imx8mm",
		     "fsl,imx8mm";

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

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

		vdev0vring0: vdev0vring0@b8000000 {
			compatible = "shared-dma-pool";
			reg = <0 0xb8000000 0 0x8000>;
			no-map;
		};

		vdev0vring1: vdev0vring1@b8008000 {
			compatible = "shared-dma-pool";
			reg = <0 0xb8008000 0 0x8000>;
			no-map;
		};

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

	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 = <&vdev0vring0>, <&vdev0vring1>, <&vdevbuffer>;
		syscon = <&src>;
	};
};

&clk {
	init-on-array = <IMX8MM_CLK_UART4_ROOT
	IMX8MM_CLK_AHB IMX8MM_CLK_DRAM_CORE
	IMX8MM_CLK_NOC IMX8MM_CLK_NOC_APB
	IMX8MM_CLK_USB_BUS
	IMX8MM_CLK_MAIN_AXI IMX8MM_CLK_AUDIO_AHB
	IMX8MM_CLK_DRAM_APB IMX8MM_CLK_A53_DIV
	IMX8MM_ARM_PLL_OUT IMX8MM_CLK_DISP_AXI
	IMX8MM_CLK_DISP_APB
	>;
};

/*
* ATTENTION: M4 may use IPs like below
* ECSPI0/ECSPI2, GPIO1/GPIO5, GPT1, I2C3, I2S3, WDOG1, UART4, PWM3, SDMA1
*/

&i2c3 {
	status = "disabled";
};

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

&sdma1{
	status = "disabled";
};

&uart4 {
	status = "disabled";
};

&sdma3 {
	status = "disabled";
};

&sai3 {
	status = "disabled";
};

&sai1 {
	status = "disabled";
};

&sai2 {
	status = "disabled";
};

&flexspi {
	status = "disabled";
};

Successfully booted Linux and dmesg | grep rpmsg returned this:

vdev0vring0@b8000000 (0x00000000b8000000--0x00000000b8008000) overlaps with rpmsg@b8000000 (0x00000000b8000000--0x00000000b8400000)
               rpmsg@b8000000 (0x00000000b8000000--0x00000000b8400000) overlaps with vdev0vring1@b8008000 (0x00000000b8008000--0x00000000b8010000)
[    0.047661] imx rpmsg driver is registered.
[    1.401309] imx-rpmsg b8000000.rpmsg: assigned reserved memory node vdevbuffer@b8400000
[    1.401688] virtio_rpmsg_bus virtio0: rpmsg host is online
[    1.403020] virtio_rpmsg_bus virtio0: creating channel rpmsg-virtual-tty-channel-1 addr 0x1e
[   48.210838] imx_rpmsg_tty virtio0.rpmsg-virtual-tty-channel-1.-1.30: new channel: 0x400 -> 0x1e!
[   48.211329] Install rpmsg tty driver!

I managed to communicate with M4 core:

RPMSG String Echo FreeRTOS RTOS API Demo...

Nameservice sent, ready for incoming messages...
Get Message From Master Side : "hello world!" [len : 12]

Those “overlaps” warning considers rpmsg_reserved defined in imx8mm-verdin-v1.1.dtsi, also for some reason I cant see can0 interface.

@spasoye,

I was able to compile and apply that overlay with the TorizonCore Builder tool. Can you please try that?

After setting up TorizonCore builder, you should issue something like torizoncore-builder dto apply verdin-m4.dts where verdin-m4.dts is the overlay I posted. Then you can just deploy it to your current image or to a new image according to this article.

@gustavo.tx is it possible for me to just copy overlay .dtbo file after I run
torizoncore-builder dto apply device-trees/overlays/verdin-m4.dts ?

@spasoye,

Ideally, after issuing the dto apply command, you should then proceed with capturing the changes then deploying them directly on your target over network. That’s the supported and most elegant way to do this since it’ll correctly generate the ostree commits.

@spasoye,

I think it’s okay to get those warnings. dtc is used to compile full device-trees so sometimes it will complain a bit with overlays. Glad it’s working now!

@gustavo.tx sry for late response. I managed to compile your RPMSG overlay without using torizoncore builder.

I used latest version of DTC that I built:

git clone git://git.kernel.org/pub/scm/utils/dtc/dtc.git -b v1.6.0
cd dtc
make
make install

And then I followed this:

cpp -nostdinc -I ../../linux-toradex/arch/arm64/boot/dts -I ../../linux-toradex/include -undef -x assembler-with-cpp verdin-rpmsg-overlay.dts verdin-rpmsg-overlay.dts.preprocessed

dtc -@ -Hepapr -I dts -O dtb -i ../../linux-stable.git/arch/arm/boot/dts/ -o verdin-rpmsg-overlay.dtbo verdin-rpmsg-overlay.dts.preprocessed

I got lots of warnings:

verdin-rpmsg-overlay.dts:78.5-40: Warning (reg_format): /fragment@2/__overlay__:reg: property has invalid length (16 bytes) (#address-cells == 2, #size-cells == 1)
verdin-rpmsg-overlay.dts:12.9-16: Warning (ranges_format): /reserved-memory:ranges: empty "ranges" property but its #size-cells (2) differs from / (1)
verdin-rpmsg-overlay.dts:72.7-81.3: Warning (unit_address_vs_reg): /fragment@2/__overlay__: node has a reg or ranges property, but no unit name
verdin-rpmsg-overlay.dts:14.36-17.11: Warning (unit_address_format): /reserved-memory/m4@0x80000000: unit name should not have leading "0x"
verdin-rpmsg-overlay.dtbo: Warning (pci_device_reg): Failed prerequisite 'reg_format'
verdin-rpmsg-overlay.dtbo: Warning (pci_device_bus_num): Failed prerequisite 'reg_format'
verdin-rpmsg-overlay.dtbo: Warning (simple_bus_reg): Failed prerequisite 'reg_format'
verdin-rpmsg-overlay.dtbo: Warning (i2c_bus_reg): Failed prerequisite 'reg_format'
verdin-rpmsg-overlay.dtbo: Warning (spi_bus_reg): Failed prerequisite 'reg_format'
verdin-rpmsg-overlay.dts:9.21-36.7: Warning (avoid_default_addr_size): /reserved-memory: Relying on default #address-cells value
verdin-rpmsg-overlay.dts:9.21-36.7: Warning (avoid_default_addr_size): /reserved-memory: Relying on default #size-cells value
verdin-rpmsg-overlay.dts:72.7-81.3: Warning (avoid_default_addr_size): /fragment@2/__overlay__: Relying on default #address-cells value
verdin-rpmsg-overlay.dts:72.7-81.3: Warning (avoid_default_addr_size): /fragment@2/__overlay__: Relying on default #size-cells value
verdin-rpmsg-overlay.dtbo: Warning (avoid_unnecessary_addr_size): Failed prerequisite 'avoid_default_addr_size'
verdin-rpmsg-overlay.dtbo: Warning (unique_unit_address): Failed prerequisite 'avoid_default_addr_size'

But it still created verdin-rpmsg-overlay.dtbo. I then copied it to target /boot/ostree/torizon-number/dtb/overlays, changed overlays.txt, rebooted Verdin, started RPMSG M4 example and modprobed imx-rpmsg-tty. This time no overlap warning were returned and M4 returned:

 RPMSG String Echo FreeRTOS RTOS API Demo...
 
 Nameservice sent, ready for incoming messages...
 Get Message From Master Side : "hello world!" [len : 12]

I think its ok now.

Hello @gustavo.tx,
the link to the overlay you posted is broken.
Can you fix the link, please?

Hi @vix,

Just to confirm, do you want the overlay to enable the RPMsg on Verdin Mini TorizonCore 5?

Best Regards,
Hiago.

Hi @hfranco.tx
I need to overloay to enable RPMsg on Verdin Mini TorizonCore 6.
And, hopefully, instructions on how to edit my tcbuild.yaml to apply it.

I describe a little bit my tcbuild.yaml:
I use it together with torizoncore-builder, starting from
torizon-core-docker-verdin-imx8mm-Tezi_6.1.0-devel-202212+build.4.tar
and adding weston and chromium containers (bundled); I don’t need portainer.
And adding another container with my application (work in progress).

Hi @vix,

Understood, thanks for the information. That being said, could you please open a new ticket and tag me? Then we can continue from there.
I see this is an old thread and related to Torizon 5, so it’s better if we open a new ticket and continue from there. Others will benefit from this new information as well.

Thanks!

Best Regards,
Hiago.