cancel
Showing results for 
Search instead for 
Did you mean: 

I have a problem of BootLoader

guo qiang
Senior
Posted on June 19, 2017 at 15:43

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

0690X00000607PCQAY.png

So I entered the command at the terminal: 

ppc-freevle-eabi-objdump.exe -S out.s

0690X00000607JGQAY.png

what should I do?

#bootloader
8 REPLIES 8
guo qiang
Senior
Posted on June 19, 2017 at 16:04

Shall I change the value of Macro SPC5-NO-INIT to TRUE? (The original value of the Macro SPC5-NO-INIT is FALSE)

guo qiang
Senior
Posted on June 19, 2017 at 17:55

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:

0690X00000607JKQAY.png

It looks like a success?

 

but could not execute the APP interrupt program..........

guo qiang
Senior
Posted on June 20, 2017 at 03:55

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

)0690X00000607PbQAI.png

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?

guo qiang
Senior
Posted on June 20, 2017 at 14:02

Yvin.Erwan

‌ Can you help me? thank you

Posted on June 20, 2017 at 14:43

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

Posted on June 20, 2017 at 15:15

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

)0690X00000607QZQAY.png

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?

Posted on June 20, 2017 at 16:01

I should add ''soft reset'' to _unhandled_exception:

0690X00000607Q0QAI.png

Before modify wrong..............................

Posted on June 13, 2018 at 08:12

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�?