Skip to main content
Visitor II
January 22, 2021
Question

How to start bootloader from application code

  • January 22, 2021
  • 2 replies
  • 1067 views

I tried this code:

    // BOOTLOADER starten -------------------------------------------------------------------------------------------

    void (*SysMemBootJump)(void);                              // Funtkion Jump definieren

    volatile uint32_t addr = 0x1FFF0000;                        // System Memory-Adresse für STM32G07 laden

    HAL_RCC_DeInit();                                       // RCC auf Default setzen

    SysTick->CTRL = 0;                                    // Systick Timer zurücksetzen

    SysTick->LOAD = 0;                                    // ...

    SysTick->VAL = 0;                                       // ...

    __disable_irq();                                       // Alle Interrupts sperren

    HAL_UART_DeInit(handleuart);                              // UART ausschalten

    __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();                     // System Memory remappen

    SysMemBootJump = (void (*)(void)) (*((uint32_t *)(addr + 4)));   // Sprung-Adresse auf System Memory-Adresse setzen

    __set_MSP(*(uint32_t *)addr);                              // Main Stack-Pointer setzen

    SysMemBootJump();                                       // BOOTLOADER starten

    while (1)

    {

       // Diese Schleife Sollte nie erreicht werden

    }

This worked fine with the previous uses STM32F05. I just changed the adress of the bootloader (AN2606).

Can anybody help me?

Thanks

    This topic has been closed for replies.

    2 replies

    Graduate II
    January 23, 2021

    This question was asked a zillion times. Search here. In short, add code in your user programm at the very start before further initialization that scans for a signature and if that signature is found, jump to the bootloder. To get from running user program to the bootloader, set that signature and reset .

    BHeiß.1Author
    Visitor II
    February 2, 2021

    Thank you for your response. There were several problems to solve. I did it with help of the ST support.

    Best regards

    Bernd