2022-04-05 04:22 AM
Hi,
We are using the IAR compiler and Cube generated project on STM32L4+ for a new project we intend to code in C++.
Because C++ runs constructors of static objects before the main() function at an undetermined order the program hangs. I need to make sure somehow that the DLIB locks initialization function (generated by cube) runs before all the other constructors.
How can I set the order of execution for the constructors and move the DLIB initialization to be always the first one?
2022-04-05 05:24 AM
Does it hang, or merely Hard Faults?
ARM's CMSIS model really expects all clocks and external memory to be brought up by SystemInit(), not some hodgepodge of code in main(). You might want the system in a viable state before initializing statics, and calling constructors.
Instrument the Hard Faults Handler to get some actionable information from that.