cancel
Showing results for 
Search instead for 
Did you mean: 

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

ZXiao.1
Associate II

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.

7 REPLIES 7
Ons KOOLI
Senior III

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.

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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?

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();

  }

 }

Reset_Handler:

LDR R0,=_estack

MOVS SP, R0

..

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Is this from a interrupt handler or callback ?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

like this? it will occur the error below, how to find the stack name?

Error[50]: Undefined symbol:'_estack' C:\workfile\ongoingProject\shadow_temp\src\trunk\STM32Boot_app_test\EWARM\startup_stm32l072xx.s 117 

Reset_Handler

    LDR R0,=_estack

    MOVS SP, R0

    LDR   R0, =SystemInit

    BLX   R0

    LDR   R0, =__iar_program_start

    BX   R0