We have some issue with the generated elf file that probably comes from the linker file. Issue is, that the m_data section gets placed at the wrong memory location. I found the problem because the elf loader from remoteproc issued an error.
[ 1944.561752] remoteproc remoteproc0: Booting fw image RTOScewo.elf, size 109220
[ 1944.576416] remoteproc remoteproc0: bad phdr da 0x91c2e0 mem 0x72e0
[ 1944.582750] remoteproc remoteproc0: Failed to load program segments: -22
[ 1944.589537] remoteproc remoteproc0: Boot failed: -22
If I understand this correctly the elf file tries to load a memory section of size 0x72e0 to address 0x91c2e0. This would overflow the m_text region (0x9235C0 > 0x920000).
/* Specify the memory areas */
MEMORY
{
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000240
m_text (RX) : ORIGIN = 0x00910000, LENGTH = 0x00010000
m_data (RW) : ORIGIN = 0x20220000, LENGTH = 0x00020000 /* EPDC */
}
I wondered why this was even possible and if there weren’t any memory size checks. Funny thing is, they exist, but they don’t see another issue. If I check the elf file with readelf I find this section:
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x001000 0x00000000 0x00000000 0x00240 0x00240 R 0x1000
LOAD 0x002000 0x00910000 0x00910000 0x0c2e0 0x0c2e0 RWE 0x1000
LOAD 0x00f000 0x20220000 0x0091c2e0 0x00210 0x072e0 RW 0x1000
So to me it seems that it places the m_data section into the m_text section. Issue is I don’t know how to resolve this as I don’t know how the virtual address resolution is done. I checked the nxp manuals. The 0x20220000 is an alias for the 0x00920000 region as it seems, but why is it then placed in the first section anyway?