2017-06-19 06:43 AM
Chip: SPC560B54L5.
I write a BootLoader program.this code is running from flash with address 0x00000 ?not sram. use the computer send ''app.bin'' file to the mcu by can bus. then the mcu erases the flash after address 0x40000. and program the received data( app.bin) to flash ,and jump.I write a BootLoader program.this code is running from flash with address 0x00000 ?not sram. use the computer send ''app.bin'' file to the mcu by can bus. then the mcu erases the flash after address 0x40000. and program the received data( app.bin) to flash ,and jump.I write a BootLoader program.this code is running from flash with address 0x00000 ?not sram. use the computer send ''app.bin'' file to the mcu by can bus. then the mcu erases the flash after address 0x40000. and program the received data( app.bin) to flash ,and jump.I write a BootLoader program.this code is running from flash with address 0x00000 ?not sram. use the computer send ''app.bin'' file to the mcu by can bus. then the mcu erases the flash after address 0x40000. and program the received data( app.bin) to flash ,and jump.
The Bootloader jump code:
&sharpdefine JMP_ADDRESS (0x40000) //C_OFFSET_MID_B6
irqIsrDisable();
(*(AppFunctionType)(JMP_ADDRESS+8))(); // jump to app and should not back
while(1);
APP link script code?
MEMORY
{ flash : org = 0x40000, len = 512k // offset dataflash : org = 0x00800000, len = 64k ram : org = 0x40000000, len = 64k}............
After jumping, it will enter the loop code?The value of the PC register is 0x00041544
So I entered the command at the terminal:
ppc-freevle-eabi-objdump.exe -S out.s
what should I do?
#bootloader2017-06-19 07:04 AM
Shall I change the value of Macro SPC5-NO-INIT to TRUE? (The original value of the Macro SPC5-NO-INIT is FALSE)
2017-06-19 08:55 AM
Through debugging, I found that my jump code must be changed to this:
// irqIsrDisable();
SPCSetRunMode(SPC5_RUNMODE_DRUN); (*(AppFunctionType)(JMP_ADDRESS+8))(); // jump to app and should not back
The value of the PC is 0x424d8
my APP code:
It looks like a success?
but could not execute the APP interrupt program..........
2017-06-19 06:55 PM
Success? My jump code:
SPCSetRunMode(SPC5_RUNMODE_DRUN);
INTC.MCR.B.HVEN = 1; // disable software vector mode
CAN_0.MCR.B.MDIS = 1; // disable FlexCAN
CAN_1.MCR.B.MDIS = 1;
CAN_2.MCR.B.MDIS = 1;
PIT.PITMCR.B.MDIS=1;
(*(AppFunctionType)(JMP_ADDRESS+8))(); // jump to app and should not back
while(1);
Turn off the power.
immediately turn on the power..(About a few hundred milliseconds).then entry
_unhandled_irq interrupt (the value of pc register is
0x40BA8
)but turn off the power. and turn on the power after a few seconds.Everything is successful! MCU can enter the APP interrupt .?TEST APP use PIT peripherals.
can enter the
PIT interrupt!
?Everything is successful!
What is the problem?
2017-06-20 05:02 AM
Yvin.Erwan
Can you help me? thank you2017-06-20 07:43 AM
Hello Guo ,
(*(AppFunctionType)(JMP_ADDRESS+8))(); is valid because it is the boot sector structure.
The first 32 Bits contain the BootID
the next 32 Bits contain 32 Bits Reset Vector
(Cf RM0037)
Check your call stack, It seems to be a STATE Issue , check your registers just before switching states.
(cf figure 72 in the RM)
I think that you are going to SPC5_CLOCK_FAILURE_HOOK();
Best Regards
Erwan
2017-06-20 08:15 AM
Yes.
Everything is successful now . but There is a very small problem:
Turn off the power.
immediately turn on the power..(About a few hundred milliseconds).
then entry
_unhandled_irq interrupt (the value of pc register is
0x40BA8
)but turn off the power. and turn on the power after a few seconds(about 2 seconds).Everything is successful!
The problem seems difficult to solve....
so I am going to modify the irqSysHalt function:
void irqSysHalt(void) {
irqIsrDisable();
SPCSetRunMode(SPC5_RUNMODE_DRUN); RGM.FERD.B.D_SOFT=1; //software reset ??? for ( ; ; ) { }}But the MCU did not restart...How to do it?
2017-06-20 09:01 AM
I should add ''soft reset'' to _unhandled_exception:
Before modify wrong..............................
2018-06-13 01:12 AM
Hello Erwan:
I think I have the problem “
going to SPC5_CLOCK_FAILURE_HOOK();�? with the same situation as guo qiang‘s,but how to resolve this,could you help me?Thanks in advance�?