2021-05-19 06:40 AM
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.
2021-05-19 07:38 AM
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.
2021-05-19 08:08 AM
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.
2021-05-19 03:56 PM
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?
2021-05-19 04:14 PM
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();
}
}
2021-05-19 04:59 PM
Reset_Handler:
LDR R0,=_estack
MOVS SP, R0
..
2021-05-19 04:59 PM
Is this from a interrupt handler or callback ?
2021-05-19 07:01 PM
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