cancel
Showing results for 
Search instead for 
Did you mean: 

How to jump to bootloader from application on STM32F103

Markobar
Associate II

Hi there,

I'm trying to jump from my application to the bootloader on a STM32F103.

The bootloader address is 0x1FFFF000

This is my code, but unfortunately, it doesn't work:

void (*f_boot_jump)();

f_boot_jump = (void (*)(void)) (*((uint32_t *)(0x1FFFF000 + 4)));

HAL_RCC_DeInit();

SysTick->CTRL = 0;

SysTick->LOAD = 0;

SysTick->VAL = 0;

__disable_irq();

__DSB();

SCB->VTOR = (uint32_t) 0x1FFFF000;

__DSB();

__ISB();

__set_MSP(*(__IO uint32_t*) 0x1FFFF000);

f_boot_jump();

I tried some variations of this code, but they didn't work either.

There is one code that I found using the function:

__HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();

But the compiler says "undefined reference" to this function.

Any ideas? Thanks for your help!

2 REPLIES 2

You can't remap the zero page memory on the F1.

Who reenables the interrupts you disable?​

Use the debugger, step the code, see where it goes..​

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

I made some progress. Following clive1 advice, I used the debugger:

Setting a breakpoint just before the f_boot_jump() function and then resuming the execution, it works!

But running the program with no breakpoint (even in debug session), it doesn't work.

I tried adding some __NOP() functions, but it doesn't help. I'm close, but I still don't know what the problem is.