INIT:ARM no rtos: Align pre-main initialization steps between TCs

Various toolchains supported in MBED don't followthe same initialization
steps. This can have impacts on platform behavior.

For STM32, it is needed to call the HAL_Init() _after_ the  RAM has been
initialized (sdata from flash / zero initialized data) and _before_ the C++
objects are being created, especially if those objects require support
of tickers for instance.

In GCC and IAR, this was done in previous commit to avoid HAL_Init()
to be called twice.

In ARM this there is no hook defined in MBED yet to place the call.
The proposal is to take benefit of the library's
_platform_post_stackheap_init function that is going to be called before
__rt_lib_init where the C++ object init is done (__cpp_initialize__aeabi_)

This series should solve issue reported here:
STM32 (At least F401) breaks if Tickers are activated in a global object #2115
pull/2917/head
Laurent MEUNIER 2016-07-11 16:14:03 +02:00 committed by Russ Butler
parent fe9d3174bf
commit f50e23aea6
1 changed files with 5 additions and 1 deletions

View File

@ -524,10 +524,14 @@ extern "C" WEAK void mbed_sdk_init(void) {
extern "C" int $Super$$main(void);
extern "C" int $Sub$$main(void) {
mbed_sdk_init();
mbed_main();
return $Super$$main();
}
extern "C" void _platform_post_stackheap_init (void) {
mbed_sdk_init();
}
#elif defined(TOOLCHAIN_GCC)
extern "C" int __real_main(void);