Skip to main content
LeoC
Associate II
April 10, 2020
Solved

SPC570Sxx Bootloader: Check valid application

  • April 10, 2020
  • 1 reply
  • 1096 views

Hi,

My setup:

  • SP570S-DISP Demo Board Evaluation
  • uC: SPC570S50E1
  • IDE: SPC5Studio 5.8.1

I'm using example "SPC570Sxx_RLA Bootloader Application for Discovery".

Function "updater_jump()" In "firmware_updater.c" file, jump to application image without checking if there is valid application image.

So, if there isn't a valid application image, bootloader stucks and the only way to restore bootloader functionality is to perform a "physical" reset using button RESET of SPC570S-DISP board.

void updater_jump(void) {
 void (*fptr)(void);
 uint32_t jump_address_pointer;
 vuint32_t jump_address;
 
 jump_address_pointer = updater_config.codeimage1.address + 4UL;
 jump_address = *((vuint32_t*)(jump_address_pointer));
 /*
 * stop peripherals
 */
#if (SPC5_UPDATER_CONN == SPC5_UPDATER_CONN_CAN)
 can_lld_stop (updater_config.can_driver);
 
#else
 sd_lld_stop(updater_config.serial_driver);
#endif
#if (SPC5_UPDATER_ACT == SPC5_UPDATER_ACT_TIMER)
 stm_lld_stop(updater_config.stm_driver);
#endif
 
 updater_lld_stop();
 /*lint -e9074 */
 fptr = (void (*)(void))jump_address;
 fptr();
 /*lint +e9074 */
 
}

I have tried to inspect, using debugger, what happens when microcontroller jump in an address that contain no valid instructions.

I noticed that no exceptions are triggered, microcontroller remains blocked in a memory location with "unknown instruction".

I have tried to enable all IVOR interrupts, but no IVOR condition is triggered.

I would expect to see "IVO6 - Program Interrupt" because there is an "illegal instruction".

My questions:

  • Why no IVOR condition is triggered when microcontroller jump in an "unknown instruction"?
  • Please, could you suggest me any approach to check if there is a valid application in "which" jump before perform application image jump?

Thanks,

Regards

    This topic has been closed for replies.
    Best answer by zambrano.luigi

    Hi,

    if the new application is designed with SPC5Studio and is compiled to be executed starting from 0x1000000 (as in the example SPC570Sxx_RLA Bootloader Application for Discovery), the first word at address 0x1000000 will be to 0x005A0000 (first word in boot.S) if a valid application is already present to 0x1000000. So, it is possible to check if a valid application is present verifying if the value to the address updater_config.codeimage1.address is to 0x005A0000.

    Please, feel free to contact me for any other clarification.

    Regards,

    Luigi

    1 reply

    zambrano.luigi
    zambrano.luigiBest answer
    ST Employee
    April 22, 2020

    Hi,

    if the new application is designed with SPC5Studio and is compiled to be executed starting from 0x1000000 (as in the example SPC570Sxx_RLA Bootloader Application for Discovery), the first word at address 0x1000000 will be to 0x005A0000 (first word in boot.S) if a valid application is already present to 0x1000000. So, it is possible to check if a valid application is present verifying if the value to the address updater_config.codeimage1.address is to 0x005A0000.

    Please, feel free to contact me for any other clarification.

    Regards,

    Luigi

    LeoC
    LeoCAuthor
    Associate II
    April 22, 2020

    Dear Luigi,

    It works!

    Many thanks for support!

    Leonardo