2018-01-31 06:03 PM
Posted on February 01, 2018 at 03:03
I have an application and want to jump to ST bootloader. It does not work and it seems to jump back from bootloader.
<LINK NO LONGER ACTIVE>
https://community.st.com/0D50X00009XkYG6SAN
From AN2606, STM32F042 should jump to 0x1FFFC519, but the system address is 0x1FFFC400,I think I still need use 0x1FFFC519.
User can jump to the System Memory Boot
loader from his application code using the
following entry point:0x1FFFC519 (Thumb mode)
I suspect it may related to valid code in bank, and cause a second jump back to application.
Does ST has some proved solution for this kind MCU?
Here is my code:
void jumpToSTBootloader()//called from first line of main
{
&sharpdefine ApplicationAddress 0x1FFFC519
typedef void (*pFunction)(void);
uint32_t JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4);
pFunction Jump_To_Boot = (pFunction) JumpAddress;
__disable_irq();
// Disable used PLL
HAL_RCC_DeInit();
SysTick->CTRL = 0; // Reset the Systick Timer
SysTick->LOAD = 0;
SysTick->VAL = 0;
/* ARM Cortex-M Programming Guide to Memory Barrier Instructions.*/
__DSB();
__HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();
/* Remap is bot visible at once. Execute some unrelated command! */
__DSB();
__ISB();
__set_MSP(*(__IO uint32_t*) ApplicationAddress);
Jump_To_Boot();
while(1);
}
Many thanks
null
2018-01-31 06:46 PM
>>I suspect it may related to valid code in bank, and cause a second jump back to application.
I'm surprised it doesn't hard fault, you've just copied stuff with little understanding of the code or the processor.
You're not calling 0x1FFFC519, if you read the code and debugged it you'd know that wasn't happening instead of guessing at reasons.
This would transfer control to 0x1FFFC519
#define EntryAddress 0x1FFFC519
typedef void (*pFunction)(void);
pFunction Jump_To_Entry_Point = (pFunction) EntryAddress;
Jump_To_Entry_Point();
while(1); // shouldn't get hereThe stack and the ROM mapping might also need to be addressed, but you've not going to pull a workable stack pointer in the fashion you illustrated earlier.
2018-02-18 09:53 PM
Thanks Clive. I am not sure how should I set the workable stack pointer bebore jumping to 0x1FFFC519.
For Thumb code, is the offset -2?
I am using the System Workbench for STM32 which uses GCC as compiler.
BTW, this 0x1FFFC519 appears to be Thumb code only. I jump to this code ends up with hard fault.
Below build option appears to build with thumb, but still does not work.
arm-none-eabi-as -mcpu=cortex-m0 -mthumb -mfloat-abi=soft -g -o 'startup/startup_stm32f042x6.o' '../startup/startup_stm32f042x6.s'
Thanks a lot