For the product I'm working on, we want to use the M4 for a particular feature.
I rather use remoteproc than U-Boot, to load the M4 firmware. I found that there is remoteproc support in the 5.4 Linux kernel.
I found that the MCUXpresso SDK for i.MX 8M Mini has some projects that can build ELF files suitable for loading with remoteproc. Eg under boards/evkmimx8mm/multicore_examples/rpmsg_lite_str_echo_rtos. I found that doing ./build_release.sh builds the ELF file to be loaded into TCM (tightly coupled memory) and remoteproc is able to load that.
I worked out the device tree changes I needed to make, by looking at imx8mm-evk-rpmsg.dts in the 5.4 kernel source.
So, I am having some success with my own code based off one of the NXP examples in the MCUXpresso SDK.
I had trouble once my M4 firmware got above a certain size, that it would no longer load. I found that the NXP kernel branch 5.4-2.3.x-imx has a fix for imx_rproc.c to combine TCMU and TCML into one block, which fixes this problem.
I was curious to know if I could compile my M4 code to run in DDR memory. I tried doing ./build_ddr_release.sh. I found that the remoteproc driver wasn't able to load it. I am a bit unsure if the M4 is really able to execute code at 0x80000000 (the address the example project links at). I wonder if I need to change the address specified in m4_reserved in the reserved-memory in the device tree, and add <&m4_reserved> to memory-region for imx8mm-cm4. Any advice on this would be appreciated.
It would be helpful for NXP to document this so it's easier to work it out (I really appreciate that these examples exist, but I did have to hunt for some time to find them and figure out how to use them successfully).
If the right kernel features are enabled, then you should have a /sys/class/remoteproc/remoteproc0/ which represents the interface to the M4.
If you do:
$ cat sys/class/remoteproc/remoteproc0/firmware
That name rproc-imx-rproc-fw is the required filename of the M4 ELF file, under /lib/firmware/. Maybe it could be different for a different Linux kernel.
So, copy the ELF file that was built by the SDK ./build_release.sh command onto the target board, and rename it to /lib/firmware/rproc-imx-rproc-fw.
To run the firmware, do:
$ echo start > sys/class/remoteproc/remoteproc0/state
I am afraid such special document is not available, one can look at general description on
NXP provides a document called "Getting Started with MCUXpresso SDK for i.MX 8M Mini". Document Number MCUXSDKIMX8MMGSUG.
That document describes loading M4 firmware using U-Boot. It would be logical to update it to describe loading firmware using remoteproc, as well as building the ELF file that is suitable for use with remoteproc.
Is this available now?
I would think that working with the M4 core in parallel with Linux would be a common use case. Is NXP still recommending its customers to refer to ST documentation?