2025-05-07 11:43 AM - last edited on 2025-05-07 12:03 PM by Andrew Neil
Does the system memory bootloader for the STM32L4P5xx consider RAM3 as valid SRAM for the stack pointer?
After programming bank 2, and then setting BFB2, The device will not boot into bank 2. The linker has the top of the stack at RAM3. The value written to both 0x8000000 (bank 1) and 0x8040000 (bank 2) is 0x20050000. I want to make sure this is correct. By the way, this is the 512K part STM32L4P5xE. The other relevant options bytes are set as follows: nBOOT1=1, nSWBOOT0=0, nBOOT0=1 (BOOT0=0). When I clear BFB2 I can boot. I have compared the flash memory from 0x08000000-Length with 0x8040000-Length, and they both match.
2025-05-07 12:37 PM
Anything accessible to the CPU can be used as the stack pointer. Using SRAM3 at 0x20050000 is valid.
Is your program compiled to run correctly when it's at 0x08040000? Code is typically position dependent. You would need to modify the linker file to run it at a different position.
See the FB_MODE field in the SYSCFG_MEMRMP register for actually remapping bank 2 as if it were bank 1.
2025-05-07 12:43 PM
When I mean valid, I mean valid to the system bootloader, not the CPU. Referring to AN2606 (73.2 Bootloader selection), the bootloader has to determine if the value is a valid SRAM address in order to boot from bank 2. I do read the FB_MODE to determine what bank I am currently running, but I can't tell until my code in bank 2 is actually executed.