2017-09-23 12:29 AM
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?
2017-09-24 05:47 PM
Yvin.Erwan
2017-09-25 01:51 AM
Hi,
you can create a bootloader in flash. Check out this post and related spc5studio projects attached.
https://community.st.com/0D50X00009Xkeh4SAB
Regards,
Procolo
2017-09-25 04:13 AM
My APP address is 0x18000, i did test.
if i wrote:
e_lis% r3, HI (0x00018000)e_or2i% r3, LO (0x00018000)mtctr% r3se_bctrlJump failed.I must write:e_lis% r3, HI (0x00018008)e_or2i% r3, LO (0x00018008)mtctr% r3se_bctrlJump 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...
2017-09-26 07:01 AM
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
2017-09-27 08:46 PM
ok! Thank you ,i will try it!
2017-11-06 07:16 PM
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.
2017-11-06 08:18 PM
When I use 8M
oscillator
, there will be the above jump failure, when I use 8Mcrystal
, everything is no problem.
Yvin.Erwan.001
carannante.procolo