I wrote a custom bootloader for the STM32F4 microcontroller and I'm able to write an application to the flash memory at the address of 0x08008000. The issue I have is when I use the jump function the application doesn't seem to execute. I have attached the jump function below. I have disabled all the peripherals, timers and interrupts. Also, relocated the vector table to 0x08008000 to run the new app.

void bootloader_jump_to_user_app(void)

   //just a function pointer to hold the address of the reset handler of the user app.
    void (*app_reset_handler)(void);

    //shut down any tasks running

    SysTick->CTRL = 0;
    SysTick->LOAD = 0;
    SysTick->VAL = 0;

    //disbale interuppts

     SCB->VTOR = FLASH_SECTOR2_BASE_ADDRESS; //0x080080000

    // 1. configure the MSP by reading the value from the base address of the sector 2
    uint32_t msp_value = *(__IO uint32_t *)FLASH_SECTOR2_BASE_ADDRESS;


    uint32_t resethandler_address = *(__IO uint32_t *) (FLASH_SECTOR2_BASE_ADDRESS + 4);

    app_reset_handler = (void*) resethandler_address;

    //3. jump to reset handler of the user application


In the linker file for the bootloader I have broken the flash into two parts, one for the app and the other for the bootloader. For the application linker file I have the flash starting at 0x08008000.

/* Memories definition */
    CCMRAM  (xrw)   : ORIGIN = 0x10000000,  LENGTH = 64K
    RAM (xrw)   : ORIGIN = 0x20000000,  LENGTH = 128K
    FLASH   (rx)    : ORIGIN = 0x8000000,   LENGTH = 128K
    APPLICATION (rx) : ORIGIN = 0x08008000, LENGTH = 896K
  • \$\begingroup\$ How/where is FLASH_SECTOR2_BASE_ADDRESS defined? Is it just an integer or is it already a pointer of some sort? \$\endgroup\$
    – brhans
    Feb 5, 2020 at 16:05
  • \$\begingroup\$ defined in header file as #define FLASH_SECTOR2_BASE_ADDRESS 0x08008000U \$\endgroup\$
    – doge
    Feb 5, 2020 at 16:08
  • \$\begingroup\$ I have an STM32F4 bootloader which does something like: extern uint32_t __FLASH_segment_start__[]; #define APPLICATION_START (uint32_t)__FLASH_segment_start__ SCB->VTOR = (uint32_t)APPLICATION_START; __set_MSP(APPLICATION_START[0]); ((void (*)(void))APPLICATION_START[1])(); and it seems like your code _should have the same effect ... \$\endgroup\$
    – brhans
    Feb 5, 2020 at 16:15
  • \$\begingroup\$ code seems similar. Maybe there's something that i missed since my jump function doesnt work \$\endgroup\$
    – doge
    Feb 5, 2020 at 16:26
  • 1
    \$\begingroup\$ Did you link your code to start at 0x08008000? You can't just take an image linked for a different start address, load it, and expect it to work. \$\endgroup\$ Feb 5, 2020 at 18:47

2 Answers 2


I managed to get the bootloader to work. I just needed to rename the reset_handler in the linker script and startup_stm32F40xx.s file to bootloader_reset_handler for the bootloader program.

  • \$\begingroup\$ Can you please tell me how you renamed reset_handler in the linker script and startup_stm32F40xx.s file \$\endgroup\$
    – Rohith R
    Sep 15, 2021 at 6:13

Renaming reset_handler in the linker script and startup_stm32F40xx.s file

  1. Open STM32XXXXX_FLASH.ld file in your project search text Reset_Handler. replace this text with Boot_Reset_Handler.
  2. Open startup_stm32F40xx.s file in startup folder search text Reset_Handler. replace this text with Boot_Reset_Handler for all occurances.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.