cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4R5 - jump to system memory bootloader from application

palsson.gp
Associate II

Hi there, I´m using a NUCLEO-L4R5ZI evaluation kit, running STM32L4R5 mcu.

For simplicity I have implemented a very simple application that configures my LEDs, creates a few blinks and then it is supposed to jump to System Memory Bootloader.

The application runs fine, LEDs blink as expected and I think it makes the jump as well.

I notice that it turns on the user-LED3 on my board, which is when I think it enters the system memory bootloader... just guessing, though.

Then I´m trying to connect, using the STMFlashLoader Demo application, downloaded from here: https://www.st.com/en/development-tools/flasher-stm32.html#design-scroll

By reading AN2606 I have tried with USART1, USART2 and USART3, but without luck.

Can anyone tell, is this supposed to work out of the box, or would there be something to it, a tweak or two that is needed?

My jump to bootloader looks like this:

(code borrowed from here: https://github.com/akospasztor/stm32-bootloader)

typedef void (*pFunction)(void);
#define	SYSMEM_ADDRESS (uint32_t) 0x1FFF0000
 
void Bootloader_JumpToSysMem(void)
{
    uint32_t  address = *(__IO uint32_t*)(SYSMEM_ADDRESS + 4);
    pFunction Jump = (pFunction) address;
 
    GPIO_DeInIt();
 
    HAL_RCC_DeInit();
    HAL_DeInit();
 
    SysTick->CTRL = 0;
    SysTick->LOAD = 0;
    SysTick->VAL  = 0;
 
    __disable_irq();
 
    __HAL_RCC_SYSCFG_CLK_ENABLE();
    __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();
 
    __set_MSP(*(__IO uint32_t*)SYSMEM_ADDRESS);
    Jump();
 
    while(1);
}

Kind regards

Gestur

3 REPLIES 3

Nobody enables IRQs​ on the other side, turn OFF all your interrupt sources.

Not sure​ if the L4+ allows for this. Use a debugger and step into the ROM

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

Hi Clive, thanks for replying.

I´m using System Workbench from ST and debugging only gets me to the jump, then I don´t know what to expect.

I believe I´m turning off all my interrupt sources in the code above, but my application is only initializing the GPIOs, clocks and systick.

If my code above seems correct I was hoping if someone had played with this on an evaluation kit, similar to mine, and if there is anything specific I need to do.

/Gestur

kampiakseli
Associate

Are you able to enter the system bootloader with BOOT0 pin asserted and able to write flash with the demonstrator from there?