Embed M7 firmware in TorizonCore and load it automatically on Verdin iMX8M-Mini

This message from @hfranco.tx describes the necessary steps to:

  1. copy the firmware for M7 core into TorizonCore
  2. load it into M7
  3. start it

There are two possiiblities: bootaux (I think this is "from thebootloadwer u-boot) and remoteproc (from TorizonCore).

After the firmware for M7 has been built (.elf or .bin file), which is the suggested way to “automate” the previous steps in the TorizonCore image?
Do I need a custom container that does the previous steps automatically?
Is this different for bootaux or remoteproc?


Hi @vix,

In general, I recommend using the bootaux command from u-boot instead of using the remote proc approach. The difference is that bootaux u-boot will load the M7 binary before the kernel even starts, so it’s the fastest way to turn on your M7 cortex.

The remote proc approach uses the linux kernel driver called imx_rproc, which will launch the M7 cortex using the linux userspace. So the positive side here is that you can control your M7 with the userspace (reload the M7, change the binary) without rebooting, but you have to do everything manually after the kernel has started (takes more time and more commands).

Also, it has been reported some errors with this remote proc driver from NXP, so you can face some errors that are not yet fixed.

To automate the u-boot part, please check this article: How to load compiled binaries into Cortex-M | Toradex Developer Center

You can do this manually on the u-boot terminal and save the files or change the u-boot environment variables file inside the Tezi image.

Let me know if you have any questions.

Best Regards,

1 Like

Thanks @hfranco.tx
I’m going with bootaux since in the next few weeks I start working with iMX8M-Plus and (in another message) you told me that remoteproc doesn’t work yet on the Plus under BSP 6/TorizonCore 6.

I have some questions and suggestions on the article How to load compiled binaries into Cortex-M | Toradex Developer Center:

The Introduction says

this article will cover only two methods, described in the next sections.

but only EXT4LOAD Loading Method is described. Probably the info in Introduction should be fixed.

In section EXT4LOAD Loading Method I see

Follow the next steps to load the binary from the eMMC where the OS Image is, using EXT4LOAD.

and I suggest to add “from u-boot” so that everything is clearer at a first sight to a not-experienced user too (like me).

For the steps form 1 ongoing, it’s not immediately clear which one should be executed while the SoM is running Linux/TorizonCore, and which one while is running u-boot.
As far as I understand, point 1 should be executed while the SoM is running Linux, then the device should be rebooted and halted to u-boot to execute all the other steps in EXT4LOAD Loading Method section.

Can you confirm this?
Do yoy think that clarifying the documentation can help other users?


Hi @vix,

You’re correct, we had the “FATLOAD” method as well where you can load the binary from an SD card for example, and we forgot to fix the introduction. I will fix that.

Noted, I will add that too, thanks for the feedback.

Yes, you’re correct, I mentioned to you the remote proc approach but we don’t have any documents about the remote proc yet. As I said earlier, we know that the remote proc doesn’t always work and sometimes gives some kernel panics, that’s why we didn’t document this approach yet. We’re still testing it to create a guide in the future.

I really appreciate the input, currently, we don’t have too many customers using the Cortex-M to provide more feedback, so any input from you is highly appreciated.

Best Regards,

Hi @vix,

Article updated: How to load compiled binaries into Cortex-M | Toradex Developer Center


Let me know if you need anything else. Any feedback is appreciated.

If this topic is solved, can you please mark one of the answers above as solved?

Best Regards,

1 Like

One more question, how should I customize TorizonCore to do this?
As a general idea, I suppose:

  • add the firmware to TorizonCore filesystem
  • add steps to add the m4boot to the “bootcmd” alias

But how can I do this?
Customizing docker-compose.yml for the first step?
How to tweak u-boot?

Hi @vix,

I tested myself here and this can be accomplished with the image.json inside the image file. Since we’re dealing with U-Boot, TorizonCore Builder is not useful, since we can’t change U-Boot setting with it.

In this case, I simply added a few lines to my image.json and the u-boot-initial-end-sd files.

Here are the steps:

  • First, I downloaded an image from our feed, torizon-core-docker-verdin-imx8mm-Tezi_6.1.0+build.1 in my case, but you can choose a different one.
  • Next, I moved my Cortex-M binary inside this folder:
.rwxr-xr-x       6,260 hiago hiago 23 Mar 16:34  hello_world.bin
.rw-r--r--       1,566 hiago hiago 23 Mar 16:41  image.json
.rw-r--r--   1,314,376 hiago hiago 16 Jan 11:29  imx-boot
.rw-r--r--      79,368 hiago hiago 16 Jan 12:00  LA_OPT_NXP_SW.html
.rw-r--r--     212,480 hiago hiago 16 Jan 11:33  marketing.tar
.rw-r--r--         183 hiago hiago 16 Jan 11:33  prepare.sh
.rw-r--r--       2,488 hiago hiago 16 Jan 11:33  toradexlinux.png
.rw-r--r-- 217,362,695 hiago hiago 16 Jan 11:59  torizon-core-docker-verdin-imx8mm.ota.tar.zst
.rw-r--r--       4,232 hiago hiago 23 Mar 16:35  u-boot-custom-env-sd
.rw-r--r--       4,127 hiago hiago 16 Jan 10:04  u-boot-initial-env-sd
.rw-r--r--          18 hiago hiago 16 Jan 11:33  wrapup.sh
  • Now, you need to edit the image.json to copy the binary when Toradex Easy Installer is going to install your image.
--- image.json.old	2023-03-24 13:43:59.939387885 -0300
+++ image.json	2023-03-23 16:41:59.023515994 -0300
@@ -30,7 +30,8 @@
                         "filesystem_type": "ext4",
                         "mkfs_options": "-E nodiscard",
                         "filename": "torizon-core-docker-verdin-imx8mm.ota.tar.zst",
-                        "uncompressed_size": 599.375
+                        "uncompressed_size": 599.375,
+			"filelist": ["hello_world.bin:/ostree/deploy/torizon/var/"]

So in this case I’m telling Toradex Easy Installer to move m binary to /var/ when it’s going to install TorizonCore.

  • Finally, I added the variables to u-boot-initial-env-sd to automatically start the auxiliary core.
--- u-boot-initial-env-sd	2023-01-16 10:04:52.846678207 -0300
+++ u-boot-custom-env-sd	2023-03-23 16:35:53.519128019 -0300
@@ -1,4 +1,4 @@
-bootcmd=run bootcmd_mmc0
+bootcmd=run m4boot; run bootcmd_mmc0
@@ -53,5 +53,6 @@
 setup=setenv setupargs console=tty1 console=${console},${baudrate} consoleblank=0 earlycon
 update_uboot=askenv confirm Did you load flash.bin (y/N)?; if test "$confirm" = "y"; then setexpr blkcnt ${filesize} + 0x1ff && setexpr blkcnt ${blkcnt} / 0x200; mmc dev 0 1; mmc write ${loadaddr} 0x2 ${blkcnt}; fi
+m4boot=load mmc 0:1 ${loadaddr} 0x7e0000; cp.b ${loadaddr} 0x7e0000 10000; bootaux 0x7e0000;

In this case, I assume you’re using TCM memory, that’s why I used 0x7e0000.

After flashing the image, your binary will be in place and will also be started automatically.

I also did a test with the platform and did an OS update and the Cortex-M kept working. I’m not sure what’s going to happen if you do a bootloader remote update, because we need to make sure u-boot saves this custom m4boot variable.

Hope this helps.

Best Regards,