2015-08-25 12:21 AM
Hello Sirs,
I�m trying to jump to Bootloader memory (embedded in STMF030xx) from my user application.
The code that I try is as follow:typedef void (*pFunction)(void);
pFunction Jump_To_Bootloader;uint32_t JumpAddress;int main(void){SystemClock_ConfigHSI();JumpAddress = *(__IO uint32_t*) (0x1FFFF7A6 + 4);Jump_To_Bootloader = (pFunction) JumpAddress; __set_MSP(*(__IO uint32_t*) 0x1FFFF7A6);Jump_To_Bootloader();It should branch to Bootloader region, but it seems that �Hardware fault exception� instead.
Does anybody could give me a hand in this issue please?
What I�m doing wrong?Please note that I�m not used with Bootloader issues, neither �startup.s� file type .I use IAR Workbench.Thank you in advance!
Best regards.Jai #bootloader-stm32-jump2015-08-25 07:37 AM
The base of the ROM is *not* 0x1FFFF7A6
2015-08-26 04:42 AM
Ok!
Address fixed at 0x1FFFEC00 instead 0x1FFFF7A6 . thanks Clive1 :)Now I’m being able to enter to embedded Bootloader from user application, even from normal running (peripherals such as UART, SPI …initiated). In this case and if it is useful for somebody, I must stop ALL peripheral before Jump to Bootloader. Otherwise it doesn’t work.
Regads2015-08-26 01:13 PM
Not sure you have to disable the peripherals as much as the interrupts they might generate.
The boot loader really expects to enter with reset like conditions.With the Cortex-M0 you'll need to be particularly conscious that the vector table can't move, so the System Loader will expect the ROM to be mapped/shadowed at Zero. This mapping has been discussed in several other threads on this topic.2015-09-02 05:31 AM
Hi,
I tried the same code. But I have got a ''lvalue required as left operand of assignment'' for this instruction : Jump_To_Bootloader = (pFunction) JumpAddress; Did you get the same issue?2015-09-02 09:06 AM
This type of construct works with Keil, the address would need to change to the base of the ROM, and depending on the STM32 involved, you'd also want to remap the ROM into the zero space.
#define ApplicationAddress 0x8003000
typedef void (*pFunction)(void);
pFunction Jump_To_Application;
uint32_t JumpAddress;
/* Jump to user application */
JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4);
Jump_To_Application = (pFunction) JumpAddress;
/* Initialize user application's Stack Pointer */
__set_MSP(*(__IO uint32_t*) ApplicationAddress);
Jump_To_Application();
2015-09-03 12:20 AM
Hi Clive,
I used the same code to jump from the application to the bootloader. Now , it is working . What I implemented:#define ApplicationAddress 0x1FFF0000
typedef void (*pFunction)(void);
uint32_t JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4);
pFunction Jump_To_Boot = (pFunction) JumpAddress;
__set_MSP(*(__IO uint32_t*) ApplicationAddress);
Jump_To_Boot();
Thank you!