Showing results for 
Search instead for 
Did you mean: 

STM32L151C6, Jump to System Memory (Bootloader)

Maurice Jackson


If I used the Boot0 button, reset, and the demo-flasher, everything works as it should.


My application needs to jump to system memory. I've read many post on this which should be fairly straight forward but after jumping to System-Memory, the demo-flasher is not able to communicate with the mcu. Here is the code I'm using:


 * Function to perform jump to system memory boot from user application


 * Call function when you want to jump to system memory


void JumpToBootloader(void) {

void (*SysMemBootJump)(void);


* Step: Set system memory address.


*    For STM32L151, system memory is on 0x1FF0 0000

*    For other families, check AN2606 document table 121 with descriptions of memory addresses


volatile uint32_t addr = 0x1FF00000;





* Step: Disable RCC, set it to default (after reset) settings

*    Internal clock, no PLL, etc.




* Step: Disable systick timer and reset it to default values


SysTick->CTRL = 0;

SysTick->LOAD = 0;

SysTick->VAL = 0;


* Step: Disable all interrupts




* Step: Remap system memory to address 0x0000 0000 in address space


/* ARM Cortex-M Programming Guide to Memory Barrier Instructions.*/



* Step: Set jump memory location for system memory

*    Use address with 4 bytes offset which specifies jump location where program starts


SysMemBootJump = (void (*)(void)) (*((uint32_t *)(addr + 4)));


* Step: Set main stack pointer.

*    This step must be done last otherwise local variables in this function

*    don't have proper value since stack pointer is located on different position


*    Set direct address location which specifies stack pointer in SRAM location


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


* Step: Actually call our function to jump to set location

*    This will start system memory execution




* Step: Connect USB<->UART converter to dedicated USART pins and test

*    and test with bootloader works with STM32 Flash Loader Demonstrator software




Don't disable interrupts. Or if you do, reenable them before the jump.

Follow this guide and adapt for your chip:

If you feel a post has answered your question, please click "Accept as Solution".

Disable All Interrupts is a requirement for you to turn off all the sources of interrupts you have running, not turn off the processors ability to interrupt. Who re-enables that?

C compiler implementations might also get in the way of cleanly changing stack mid-subroutine, recommend doing this in Assembler

SYSCFG clock needs to be running to change SYSCFG registers

Step the code, check the registers, confirm you get into the ROM successfully. Make sure the ROM code isn't checking the BOOTx pin states, or if the FLASH has a valid image.

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

hello, did you solve the problem now?