cancel
Showing results for 
Search instead for 
Did you mean: 

Dual-slot Bootloader: Same Application Binary in Two Different Flash Sectors on STM32F7

MADHU2
Associate III

 

Hi,

I’m working on an STM32F767 custom bootloader with two application slots:

  • Main Application Slot → starts at 0x08040000

  • Backup (Factory) Slot → starts at 0x08100000

I have written a bootloader that checks both slots and jumps to the valid application:

 

 
 
SCB->VTOR = app_base;                    // Set vector table offset
__set_MSP(*(uint32_t*)app_base);         // Set initial stack pointer
void (*app_reset_handler)(void) = (void*)(*(uint32_t*)(app_base + 4));
app_reset_handler();                     // Jump to reset handler

Problem

I tested two scenarios:

 Using app_main.ld (FLASH origin = 0x08040000)

  • I built one binary with FLASH start = 0x08040000.

  • I program the same binary into both slots:

    • Slot 1 → 0x08040000

    • Slot 2 → 0x08100000

  • Result:

    • Main slot works :white_heavy_check_mark:

    • Backup slot fails :cross_mark: — the application does not start.


Question

The binary built for 0x08040000 fails when executed from 0x08100000?

Is there a way to make one application binary run from both flash addresses?

3 REPLIES 3
vaualbus
Associate II

Have you set correctly the VTOR for the apps? It has to change when you run the app from the second bank 

TDK
Super User

You can use position independent code, which is not common. You will still need to set VTOR correctly.

You can use bank remapping if it's placed at the same position within each bank.

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

Hello @MADHU2 

The recommended method for dual-slot booting is to build two separate application binaries; each linked to a different flash start address using distinct linker scripts—one for the main slot at 0x08040000 and another for the backup slot at 0x08100000.  This ensures that each binary’s vector table and all absolute addresses are correctly aligned with its designated flash region. During firmware updates, both binaries are included in the update package, and the bootloader is responsible for checking the validity of each slot and jumping to the appropriate application. 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om