I am working with the verdin AM62 on a custom carrier board. I would like to use the cortex M4 processor to run real time applications like SPI,… To start I just wanted to load the hello_world example from the TI SDK.
I was able to compile the project and it generated the hello_world.release.out file (not a .elf, but does a .out file work as well?). I put this file on the verdin AM62, used the remoteproc driver to load and start the M4 core, but here something goes wrong. When I look at dmesg, I see the following error:
[ 341.790825] remoteproc remoteproc0: powering up 30074000.pru
[ 341.796873] remoteproc remoteproc0: Booting fw image hello_world.release.out, size 279376
[ 341.796928] remoteproc remoteproc0: bad phdr da 0x8200 mem 0x5380
[ 341.803033] remoteproc remoteproc0: Failed to load program segments: -22
[ 341.810209] remoteproc remoteproc0: Boot failed: -22
Am I missing something? I made no changes in the code or in the device tree. I am using Torizon OS.
Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!
Did you like my answer?
The error message you’re encountering, “bad phdr da 0x8200 mem 0x5380,” suggests that there is an issue with the program header in the firmware file you’re trying to load. The .out file format is typically used by TI’s tools and may not be directly compatible with the RemoteProc framework, which expects an ELF file format.
Here are a few steps you can take to resolve this issue:
Convert the .out file to an ELF file: Use TI’s tools to convert the .out file to an ELF file. The RemoteProc framework expects an ELF file, which contains the necessary program headers for loading the firmware correctly.
Check the Firmware Path: Ensure that the firmware file is placed in a location that is accessible by the RemoteProc framework. Since Torizon OS has a read-only filesystem, you might need to place the firmware in a writable location like /tmp/ and update the path accordingly.
Verify Device Tree Overlays: Make sure that the correct device tree overlays are enabled for the M4 core. This can be done by checking the overlays.txt file and ensuring the appropriate overlay is listed.
Check Compatibility: Ensure that the firmware is compatible with the specific version of the RemoteProc driver and the hardware configuration of the Verdin AM62.
If these steps do not resolve the issue, you may need to consult additional resources or support from TI or Toradex to ensure compatibility and correct configuration.
Please, also check if these links can help you solve your problem:
I already ran the hello_world example on Cortex M4 of Verdin AM62 and it can be very tricky.
You can use hello_world.release.out as Cortex M4 firmware.
In order to validate it, you must change your device tree overlay for the verdin-am62_hmp_overlay.dts (if you didn’t do it, please follow this article). After this, you can copy hello_world.release.out to /lib/firmware. You probably won’t have permission to do that (if you are using Torizon OS), because /usr is a read-only directory, so you must do the following:
Then, after it boots, you’ll see Hello World! on Cortex M4 terminal.
I strongly recommend following this way, at least for validation purposes, because, in my opinion, this is the easiest way. After you validate it, you can start to customize the paths and file names.
After my initial post I did indeed use the overlay that you’ve also mentioned, but this did not change anything at that moment.
I copied the firmware to the location like you suggested (I am indeed using Torizon OS). Looking at dmesg it appears that the firmware is loaded correctly:
[ 7.931432] k3-m4-rproc 5000000.m4fss: assigned reserved memory node m4f-dma-memory@9cb00000
[ 7.931832] k3-m4-rproc 5000000.m4fss: configured M4 for remoteproc mode
[ 7.952856] k3-m4-rproc 5000000.m4fss: local reset is deasserted for device
[ 7.962731] remoteproc remoteproc0: 5000000.m4fss is available
[ 7.969084] remoteproc remoteproc0: powering up 5000000.m4fss
[ 7.969131] remoteproc remoteproc0: Booting fw image am62-mcu-m4f0_0-fw, size 266704
However, I do not see any output on the M4 terminal yet. I will check if there is maybe a conflict with UART0 somewhere, altough I disabled it in the devicetree.
Also: when I try to run it via remoteproc after the system is rebooted, it fails loading the firmware:
The overlay does not do anything “visible” but reserves the memory that rproc assigns for cortex M4.
Could you please detail the steps you took to build the hello_world example? Also, what board did you select to build (in TI’s MCU), and did you have to make changes on SysConfig?
The thing about the overlay was meant to say that I had tested the firmware again after applying the overlay, but the errors persisted
For building the example, I followed the exact steps in the following link:
I downloaded the SDK for the AM62x devices, installed all dependencies and libraries and finally I build the example via the make command.
I did not change anything in the sysconfig and I build the example under the folders …/am62x-sk/m4fss0-0_nortos/
Today I tried building the RPMSG example and this worked almost. The firmware was loaded correctly, the core was started and the M4 terminal showed an output. I am just not able to send an echo from linux to the M4 via /dev/rpmsg0. There is no error, but nothing gets received by the M4. This makes me believe that the hello-world example is missing the resource-table or something related. I need to compare both examples to figure it out
I think I found the problem. I checked the SysConfig for m4fss0-0_nortos and I saw that IPC was not enabled, and it must be enabled because it is responsible for the inter-processor communication (as its name suggests).
Although, if you just enable it in SysConfig, you will get a memory space error. To bypass it, you can go to the IPC tab on SysConfig and reduce the number and the size of RPMessage buffers (as far as I tested, 64 buffers of 64 bytes should be reduced enough to bypass the error).
After that, you can deploy the firmware to the module and load it as I explained before, and you should see the “Hello World!” on Cortex M4 terminal.
I just realized that, for some reason, the module is rebooting when I use m4fss0-0_nortos, but I tried m4fss0-0_freertos with the same SysConfig and it worked.
So, for validation purposes, I think you can use m4fss0-0_freertos.
I tried your SysConfig modification on both the freertos and nortos firmware and I can confirm that for me both of these are working as expected now!
Now that this is validated, I can start developing the application on the M4. The goal is to use the M4 to read an SPI interface and simultaneously write these measurements to a shared memory so Linux can access it. Do you know of any other ‘tricks’ or things I should keep in mind with the TI environment and the AM62 module?
About TI’s environment, I would say that it is good to start from their examples.
I verified and they have an SPI example in /path-to-mcu/examples/drivers/mcspi, you could start from there and then try to reproduce your own. I did something similar when I was working with CAN communication using Cortex M4.
Another important point is to always check SysConfig, it is the base of TI’s environment and sometimes a simple configuration can change everything in the project.
If you have any other doubts or issues, please feel free to open another topic.