With BFB2 set on an STM32F429 (i.e. the ROM bootloader runs before the application code) it is not possible to start an application that runs from the flash alias at address 0. That works fine with BFB2=0.
STM32F429.
The problem appears after the bootloader has run and jumped to application code, which it does when BFB2=1. When my application reads data from addresses around 0, it gets data from the ROM bootloader instead of from flash. I.e. it behaves like if SYSCFG_MEMRMP.MEM_MODE=1 (system flash mapped at 0), although it should be, and is, set to 0 (flash mapped at 0) at this time. Reading the same addresses from the debugger returns data from flash.
Executing code from the mapping at 0 doesn't work: it is not possible to run a program that has specified its entry point as for example 0x00003089 in the vector table. I can set a break point at 0x3088, but the wrong instructions get executed from there.
Here is a simple reproducer program (I assemble it with GNU AS, no linker involved, so it gets located at address 0). It works for me with BFB2=0 in the option bits, but with BFB2=1 it does not.
.syntax unified
.cpu cortex-m4
.thumb
vector_table:
.word 0x20000100
.word 0x1001
.org 0x1000
reset:
// Turn on a LED on PC3
ldr r1,=0x40023800 // RCC base address
ldr r0,=0x00000004 // GPIOCRST in RCC_AHB1ENR
str r0,[r1,#0x30] // Set GPIOCRST in RCC_AHB1ENR
ldr r1,=0x40020800 // GPIOC base address
ldr r0,=0x00000040 // MODER3 = 1 (GPIO out)
str r0,[r1,#0x00] // Set GPIOC_MODER
ldr r0,=0x00000008 // ODR3 = 1
str r0,[r1,#0x14] // Set GPIOC_ODR
loop:
bl loop