How to communicate with M4 on the Verdin AM62 through ttyRPMSG

Hello Toradex Community,

first: here is our setup:

Software summary
------------------------------------------------------------
Bootloader:               U-Boot
Kernel version:           6.1.46-6.5.0+git.8e6a2ddd4fe6 #1-TorizonCore SMP PREEMPT Thu Dec 21 17:08:38 UTC 2023
Kernel command line:      root=LABEL=otaroot rootfstype=ext4 quiet logo.nologo vt.global_cursor_default=0 plymouth.ignore-serial-consoles splash fbcon=map:3 ostree=/ostree/boot.1/torizon/59c201478c9930c51af6b232132519c5ca010e1baecac1df2876a5daa3e77467/0
Distro name:              NAME="TorizonCore"
Distro version:           VERSION_ID=6.5.0-build.8
Distro variant:           VARIANT="Docker"
Hostname:                 verdin-am62-15207085
------------------------------------------------------------

Hardware info
------------------------------------------------------------
HW model:                 Toradex Verdin AM62 on Verdin Development Board
Toradex version:          0075 V1.1A
Serial number:            15207085
Processor arch:           aarch64
------------------------------------------------------------

We’ve been trying to communicate with the M4F on the SOC over the rpmsg. We’ve already enabled the appropritate overlay (verdin-am62_hmp_overlay.dts). But there is no /dev/rpmsg_tty to communicate though.
The description here RPMsg TTY Example says that you have to load the module like: modprobe imx_rpmsg_tty. But there is no module to load since its a different processor.

Here are some outputs:

available kernel modules:

torizon@verdin-am62-15207085:~$ find /lib/modules/$(uname -r) -type f -name '*rpm*.ko'
/lib/modules/6.1.46-6.5.0+git.8e6a2ddd4fe6/kernel/samples/rpmsg/rpmsg_client_sample.ko
/lib/modules/6.1.46-6.5.0+git.8e6a2ddd4fe6/kernel/drivers/rpmsg/rpmsg_pru.ko
/lib/modules/6.1.46-6.5.0+git.8e6a2ddd4fe6/kernel/drivers/rpmsg/virtio_rpmsg_bus.ko
/lib/modules/6.1.46-6.5.0+git.8e6a2ddd4fe6/kernel/drivers/rpmsg/rpmsg_char.ko
/lib/modules/6.1.46-6.5.0+git.8e6a2ddd4fe6/kernel/drivers/rpmsg/rpmsg_ctrl.ko
/lib/modules/6.1.46-6.5.0+git.8e6a2ddd4fe6/kernel/drivers/rpmsg/rpmsg_ns.ko
torizon@verdin-am62-15207085:~$ lsmod |grep "rpm"
rpmsg_client_sample    20480  0
rpmsg_ctrl             16384  0
rpmsg_char             16384  1 rpmsg_ctrl
virtio_rpmsg_bus       24576  0
rpmsg_ns               20480  1 virtio_rpmsg_bus

rpmsg config:

torizon@verdin-am62-15207085:~$ zcat /proc/config.gz | grep -i config_rpmsg
# CONFIG_RPMSG_TTY is not set
CONFIG_RPMSG=y
CONFIG_RPMSG_CHAR=m
CONFIG_RPMSG_CTRL=m
CONFIG_RPMSG_NS=m
# CONFIG_RPMSG_QCOM_GLINK_RPM is not set
CONFIG_RPMSG_VIRTIO=m
CONFIG_RPMSG_PRU=m
CONFIG_RPMSG_KDRV=y
# CONFIG_RPMSG_KDRV_DEMO is not set
# CONFIG_RPMSG_KDRV_DISPLAY is not set
CONFIG_RPMSG_KDRV_ETH_SWITCH=y

Questions

  • How can we get the /dev/rpmsg_tty?
  • Which module has to be loaded?
  • Do we have to modify the device tree overlay somehow like described here Verdin Mini RPMSG imx_rpmsg_tty Issue?
  • And/or do we have to add something to the tcbuild.yaml file for the TorizonCoreBuilder?

Thanks in advance,
Uwe

@buw3,

Ti refers to the auxiliary cores of its SoC as Programmable Realtime Unit (PRU). The character devices show up as /dev/rpmsg_pruN.
Devices /dev/rmpsg_tty are created by the imx_rpmsg_tty` driver which does not apply for TI AM62. The rpmsg_pru driver was never upstreamed, hence CONFIG_RPMSG_PRU does not apply to a standard kernel.
Yes, you will need a DT overlay with the memory carveouts for the PRU. Typically something like this:

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

        mcu_m4fss_dma_memory_region: m4f-dma-memory@9cb00000 {
                compatible = "shared-dma-pool";
                reg = <0x00 0x9cb00000 0x00 0x100000>;
                no-map;
        };

        mcu_m4fss_memory_region: m4f-memory@9cc00000 {
                compatible = "shared-dma-pool";
                reg = <0x00 0x9cc00000 0x00 0xf00000>;
                no-map;
        };
};

Of course the memory carveouts have to match with the M4 core external memory section sizes in their linker mapfiles.
The device will not show up unless the M4 core is running and has an endpoint established.
For kernel config you also need: CONFIG_PRU_REMOTEPROC

Hello @buw3,

I would recommend that you use Torizon OS 6.6.1 or newer when using the Cortex-M4 in the Verdin AM62.
The reason for this is that the overlay verdin-am62_hmp_overlay.dts was only officially introduced on BSP 6.6, therefore previous versions may not work with it.
The overlay is also included by default with the Torizon OS 6.6.1 release.

In this overlay, some necessary reserved memory areas are defined, as @RudolfStreif mentioned, and the required mailbox is setup.


This example is not applicable to the Verdin AM62, as it contains quite a lot of NXP-specific information and code.

Also, as you saw in the kernel configuration, the generic driver for RPMSG tty is not enabled on Torizon OS.
If this ends up being a requirement for your project, we can evaluate enabling it by default.


The topic of development for the Cortex-M4 of the Verdin AM62 is still unfortunately not documented on our side.
My recommendation is that you look at the TI documentation on the topic.

Best Regards,
Bruno

Hello @bruno.tx,

thank you for the answer. I will look into the links you have given.
And I will also update to the newest Torizon OS release, even though the the memory reservation seems to work with the older version.

… this would be the best for our project. How long will this may take? The sources for this seem to be already in there!? (see rpmsg_tty.c)

Kind Regards,
Uwe

Hello @buw3,

If it really is just a configuration change with the driver already available, it usually takes just a few days for it to be added to a nightly Torizon OS image.

I will put a request for this configuration change and the Torizon OS team will evaluate it. When we have updates, I will send them on this thread.

Best Regards,
Bruno