Failed to run application loaded into SRAM on STM32F407
Hello everyone,
I am trying to download and run my application firmware into internal SRAM of STM32F407, but it does not execute as expected.
Here is what I have done:
1. I built my project with Keil MDK‑ARM, configured the scatter‑linker script to place all code and data into SRAM region (0x20000000).
2. I generated the .bin firmware file.
3. Using STM32CubeProgrammer, I downloaded this bin file to SRAM address 0x20000000. Memory window verification shows the binary content is correctly written into SRAM.
4. I used the "Run after programming" option in STM32CubeProgrammer, or performed a software reset after downloading.
Symptom:
The tool reports download completes. However, my application is not actually running.
When I check the Cortex‑M4 core registers in STM32CubeProgrammer:
VTOR register shows value 0x1FFF0000, which points to ST‑system boot ROM, not my SRAM address 0x20000000. The CPU stays in the system bootloader, it never jumps to my SRAM‑located application.
I understand from the reference manual that STM32F4 supports SRAM‑boot mode controlled by BOOT0 and BOOT1 hardware pins.
But when I download firmware to SRAM via debugger and trigger software reset, the chip still boots from system memory instead of SRAM, even though the binary image is already present inside SRAM.
Questions:
1. Why does software reset not start executing code from SRAM, even if firmware is already loaded into SRAM?
2. What is the correct workflow in STM32CubeProgrammer to make the CPU run the SRAM‑loaded application?
3. Is manual modification of SP, PC and SCB->VTOR register required when debugging SRAM‑resident firmware?
Thank you.
