Skip to content

Commit 9c93aa8

Browse files
author
Laurent MEUNIER
committed
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 1bf78fd commit 9c93aa8

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
@@ -746,6 +746,7 @@ void pre_main (void)
746746
__asm void __rt_entry (void) {
747747

748748
IMPORT __user_setup_stackheap
749+
IMPORT _platform_post_stackheap_init
749750
IMPORT os_thread_def_main
750751
IMPORT osKernelInitialize
751752
#ifdef __MBED_CMSIS_RTOS_CM
@@ -766,6 +767,7 @@ __asm void __rt_entry (void) {
766767
/* Ignore return value of __user_setup_stackheap since
767768
* this will be setup by set_stack_heap
768769
*/
770+
BL _platform_post_stackheap_init
769771
BL osKernelInitialize
770772
#ifdef __MBED_CMSIS_RTOS_CM
771773
BL set_stack_heap

0 commit comments

Comments
 (0)