.elf loader for M4 core. How to load an ".elf file"?

Hi @Edge,

Sorry for the delay.

I created an overlay for you to use the remote proc driver from NXP (imx_rproc.c) with our downstream kernel.
This driver is not enabled by default in our downstream kernel, so in order to use that, the easiest way is to bitbake a new image and add a custom layer with the modified kernel config file.

Please, follow these two guides on how to set up your Yocto environment and also how to customize it with a custom meta-layer:

To make things easier, you can use this custom meta layer that I created here with the necessary kernel config to enable the remote proc: Download - Toradex File Sharing Platform

With the custom image with the imx-rproc enabled, you can add the following overlay to your image:

/dts-v1/;
/plugin/;

#include <dt-bindings/clock/imx7d-clock.h>

/ {
	compatible = "toradex,colibri-imx7d",
		     "toradex,colibri-imx7d-emmc",
		     "toradex,colibri-imx7s";
};

&{/} {
	imx7d-cm4 {
		compatible = "fsl,imx7d-cm4";
        syscon = <&src>;
		clocks =  <&clks IMX7D_ARM_M4_ROOT_CLK>;
		mbox-names = "tx", "rx", "rxdb", "txdb";
		mboxes = <&mu 0 1
			  &mu 1 1
			  &mu 3 1
			  &mu 2 1>;
		memory-region = <&m4_reserved>;
        status = "okay";
	};
};

Or you can download it here: Download - Toradex File Sharing Platform (I already compiled it, so you can simply copy it to your /boot/overlays folder and enable it. More information here: Device Tree Overlays (Linux) | Toradex Developer Center)

After that, you can reboot your module and the imx-rproc should be ready:

# dmesg | grep rproc
remoteproc remoteproc0: imx-rproc is available

Copy your .elf file to /lib/firmware and then run the following commands:

# cat /sys/class/remoteproc/remoteproc0/state
offline
# echo hello_world.elf > /sys/class/remoteproc/remoteproc0/firmware
# echo start > /sys/class/remoteproc/remoteproc0/state
[ 7818.651262] remoteproc remoteproc0: powering up imx-rproc
[ 7818.659563] remoteproc remoteproc0: Booting fw image hello_world.elf, size 156628
[ 7818.667654] remoteproc remoteproc0: no dtb rsrc-table
[ 7818.672786] imx-rproc imx7d-cm4: No resource table in elf
[ 7818.728362] remoteproc remoteproc0: remote processor imx-rproc is now up

Now you can control the m4 with the “state” file (starting, stopping…) and point the firmware inside /lib/firmware with the /sys/class/remoteproc/remoteproc0/firmware file.

Please, let me know if all the steps are clear and if you need any help with that.

Also, if you would like to use rpmsg with the remote proc, more modifications will be needed, as pointed out by @Edward in this thread: iMX7D 5.4.x kernel. Launching M4 FW using remoteproc - #23 by Edward

Let me know if you wish to use rpmsg, so we can work out a new device tree and a patch to uboot.

Best Regards,
Hiago.