Skip to main content
Visitor II
May 19, 2021
Question

Now i'm using the stm32l072CBT6 mcu to do a bootloader, but I cannot jump from bootloader code to application code. Is there any demo code for such solution

  • May 19, 2021
  • 2 replies
  • 1090 views

I set the application code @0x08004000 in the icf files and also set the invect table to this address. i shut down all ISR before jump, but it still fail to jump my app code.

    This topic has been closed for replies.

    2 replies

    Visitor II
    May 19, 2021

    Hi ZXiao.1,

    You can refer to the STM32CubeL0 and try the DFU_Standalone project existing under Projects/$Board_Name$Applications/USB_Device/ directory.

    Best Regards,

    Ons.

    ZXiao.1Author
    Visitor II
    May 19, 2021

    Thank you for your reply, i use the similar code below to jump, but it still failed, i will check the code.

    /* Check if the KEY Button is pressed */

     if (BSP_PB_GetState(BUTTON_KEY) == 0x00)

     {

      /* Test if user code is programmed starting from address 0x08007000 */

      if (((*(__IO uint32_t*)USBD_DFU_APP_DEFAULT_ADD) & 0x2FFE0000 ) == 0x20000000)

      {

       /* Jump to user application */

       JumpAddress = *(__IO uint32_t*) (USBD_DFU_APP_DEFAULT_ADD + 4);

       JumpToApplication = (pFunction) JumpAddress;

        

       /* Initialize user application's Stack Pointer */

       __set_MSP(*(__IO uint32_t*) USBD_DFU_APP_DEFAULT_ADD);

       JumpToApplication();

      }

     }

    Graduate II
    May 19, 2021

    Is this from a interrupt handler or callback ?

    Graduate II
    May 19, 2021

    Use the Debugger, walk the transition, but understand the "not working".

    If you disable interrupts you'll need to re-enable them.

    The clocks and buses will already be viable, decide if you need to re-initialize. Watch for expectations of reset conditions.

    With the CM0+ you can set VTOR, check what the SystemInit() code is doing (unnecessarily complication and cumbersome in my opinion)

    Have the app side Reset_Handler manage the stack setting.

    Look also at IAP examples for the CM0/CM0+ parts, the former relocates the vector table to RAM, which might have advantages for those who want to dynamically configure interrupt handlers.

    ZXiao.1Author
    Visitor II
    May 19, 2021

    Thank you for your reply, where can i get the IAP examples for the CM0/CM0+ parts. You mentioned "Have the app side Reset_Handler manage the stack setting." and how to manage the stack setting when I jump to app in Reset_Handler of app?

    Graduate II
    May 19, 2021

    Reset_Handler:

    LDR R0,=_estack

    MOVS SP, R0

    ..