Skip to content

Commit f50e23a

Browse files
Laurent MEUNIERc1728p9
authored andcommitted
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
1 parent fe9d317 commit f50e23a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

platform/retarget.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,10 +524,14 @@ extern "C" WEAK void mbed_sdk_init(void) {
524524
extern "C" int $Super$$main(void);
525525

526526
extern "C" int $Sub$$main(void) {
527-
mbed_sdk_init();
528527
mbed_main();
529528
return $Super$$main();
530529
}
530+
531+
extern "C" void _platform_post_stackheap_init (void) {
532+
mbed_sdk_init();
533+
}
534+
531535
#elif defined(TOOLCHAIN_GCC)
532536
extern "C" int __real_main(void);
533537

0 commit comments

Comments
 (0)