cancel
Showing results for 
Search instead for 
Did you mean: 

Does BootLoader have to run in RAM For SPC5XXX?

guo qiang
Senior
Posted on September 23, 2017 at 09:29

I have a board of SPC560B. I need to make a BootLoader.

I want to do that:

the JMP_ADDRESS is 0x40000

PowerON--> running BootLoader at 0x000000 in flash.--->delay 3000ms-->if (update cmd ==false)-----> 

(*(

AppFunctionType

)(

JMP_ADDRESS

+

8

))();

//

jump

to

app

and

should

not

back

Is that ok?

Why do all people develop BootLoader in RAM for MPC5XXX?

Can't BootLoader be run in Flash for SPC5XXX/MPC5XXXX?

This discussion has been locked for participation. If you have a question, please start a new topic in order to ask your question
7 REPLIES 7
guo qiang
Senior
Posted on September 25, 2017 at 02:47

Yvin.Erwan

procolo
Senior
Posted on September 25, 2017 at 10:51

Hi,

you can create a bootloader in flash. Check out this post and related spc5studio projects attached.

https://community.st.com/0D50X00009Xkeh4SAB

Regards,

Procolo

Posted on September 25, 2017 at 11:13

0690X00000608MJQAY.png

My APP address is 0x18000, i did test.

if i wrote:

e_lis% r3, HI (0x00018000)

e_or2i% r3, LO (0x00018000)

mtctr% r3

se_bctrl

Jump failed.

I must write:

e_lis% r3, HI (0x00018008)

e_or2i% r3, LO (0x00018008)

mtctr% r3

se_bctrl

Jump success, MCU can be executed to the APP main function, but the implementation of abnormal ....

Please tell me, before jumping program, how should I do?

My bootloader Jump code:

//irqIsrDisable();

//can_lld_stop(&CAND1);

CAN_0.MCR.B.MDIS = 1; // disable FlexCAN

//can_lld_stop(&CAND2);

CAN_1.MCR.B.MDIS = 1;

//can_lld_stop(&CAND3);

CAN_2.MCR.B.MDIS = 1;

// PIT.PITMCR.B.MDIS = 1; /* PIT clock Disabled. */

//SPCSetPeripheralClockMode(SPC5_PIT_PCTL, SPC5_PIT_STOP_PCTL);

//INTC.MCR.B.HVEN = 1;

SPCSetRunMode(SPC5_RUNMODE_DRUN);

(*(AppFunctionType)(JMP_ADDRESS+8))();

But it is not working good...

procolo
Senior
Posted on September 26, 2017 at 16:01

Hello, these funcion are used in a bootloader of another platform but should be ok also for yours

void StopPeripherals(void) {

/*Stop STM */

stm_lld_stop(&STMD1);

/*Stop System Timer*/

SPCSetPeripheralClockMode(SPC5_PIT_PCTL, SPC5_PIT_STOP_PCTL);

/* Disable Interrupt */

irqIsrDisable();

}

void SetDRUNMode(void) {

ME.DRUN.R = (0UL | SPC5_ME_MC_MVRON | SPC5_ME_MC_DFLAON_NORMAL | SPC5_ME_MC_CFLAON_NORMAL | SPC5_ME_MC_IRCON | SPC5_ME_MC_SYSCLK_IRC);

if (SPCSetRunMode(SPC5_RUNMODE_DRUN) == CLOCK_FAILED) {

pal_lld_togglepad(PORT_A, Led_D11);

SPC5_CLOCK_FAILURE_HOOK();

}

}

void JumpMain(void) {

/* Branch to the main application.*/

asm volatile ('e_lis %r3, 0x00010008@h \t\n'

'e_or2i %r3, 0x00010008@l \t\n'

'mtctr %r3 \t\n'

'se_bctrl');

}

Order is 

 - StopPeripherals

-

SetDRUNMode

- JumpMain

most important is to stop the PIT clock which runs by default and to disable irq before jump.

Also set DRUN with the configuration set in ME.DRUN.R 

Regards,

Procolo

Posted on September 28, 2017 at 03:46

ok! Thank you  ,i will  try it!

Posted on November 07, 2017 at 03:16

carannante.procolo

My code :

can_lld_stop(&CAND1);

SPCSetPeripheralClockMode(SPC5_FLEXCAN0_PCTL, SPC5_CAN_FLEXCAN0_STOP_PCTL);

can_lld_stop(&CAND2);

SPCSetPeripheralClockMode(SPC5_FLEXCAN1_PCTL, SPC5_CAN_FLEXCAN1_STOP_PCTL);

can_lld_stop(&CAND3);

SPCSetPeripheralClockMode(SPC5_FLEXCAN2_PCTL, SPC5_CAN_FLEXCAN2_STOP_PCTL);

pit_lld_stop(&PITD);

SPCSetPeripheralClockMode(SPC5_PIT_PCTL, SPC5_PIT_STOP_PCTL);

irqIsrDisable();

ME.DRUN.R = (0UL | SPC5_ME_MC_MVRON | SPC5_ME_MC_DFLAON_NORMAL | SPC5_ME_MC_CFLAON_NORMAL | (1<<4) | (0));

ME.RUN[0].R=(0UL | SPC5_ME_MC_MVRON | SPC5_ME_MC_DFLAON_NORMAL | SPC5_ME_MC_CFLAON_NORMAL | (1<<4) | (0));

SPCSetRunMode(SPC5_RUNMODE_DRUN);

(*(AppFunctionType)(JMP_ADDRESS+8))(); // jump to app and should not back

When I connect the debuger and debugging , everything is fine�?When I disconnect debugger and close the UDE, and re-power on the board, the jump is unsuccessful.

Posted on November 07, 2017 at 04:18

When I use 8M

oscillator

, there will be the above jump failure, when I use 8M

crystal

, everything is no problem.

Yvin.Erwan.001

carannante.procolo