there's a bug in STM32F407xG.ld (and possible other linker scipts)
which prevents static variables to be initialized in certain cases:
In STM32F407xG.ld, we have:
Code: Select all
...
_etext = .;
_textdata = _etext;
...Now, _etext can be an odd address e.g. if the last content of flash is a
string constant with odd size. This results in _textdata being odd
(0x0800f2cd in our case).
Now, crt0.c does a copy loop with u32 access which will silently fail
and not copy _textdata from flash into ram because all the mem accesses
are not aligned. The result is that static variables stay uninitialized.
The best fix is to align the _textdata:
Code: Select all
...
_etext = .;
. = ALIGN(4);
_textdata = .;
...BTW, I was unable to create a bug report on SF because I did not find a
way to "submit bug" or similar. Is a SF registration required to do this?