2020-12-08 01:07 AM
Hi,
I've got the latest SPC5Studio 6 with all updates (gcc4.9.4) and testing on the SPC560D40L1 chip with the discovery board. So core is e200z0h VLE.
I want to manipulate the flash in my app so I need to call some code from the RAM. I added the necessary sections in the application.ld, and the necessary attribute for my method :
__attribute__ ((section (".codeinram"))) void method_in_ram()
I'm calling this method from flash code
void flash_method() {
method_in_ram()
}
All this compile correctly (no warning, no error), but this crashes during debug with invalid opcode...
I decompiled the hex, found that the flash_method content is not VLE code but PPC code !! e200z0h does not support PPC but only PPC VLE. Why is gcc creating PPC opcodes to call a method in RAM ? I tried to add longcall attribute but it does not help ...
Any help appreciated!
Thanks
Solved! Go to Solution.
2021-02-04 12:57 AM
Hello ,
There are some examples in SPC5Studio.
you have to create user.ld at the root of the project. (cf user.log in attachment)
__attribute__ ((section (".codeinram"))) void gotoStandbyMode(void) {
WKUP.WISR.R = 0x00000008; //Clear interrupt flag
if ((ME.GS.B.S_CURRENTMODE < SPC5_RUNMODE_RUN3)
|| (ME.GS.B.S_CURRENTMODE > SPC5_RUNMODE_RUN0)) {
if (OSAL_FAILED == halSPCSetRunMode(SPC5_RUNMODE_STANDBY)) {
SPC5_CLOCK_FAILURE_HOOK();
}
}
}
__attribute__ ((section (".codeinram"))) void gotoRunMode(void)
{
if (OSAL_FAILED == halSPCSetRunMode(SPC5_RUNMODE_DRUN)) {
SPC5_CLOCK_FAILURE_HOOK();
}
}
Best Regards
Erwan
2021-01-11 12:46 PM
Hello,
did you manage to copy the code from flash to RAM before executing it ?
could you share the application.ld ?
Regards,
Giuseppe
2021-02-04 12:57 AM
Hello ,
There are some examples in SPC5Studio.
you have to create user.ld at the root of the project. (cf user.log in attachment)
__attribute__ ((section (".codeinram"))) void gotoStandbyMode(void) {
WKUP.WISR.R = 0x00000008; //Clear interrupt flag
if ((ME.GS.B.S_CURRENTMODE < SPC5_RUNMODE_RUN3)
|| (ME.GS.B.S_CURRENTMODE > SPC5_RUNMODE_RUN0)) {
if (OSAL_FAILED == halSPCSetRunMode(SPC5_RUNMODE_STANDBY)) {
SPC5_CLOCK_FAILURE_HOOK();
}
}
}
__attribute__ ((section (".codeinram"))) void gotoRunMode(void)
{
if (OSAL_FAILED == halSPCSetRunMode(SPC5_RUNMODE_DRUN)) {
SPC5_CLOCK_FAILURE_HOOK();
}
}
Best Regards
Erwan