Skip to main content
Associate III
August 22, 2023
Solved

STM32U575 Custom bootloader Bootloader

  • August 22, 2023
  • 4 replies
  • 4022 views

Hello. I would like to write my own bootloader, but jump function does not work. could you send a complete example for stm32U575. 

    Best answer by Rim LANDOLSI

    Hello @nima.askari,

    Here is an example code for Bootloader application project:

    For the Boot’s code:

    • Add these instructions to the main.c
    typedef void (*pFunction)(void);
    #define APPLICATION_ADDRESS 0x08003800 (this is an example address)
    pFunction JumpToApplication;
    JumpToApplication = (pFunction) (*(volatile uint32_t*) (APPLICATION_ADDRESS + 4));
    __set_MSP(*(uint32_t*) APPLICATION_ADDRESS);
    JumpToApplication();
    • Change the FLASH memory size in the linker file according to the application start address.
    FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 28K (this is an example)

    For the application’s code:

    • Change the FLASH memory size in the linker file according to the application start address.
    FLASH (rx) : ORIGIN = 0x08003800, LENGTH = 100K

    When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

    Thank you,

    Rim.

    4 replies

    Associate III
    August 23, 2023

    Please Send me an example. 

    Rim LANDOLSI
    Rim LANDOLSIBest answer
    ST Employee
    August 23, 2023

    Hello @nima.askari,

    Here is an example code for Bootloader application project:

    For the Boot’s code:

    • Add these instructions to the main.c
    typedef void (*pFunction)(void);
    #define APPLICATION_ADDRESS 0x08003800 (this is an example address)
    pFunction JumpToApplication;
    JumpToApplication = (pFunction) (*(volatile uint32_t*) (APPLICATION_ADDRESS + 4));
    __set_MSP(*(uint32_t*) APPLICATION_ADDRESS);
    JumpToApplication();
    • Change the FLASH memory size in the linker file according to the application start address.
    FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 28K (this is an example)

    For the application’s code:

    • Change the FLASH memory size in the linker file according to the application start address.
    FLASH (rx) : ORIGIN = 0x08003800, LENGTH = 100K

    When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

    Thank you,

    Rim.

    Associate II
    March 31, 2025

    Hello @Rim LANDOLSI,

    thank you for posting the example. Unfortunately I can't get it to work.

    I am using a STM32u575VGT and the following code:

    • Function at main.c
    static void _bootJumpToFirmware() {
    	typedef void (*pFunction)(void);
    	#define APPLICATION_ADDRESS 0x0803C000
    	pFunction JumpToApplication;
    	JumpToApplication = (pFunction) (*(volatile uint32_t*) (APPLICATION_ADDRESS + 4));
    	__set_MSP(*(uint32_t*) APPLICATION_ADDRESS);
    	JumpToApplication();
    }​
    • STM32U575VGTX_FLASH.ld in bootloader project
    /* Memories definition */
    MEMORY
    {
     RAM	(xrw)	: ORIGIN = 0x20000000,	LENGTH = 768K
     SRAM4	(xrw)	: ORIGIN = 0x28000000,	LENGTH = 16K
     FLASH	(rx)	: ORIGIN = 0x08000000,	LENGTH = 240K
    }​
    • STM32U575VGTX_FLASH.ld in main project
    /* Memories definition */
    MEMORY
    {
     RAM	(xrw)	: ORIGIN = 0x20000000,	LENGTH = 768K
     SRAM4	(xrw)	: ORIGIN = 0x28000000,	LENGTH = 16K
     FLASH	(rx)	: ORIGIN = 0x0803C000,	LENGTH = 784K
    }​

    ICACH is disabled.
    I have flashed the main project and the bootloader project and checked with the STM32CubeProgrammer that from 0x8000000 or from 0x0803C000 code is contained in the flash with the expected code length.
    When I start the controller, I can see that the bootloader is running (with LEDs on my board) and at the point where it should jump to the firmware, the controller seems to stop or the firmware does not start.

    What can I investigate to find the problem?

    Associate III
    August 24, 2023

    Hello @Rim LANDOLSI , thanks for your answer. Is it works for stm32U5 series? I read something about writing to option bytes. I tried your sample, but it doesn't work.

    Associate III
    August 25, 2023

    I found out the problem. ICACH should not be enable in bootloader .