I am trying to enable remoteproc to control M7. imx_rproc driver seems to be working. I am using the following device tree (at post end) . I have seen limited success , I am able stop start and load demo app firmware provided by mcuexprosso. How ever the existing firmware that we were using is not working.
The firmware(.bin) works fine with u-boot. But when i try to use firmware(.elf) using remoteproc it fails to kick complaining about address translation failed . I have looked into the issue and attached some relevent info below but i dont see any obvious issue. My guess is the linker script provided by MCUexpresso has some issue or i am not using it correctly.
Device tree used.
refer to the application note, how about define TCM memory in the dts?
https://www.nxp.com.cn/docs/en/application-note/AN5317.pdf
you can refer to the page 11
and let me remind, if you kick in the uboot, don't forget stop in the kernel then kick again
I stop the m7 before loading FW and kick
on your suggestion i have updated the device tree
what elf do yo use? it seems that this is elf issue, could you reproduce this on nxp imx8mp board? if yes, give me the detailed reproduce steps
Which elf did you use -> FreeRTOS based proprietary application that we developed It uses RPMSG-Lite to talk with host.
Since the elfs data section was not aligned with DTCM of iMX 8 Plus . It was crashing. We had 2 options.
Edit the linker script provided in MCUExpresso as mentioned in this thread https://community.toradex.com/t/error-in-m4-ocram-linker-file/8354/15
Or in the imx-rproc driver we could redefine ITCM and DTCM as a single TCM block. For now we have gone with the second option and are able to load FW.
Thank you for your help . We are stuck with different issue currently I will start a new thread for that.
this is tested elf list'
The i.MX8MN/P, the elf file list:
imx8m[n,p,m,q]_m[7,4]_TCM_hello_world.elf
imx8m[n,p,m,q]_m[7,4]_TCM_rpmsg_lite_pingpong_rtos_linux_remote.elf
imx8m[n,p,m,q]_m[7,4]_TCM_rpmsg_lite_str_echo_rtos.elf
imx8m[n,p,m]_m[7,4]_TCM_sai_low_power_audio.elf
so you can work with imx8mp_m7_TCM_hello_world.elf, but failed with your own elf, right?
I've hit the same problem as OP. Turned out there's bug in elf loader code. It uses physical address instead of virtual and puts stack+heap+bss in ITCM instead of DTCM. To hit that bug, your code+bss+stack+heap must be larger than the size of ITCM (0x20000 = 128K). You can modify stock examples by increasing stack and heap appropriately and they won't work either.
Here's the fix:
--- a/drivers/remoteproc/remoteproc_elf_loader.c
+++ b/drivers/remoteproc/remoteproc_elf_loader.c
@@ -173,7 +173,7 @@ int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw)
/* go through the available ELF segments */
for (i = 0; i < phnum; i++, phdr += elf_phdr_get_size) {
- u64 da = elf_phdr_get_p_paddr(class, phdr);
+ u64 da = elf_phdr_get_p_vaddr(class, phdr);
u64 memsz = elf_phdr_get_p_memsz(class, phdr);
u64 filesz = elf_phdr_get_p_filesz(class, phdr);
u64 offset = elf_phdr_get_p_offset(class, phdr);