imx7d/imx6d rom_start section relocation for proper remoteproc firmware loading #71617
-
To follow our discussion on Discord :-) I would like to discuss the fact that IMX7D and IMX6 need the bootvector aka sp/pc to be located into the OCRAM_S area for proper booting using remoteproc. As of now, Zephyr places the isr vectors (the rom_start section) into ocram/ocram_s/tcm/ddr as per the chosen zephyr,flash parameter in the DT. But the linux rproc driver doesn't have the code necessary to systematically copy the first 8 bytes of the rom_start section onto the boot_vector for the M4 as mentionned by NXP's AN5317. Instead the elf-loader is supposed to load the section properly as per the definitions in the linker file. When you look at FREERTOS examples the full vector table itself is placed explicitely into OCRAM_S regardless of is the code itself is located in OCRAM/DDR/TCM. It actually means that for all rproc that needs SP/PC to be loaded onto a specific location, we need to relocate the the rom_start section onto a specific memory area, a change of the linker script is necessary. At the moment, I've implemented it in my zephyr/fork: I've done the following changes: Adding a new memory area in the linker script with kconfig flags:
in /zephyr/include/arch/arm/cortex_m/scripts/linker.ld
and then in /zephyr/soc/nxp/imx/imx7d/Kconfig.defconfig:
In turns that generates the correct elf file with the section for rom_start always being located into the OCRAM_S 0x000180000 location.
Remoteproc now boots the M4 correctly with these changes :-) even if it wasn't started from u-boot. Any comments and ideas if this is a good idea to upstream this change and if yes, how would you recommend proceeding ? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
I am glad to see you refine my suggestions in Discord into a more general implementation, I think it is okay to upstream these updates but with some extra suggestions:
Maybe you can initial an PR, then have more discussion with Maintainers. |
Beta Was this translation helpful? Give feedback.
-
While I was preparing the PR, I figured something out in the linux imx_rproc #driver: The address translation tables indicate that the address 0 is translated tot the right boot-vector location. Therefore a default value of 0x00000000 and size 1K for the bootvector by default KCONFIG is correct for IMX7D/IMX6SX/IMX8M.
I also need to have a default flag for CONFIG_ROMSTART_RELOCATION_ROM selected only if the selected zephyr,flash reg address doesn't match the boot-vector address. I have tested it on my IMX7D and it still boots when placing the code in OCRAM and boot-vector at address 0x00000000 into 1K size
Do you have any ideas on how to do that ?
What do think about it ? |
Beta Was this translation helpful? Give feedback.
-
This discussion has been addressed by PR: #71684, so let's close this discussion. |
Beta Was this translation helpful? Give feedback.
This discussion has been addressed by PR: #71684, so let's close this discussion.