Skip to main content
AVM
Associate II
January 19, 2022
Question

Bootloader and application issue with SWT component

  • January 19, 2022
  • 14 replies
  • 6876 views

Hi,

I am working on SPC58NG84E7 bootloader.

Everything works fine - I have BL code(at 0xFC0000) which jumps to the APP location 0xFD0000 after waiting for 10sec after startup and executes the code there. Both codes are without SWT.

Issue - But when I added SWT component to BL, on powerOn BL is not running. swt_lld_stop() is called before jump.

If I start the BL through UDE debugger application it executes BL, jumps to APP, executes APP code, but then reset from APP and entering into BL is not working.

This issue remains in APP with SWT and without SWT both.

What could be the issue here?

Regards,

AM

    This topic has been closed for replies.

    14 replies

    ODOUV.1
    ST Employee
    January 19, 2022

    Hello,

    SWT is a watchdog. It prevent your application to be locked for too much time by resetting the HW.

    If you activate SWT, you must regularly feed it as explained in the reference manual to avoid a reset.

    Both your BL and APP software must take care of SWT if enabled.

    Best Regards,

    -Olivier

    AVM
    AVMAuthor
    Associate II
    January 19, 2022

    I am refreshing the watchdog by calling swt_lld_keep_alive() in SWT callback function.

    ODOUV.1
    ST Employee
    January 19, 2022

    Do you see this exact line in your function swt_lld_keep_alive() ?

      /* get old key */

      old_serv_key = swtd->swtp->SK.B.SK;

    AVM
    AVMAuthor
    Associate II
    January 19, 2022

    yes..it is there!

    ODOUV.1
    ST Employee
    January 19, 2022

    This line is wrong and could cause a RESET when you call the function

    Please replace it by this one and test your program again:

      /* get old key */

      old_serv_key = swtd->swtp->SK.R; /* 32 bit access to the register */

    Regards,

    -Olivier

    AVM
    AVMAuthor
    Associate II
    January 20, 2022

    Hi Olivier,

    I replaced mentioned line in function swt_lld_keep_alive() . But could not see any difference in the execution.

    The issue mentioned above still persist.

    Thanks!

    Regards,

    AM

    AVM
    AVMAuthor
    Associate II
    January 20, 2022

    Hi Olivier,

    I had used same configuration as in the image you shared except SWT0 with timeout period is 5000.

    Thanks!

    ODOUV.1
    ST Employee
    January 20, 2022

    Hello,

    then it means you do not use the SWT in pseudo random mode I was suspecting.

    When you say you activate the SWT in you BL code ONLY, I suppose you took example on "SPC58xGxx_RLA SWT Test Application for Discovery" :

    You selected SWT in Low Level Driver component:0693W00000JMf7rQAD.pngIn SWT settings in outline menu, you selected SWT2;0693W00000JMf8uQAD.pngyou configured SWT2 like this:0693W00000JMfAMQA1.png 

    Each time you modify demo configuration, you need to clean :

    0693W00000JMfHSQA1.pngand regenerate the sources:

    0693W00000JMfHhQAL.pngbefore to rebuild:

    0693W00000JMfIGQA1.png 

    In your main function, after componentsInit and irqIsrEnable, you started SWT2:

    swt_lld_start(&SWTD3, &swt2_config);

    Did you added this callback in your main.c:

    void swt2_callback(SWTDriver *swtp) {

      swt_lld_keep_alive(swtp);

    }

    And finally, did you stop SWT2 in the timeout callback just before to jump ?

    void stm_timeout_callback(void) {

    ...

    swt_lld_stop(&SWTD3);

    updater_jump();

    ...

    }

    Regards,

    -Olivier

    AVM
    AVMAuthor
    Associate II
    January 20, 2022

    Hi Olivier,

    I already have added the callback function and also stopped the SWT before jump.

    Thanks & Regards,

    AVM

    ODOUV.1
    ST Employee
    January 24, 2022

    Do you use only 1 SWT device or several ones ?

    Could you test with Time period 40000 or greater to let time to your APP to boot ?

    ODOUV.1
    ST Employee
    January 20, 2022

    Also when you say:

    "on powerOn BL is not running"

    What does it mean ? MCU is resetting before to jump to APP ?

    What is the BL behavior when you debug, when SWT is activated on BL only ?

    Regards,

    -Olivier

    AVM
    AVMAuthor
    Associate II
    January 20, 2022

    Hi Olivier,

    when you say:

    "on powerOn BL is not running", it means -

    When I flash the BL code, disconnect the debugger and reset hw, that time BL doesn't run.

    But when I flash the BL code, start the code through debugger, BL runs correctly and jumps also.

    SWT is activated on BL only.

    Thanks & Regards,

    AVM

    ODOUV.1
    ST Employee
    January 20, 2022

    Could you try to Erase your complete Flash

    Flash again your program BL and APP (check there is no recovery between them with addresses and sizes)

    Boot your board without debugger

    Regards,

    -Olivier

    AVM
    AVMAuthor
    Associate II
    January 21, 2022

    Hi Olivier,

    I am erasing complete flash before programming BL and APP every time.

    What do you exactly mean by - 'no recovery between them with addresses and sizes'?

    Thanks & Regards,

    AVM

    ODOUV.1
    ST Employee
    January 21, 2022

    Hello,

    I meant if your BL is at address1 and APP at address2 > address1

    then the size of program BL must be less than (address2-address1)

    No overlap between BL and APP in flash memory

    BRs,

    -Olivier

    AVM
    AVMAuthor
    Associate II
    January 21, 2022

    Hi Olivier,

    These things are verified.

    There is no overlap between BL and APP.

    Thanks & Regards,

    AVM