Imx rt1024 position independent code - fail to start first task

My apologies for not reading properly!! My bad.

IT WORKS!!! Thanks you both so much!! One happy soul over here!

pxTopOfStack -= 8; /* R11, R10, R9, R8, R7, R6, R5 and R4. */
//pxTopOfStack[9-4] = 0x20000000;  // Set the task's initial R9 value

__asm ("MOV %[result], R9"
    : [result] "=r" (pxTopOfStack[9-4])
  );

This seems to work. Thx again!!

Great that it’s working.

In the spirit of Richard’s comment about incremental diagnostics, it’s now worth experimenting without the -mno-pic-data-is-text-relative compiler switch. I suspect that switch is slowing down your code for no good reason.

If that’s true, then -msingle-pic-base is no longer helping very much. And that switch is what necessitated your modification of the FreeRTOS port. You could consider dropping that switch then. And if that still works, then you could remove the FreeRTOS port modification and startup modification too. And if that still works, then you could drop -mpic-register=r9 too. Maybe the whole thing cleans up nicely.

1 Like

I can remove these compiler flags without a problem. But removing the part where I no longer setup r9 results in hard faults. First step was no longer to setup r9 and remove your suggested line in port.c. That already failed. Next I removed the compiler flag -mpic-register-r9 anyway just to try; but that results in the same problem. So it looks like these are mandatory for me. Which is weird, if you say that you don’t need them, while you are using an arm cpu too (right?)

So at least you spared me another 2 compiler flags. Not sure why I do need the r9 to locate my .got, while you don’t.

Can this be something specific for nxp’s imx rt boards? Which board do you use where you don’t need to setup r9?

I can also drop a question on nxp community, maybe they can clarify this bit