Dual-slot Bootloader: Same Application Binary in Two Different Flash Sectors on STM32F7
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 handlerProblem
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?
Edited to apply source code formatting - please see How to insert source code for future reference.
