2019-12-31 03:30 AM
I was not involved in ST MCUs (STM32F769 specifically) until now. I understood that CPU gets stack pointer at start, from address 0, but what there exists is RAM - which is undefined after power up. Then, how can I force some "reasonable" SP value in custom bootloader (eg. from ITCM RAM) ?
2019-12-31 03:41 AM
The initial value for SP in vector table goes hand-in-hand with the first address which is executed, so by ensuring there's sane code to be executed from start, you also ensure that there's a sane value for SP.
> I understood that CPU gets stack pointer at start, from address 0,
This is not the case with the 'F76x, read Boot configuration chapter in RM0410.
> but what there exists is RAM - which is undefined after power up
The default setting of BOOT_ADDx point to either FLASH or the system memory (ROM with the factory bootloader). While you can change to point it to RAM, it's anticipated you'll do it only if *you* make sure the RAM's content is always well-defined, eg. in an always-powered (by battery) system.
JW
2019-12-31 04:08 AM
I've already red chapter you've mentioned, few times, but noticed nothing of stack pointer start value (in RM0410). Unless it's implied that is expected to be at the beginning of boot region. Or am I missed something.
2019-12-31 05:19 AM
Well, it's not explicitly said there, that's true, but I'd expect the boot address to point at the vector table, which contains the stack pointer start value.
JW
2019-12-31 09:06 AM
Seems so, although for newbies in ST world (like myself) it would be beneficial to emphasize such conclusion/statement.
2019-12-31 10:49 AM
The documentation leaves a lot to be desired.
You are supposed to click in CubeMX instead of asking questions on technical details.
Welcome to 21th century ;)
JW
2020-01-01 09:26 AM
The stack is usuallly defined in the linker description (.ld) file. The STM generated startup code overwrites the hardware fetched SP at the very beginning of the ResetHandler.