Trying to make a workaround for the flash-not-ready-after-leaving-power-saving problem, I am placing the below function in a section which goes into the .data section:
__attribute__ (( __section__ ("halt"))) void halt0(void)
ME.HALT0.B.CFLAON = ME.RUN.B.CFLAON = 1;
ME.HALT0.B.DFLAON = ME.RUN.B.DFLAON = 1;
ME.MCTL.R = SPC5_ME_MCTL_MODE(SPC5_RUNMODE_HALT0) | SPC5_ME_MCTL_KEY;
ME.MCTL.R = SPC5_ME_MCTL_MODE(SPC5_RUNMODE_HALT0) | SPC5_ME_MCTL_KEY_INV;
ME.RUN.B.CFLAON = 3;
ME.RUN.B.DFLAON = 3;
ME.MCTL.R = SPC5_ME_MCTL_MODE(SPC5_RUNMODE_RUN0) | SPC5_ME_MCTL_KEY;
ME.MCTL.R = SPC5_ME_MCTL_MODE(SPC5_RUNMODE_RUN0) | SPC5_ME_MCTL_KEY_INV;
Calling this function from code in the .text segment cause the linker to fail with the message
relocation truncated to fit: R_PPC_VLE_REL24 against symbol `halt0' defined in flop section in arch/spc560/halt0.o
The exact reason for this error is not clear to me, as it is quite cryptic.
However - and this is the strange part - if I adjust the function and take out some code, the object compiles and links just fine. For example, remove the last 3 lines, and the problem is gone.
Can anyone explain what exactly causes the error message, and if there is a workaround for this?