Hello,
I am developping a bootloader for a STM32F407 using Keil uvision 5 as IDE. My bootloader shall start at the beginning of flash, (0x0800 0000), as in this microcontroller this is where the littlest sector is. As this is the default start address for Keil, I got no problem to flash and run it.
But when I try to re-compile and link application executable to start at sector 5 in flash (0x0802 0000), I get issues... Although the .map file generated by my linker shows that application code and vectors are relocated in 0x0802 0000, when I flash and start my target with my application, the reset is done at bootloader's reset vector... What did I do wrong?
Thanks a lot in advance.
Best regards
The loader has to transfer control to your app. You can't make the CPU reset to 0x08020000
You need to make sure SystemInit() in your app sets SCB->VTOR to point to your vector table for that to function.
You mean I can not launch a relocated application directly form JTAG debugger?
Hello Pier,
This is what bothered me. Thank you!
You may want to use a __DSB to ensure you dont catch an interrupt before the VTOR completes the remap! See www.keil.com/.../using_VTOR_pg.html for more details and example.
The write buffers really aren't deep enough for that to be a real issue, and in the cached case __DSB doesn't even flush the cache to memory. So a complete bust there.
The enabling and disabling the interrupts also seems overly dramatic too, the VTOR doesn't have some metastable state, it's either the vector table that was working fine up until you changed it, or its the new one.