Skip to content

Commit 3a61bd0

Browse files
Laurent MEUNIERc1728p9
authored andcommitted
INIT:ARM + 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_) In case of mbed with rtos, the __rt_entry is redefined so we need to add the call to _platform_post_stackheap_init. This series should solve issue reported here: STM32 (At least F401) breaks if Tickers are activated in a global object #2115
1 parent e8d67ac commit 3a61bd0

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

rtos/rtx/TARGET_CORTEX_M/RTX_CM_lib.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ void pre_main (void)
538538
__asm void __rt_entry (void) {
539539

540540
IMPORT __user_setup_stackheap
541+
IMPORT _platform_post_stackheap_init
541542
IMPORT os_thread_def_main
542543
IMPORT osKernelInitialize
543544
#ifdef __MBED_CMSIS_RTOS_CM
@@ -558,6 +559,7 @@ __asm void __rt_entry (void) {
558559
/* Ignore return value of __user_setup_stackheap since
559560
* this will be setup by set_stack_heap
560561
*/
562+
BL _platform_post_stackheap_init
561563
BL osKernelInitialize
562564
#ifdef __MBED_CMSIS_RTOS_CM
563565
BL set_stack_heap

0 commit comments

Comments
 (0)