Skip to main content
guo qiang
Senior
September 23, 2017
Question

Does BootLoader have to run in RAM For SPC5XXX?

  • September 23, 2017
  • 3 replies
  • 1371 views
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 topic has been closed for replies.

    3 replies

    guo qiang
    guo qiangAuthor
    Senior
    September 25, 2017
    Posted on September 25, 2017 at 02:47

    Yvin.Erwan

    procolo
    Visitor II
    September 25, 2017
    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

    guo qiang
    guo qiangAuthor
    Senior
    September 25, 2017
    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
    Visitor II
    September 26, 2017
    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

    guo qiang
    guo qiangAuthor
    Senior
    September 28, 2017
    Posted on September 28, 2017 at 03:46

    ok! Thank you  ,i will  try it!