cancel
Showing results for 
Search instead for 
Did you mean: 

Jump to Bootloader area from user application on STM32F0

jaimadafaca
Associate II
Posted on August 25, 2015 at 09:21

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-jump
6 REPLIES 6
Posted on August 25, 2015 at 16:37

The base of the ROM is *not* 0x1FFFF7A6

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jaimadafaca
Associate II
Posted on August 26, 2015 at 13:42

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.

Regads
Posted on August 26, 2015 at 22:13

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
tingting
Associate II
Posted on September 02, 2015 at 14:31

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?

Posted on September 02, 2015 at 18:06

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
tingting
Associate II
Posted on September 03, 2015 at 09:20

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!