memset(dst + phdr->p_filesz, 0x00, phdr->p_memsz - phdr->p_filesz);
This clears the leftovers of the memory segment it loaded too.
I understand that, but if you do it there would be a check necessary if it doesn’t overwrite the memory section. At the moment it can overwrite the memory section anytime and that should not be done! If the m_text and m_data are not continuous it could overwrite memory from any program.
Yes and no, I guess. The first
hardcoded part would be shared memory
where both sides expect to find things
- messages to each other. But it does not need M4 running, or more
specifically, RPMsg enabled M4 code
running on the other side before/while
Linux boots. You can delay M4 startup
& firmware boot. And do your imx
remote proc boot you busy with trying
to make work .. (otherwise, whats the
point).
Well, rpmsg never worked with remoteproc for me, thought that was the issue, but then probably there was just something other missing. I checked it and it doesn’t matter when the m4 code starts the rpmsg. Could delay it without any issues.
As for the DDR region,
This must be already handled in device tree by simply disabling the area used for the M4 code.
Well, the bug I encountered shows that this is not sufficient. I would rather have the linux aware of the memory section and setting it readonly, than it being “not existent” for the linux and having potential undefined behavior regarding caches.
For the OCRAM this could be with the RDC ..
The RTOS hw init code does RDC setup for OCRAM, TCM, and so likely also happens on Linux side.
TCM can only be accessed from the m4 if I understand it correctly. As for the OCRAM I’ve never seen some RDC initialization and even if there is one, it would be still to late (as long as you don’t want to do it in assembler in the startup code). The memory protection has to be in place before the m4 is started else there is still room for violations

