I am experiencing a sporadic bug on some STM32F7s. While usually SP register takes its initial value from reset vector (stored in persistent read-only memory), sometimes it is initially set to an apparently random value.
I discovered that someone probably faced a similar problem, because some sample programs look like:
void __attribute__((naked, noreturn)) Reset_Handler()
{
//Normally the CPU should will setup the based on the value from the first entry in the vector table.
//If you encounter problems with accessing stack variables during initialization, ensure the line below is enabled.
#ifdef sram_layout
asm ("ldr sp, =_estack");
#endif
By adding asm ("ldr sp, =_estack") the problem seems to disappear, but I can't find any documentation about this issue (except the samples I've just cited). My concern is that the "solution" just hides a deeper problem that is waiting the worst moment to happen.
So, is it a known problem? Are there specific documents or errata about this issue?