M4 app stuck on rpmsg_lite_is_link_up

Hi @nmohan86,

Sorry for the delay, after debugging the driver, I was able to solve this issue. Turns out there is a property on the device tree that is required and I missed, even though is not well documented as required on the iMX RPMSG documentation from NXP. Here is the new overlay:

/dts-v1/;
/plugin/;

#include <dt-bindings/firmware/imx/rsrc.h>

/ {
	compatible = "toradex,colibri-imx8x";
};

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

		vdev0vring0: vdev0vring0@90000000 {
			reg = <0 0x90000000 0 0x8000>;
			no-map;
		};

		vdev0vring1: vdev0vring1@90008000 {
			reg = <0 0x90008000 0 0x8000>;
			no-map;
		};

		vdev1vring0: vdev1vring0@90010000 {
			reg = <0 0x90010000 0 0x8000>;
			no-map;
		};

		vdev1vring1: vdev1vring1@90018000 {
			reg = <0 0x90018000 0 0x8000>;
			no-map;
		};

		rsc_table: rsc_table@900ff000 {
			reg = <0 0x900ff000 0 0x1000>;
			no-map;
		};

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

	rpmsg: rpmsg@0 {
		compatible = "fsl,imx8qxp-rpmsg";
		reg = <0 0x90000000 0 0x20000>;
		mbox-names = "tx", "rx", "rxdb";
		mboxes = <&lsio_mu5 0 1
			  &lsio_mu5 1 1
			  &lsio_mu5 3 1>;
		memory-region = <&vdevbuffer>;
		mub-partition = <3>;
		vdev-nums = <2>;
	};
};

Although I separated the vdev buffers, I don’t think that’s really necessary in this case. But anyways, the missing part was:

		memory-region = <&vdevbuffer>;

where we need to tell the driver where is our shared DMA memory.

Now, when I boot the Colibri iMX8X with this overlay enabled, I can see the channel being created:

root@colibri-imx8x-06995602:~# dmesg | grep -i rpmsg
[    0.314140] imx rpmsg driver is registered.
[    2.107181] imx-rpmsg 90000000.rpmsg: assigned reserved memory node vdevbuffer
[    2.120302] virtio_rpmsg_bus virtio0: rpmsg host is online
[    2.122296] virtio_rpmsg_bus virtio0: creating channel rpmsg-i2c-channel addr 0x1
[    2.140946] virtio_rpmsg_bus virtio1: rpmsg host is online
[    2.141067] i2c-rpmsg virtio0.rpmsg-i2c-channel.-1.1: new channel: 0x400 -> 0x1!
[    2.141130] virtio_rpmsg_bus virtio1: creating channel rpmsg-openamp-demo-channel addr 0x1e

Now I can modprobe the driver:

root@colibri-imx8x-06995602:~# modprobe imx_rpmsg_tty
[   27.582079] imx_rpmsg_tty virtio1.rpmsg-openamp-demo-channel.-1.30: new channel: 0x400 -> 0x1e!
[   27.591143] Install rpmsg tty driver!

And it works:

root@colibri-imx8x-06995602:~# echo -n Toradex > /dev/ttyRPMSG30

M4 debug UART:

RPMSG String Echo FreeRTOS RTOS API Demo...

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

Here are my enabled overlays:

root@colibri-imx8x-06995602:~# cat /boot/overlays.txt 
fdt_overlays=colibri-imx8x_vga-640x480_overlay.dtbo colibri-imx8x_hmp_overlay.dtbo

And I booted the M4 from the boot partition as well, with u-boot:

Colibri iMX8X # load mmc 0:1 ${loadaddr} rpmsg_lite_str_echo_rtos.bin
67720 bytes read in 6 ms (10.8 MiB/s)
Colibri iMX8X # dcache flush
Colibri iMX8X # bootaux ${loadaddr} 
Power on aux core 0
Copy image from 0x95c00000 to 0x34fe0000
Start M4
bootaux complete
Colibri iMX8X # setenv fdt_high 0xffffffffffffffff
Colibri iMX8X # 
Colibri iMX8X # saveenv 
Saving Environment to MMC... Writing to MMC(0)... OK
Colibri iMX8X # boot

I installed the Multimedia image from our feeds, version 6.3.0-build.7:

root@colibri-imx8x-06995602:~# tdx-info 

Software summary
------------------------------------------------------------
Bootloader:               U-Boot
Kernel version:           5.15.77-6.3.0+git.ddc6ca4d76ea #1 SMP PREEMPT Thu Jun 29 10:14:22 UTC 2023
Kernel command line:      root=PARTUUID=3cccb3bf-02 ro rootwait console=tty1 console=ttyLP3,115200 consoleblank=0 earlycon video=imxdpufb5:off video=imxdpufb6:off video=imxdpufb7:off
Distro name:              NAME="TDX Wayland with XWayland"
Distro version:           VERSION_ID=6.3.0-build.7
Hostname:                 colibri-imx8x-06995602
------------------------------------------------------------

Hardware info
------------------------------------------------------------
HW model:                 Toradex Colibri iMX8QXP on Colibri Evaluation Board V3
Toradex version:          0038 V1.0D
Serial number:            06995602
Processor arch:           aarch64
------------------------------------------------------------

Finally, because I’m using the Colibri Development Board, I changed the UART pins in the MCUXpresso M4 code so I could see the debug messages from Cortex-M on pin SODIMM_146:

diff --git a/boards/mekmimx8qx/multicore_examples/rpmsg_lite_str_echo_rtos/pin_mux.c b/boards/mekmimx8qx/multicore_examples/rpmsg_lite_str_echo_rtos/pin_mux.c
index 7339c00..391d914 100644
--- a/boards/mekmimx8qx/multicore_examples/rpmsg_lite_str_echo_rtos/pin_mux.c
+++ b/boards/mekmimx8qx/multicore_examples/rpmsg_lite_str_echo_rtos/pin_mux.c
@@ -70,12 +70,12 @@ void BOARD_InitPins(sc_ipc_t ipc)                          /*!< Function assigne
   {
       assert(false);
   }
-  err = sc_pad_set_all(ipc, BOARD_INITPINS_M40_UART0_RX_PIN_FUNCTION_ID, 1U, SC_PAD_CONFIG_NORMAL, SC_PAD_ISO_OFF, 0x0 ,SC_PAD_WAKEUP_OFF);/* IOMUXD_ADC_IN2 register modification value */
+  err = sc_pad_set_all(ipc, BOARD_INITPINS_M40_UART0_RX_PIN_FUNCTION_ID, 2U, SC_PAD_CONFIG_NORMAL, SC_PAD_ISO_OFF, 0x0 ,SC_PAD_WAKEUP_OFF);/* IOMUXD_ADC_IN2 register modification value */
   if (SC_ERR_NONE != err)
   {
       assert(false);
   }
-  err = sc_pad_set_all(ipc, BOARD_INITPINS_M40_UART0_TX_PIN_FUNCTION_ID, 1U, SC_PAD_CONFIG_NORMAL, SC_PAD_ISO_OFF, 0x0 ,SC_PAD_WAKEUP_OFF);/* IOMUXD_ADC_IN3 register modification value */
+  err = sc_pad_set_all(ipc, BOARD_INITPINS_M40_UART0_TX_PIN_FUNCTION_ID, 2U, SC_PAD_CONFIG_NORMAL, SC_PAD_ISO_OFF, 0x0 ,SC_PAD_WAKEUP_OFF);/* IOMUXD_ADC_IN3 register modification value */
   if (SC_ERR_NONE != err)
   {
       assert(false);
diff --git a/boards/mekmimx8qx/multicore_examples/rpmsg_lite_str_echo_rtos/pin_mux.h b/boards/mekmimx8qx/multicore_examples/rpmsg_lite_str_echo_rtos/pin_mux.h
index 900d8ef..b76b299 100644
--- a/boards/mekmimx8qx/multicore_examples/rpmsg_lite_str_echo_rtos/pin_mux.h
+++ b/boards/mekmimx8qx/multicore_examples/rpmsg_lite_str_echo_rtos/pin_mux.h
@@ -14,10 +14,10 @@
  **********************************************************************************************************************/
 
 /* ADC_IN2 (coord V32), M40_UART0_RX */
-#define BOARD_INITPINS_M40_UART0_RX_PIN_FUNCTION_ID                 SC_P_ADC_IN2   /*!< Pin function id */
+#define BOARD_INITPINS_M40_UART0_RX_PIN_FUNCTION_ID                 SC_P_SCU_GPIO0_00    /*!< Pin function id */
 
 /* ADC_IN3 (coord V30), M40_UART0_TX */
-#define BOARD_INITPINS_M40_UART0_TX_PIN_FUNCTION_ID                 SC_P_ADC_IN3   /*!< Pin function id */
+#define BOARD_INITPINS_M40_UART0_TX_PIN_FUNCTION_ID                 SC_P_SCU_GPIO0_01   /*!< Pin function id */
 
 /* ADC_IN0 (coord U35), M4_I2C0_1V8_SCL */
 #define BOARD_INITPINS_M4_I2C0_1V8_SCL_PIN_FUNCTION_ID              SC_P_ADC_IN0   /*!< Pin function id */

I did this because we don’t have access to the default pins from MCUXpresso.

if you want to try it yourself, here is the compiled overlay: https://share.toradex.com/5bim7bz2bnqaudc (it will be available for 3 months).

Let me know if you have any questions!

Best Regards,
Hiago.