Skip to content

Commit fe9d317

Browse files
Laurent MEUNIERc1728p9
authored andcommitted
INIT:GCC no rtos: Align pre-main initialization steps between TCs
Various toolchains supported in MBED don't follow the 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, this is easily done because SystemInit is called after the ram initialisation, so HAL_Init does not need to called from mbed_sdk_init. this is covered by the changes in mbed_overrides.c files. This series should solve issue reported here: STM32 (At least F401) breaks if Tickers are activated in a global object #2115
1 parent cb9a4b1 commit fe9d317

File tree

8 files changed

+22
-2
lines changed

8 files changed

+22
-2
lines changed

targets/TARGET_STM/TARGET_STM32F0/mbed_overrides.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
void mbed_sdk_init() {
3232
// Update the SystemCoreClock variable.
3333
SystemCoreClockUpdate();
34-
34+
#if !defined(TOOLCHAIN_GCC_ARM)
3535
// Need to restart HAL driver after the RAM is initialized
3636
HAL_Init();
37-
37+
#endif
3838
}

targets/TARGET_STM/TARGET_STM32F1/mbed_overrides.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ void mbed_sdk_init()
3232
{
3333
// Update the SystemCoreClock variable.
3434
SystemCoreClockUpdate();
35+
#if !defined(TOOLCHAIN_GCC_ARM)
3536
// Need to restart HAL driver after the RAM is initialized
3637
HAL_Init();
38+
#endif
3739
}

targets/TARGET_STM/TARGET_STM32F3/mbed_overrides.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ void mbed_sdk_init()
3232
{
3333
// Update the SystemCoreClock variable.
3434
SystemCoreClockUpdate();
35+
#if !defined(TOOLCHAIN_GCC_ARM)
3536
// Need to restart HAL driver after the RAM is initialized
3637
HAL_Init();
38+
#endif
3739
}

targets/TARGET_STM/TARGET_STM32F4/mbed_overrides.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ void mbed_sdk_init()
3333
{
3434
// Update the SystemCoreClock variable.
3535
SystemCoreClockUpdate();
36+
#if !defined(TOOLCHAIN_GCC_ARM)
3637
// Need to restart HAL driver after the RAM is initialized
3738
HAL_Init();
39+
#endif
3840
}
3941

4042
/**

targets/TARGET_STM/TARGET_STM32F7/mbed_overrides.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ void mbed_sdk_init()
3535
{
3636
// Update the SystemCoreClock variable.
3737
SystemCoreClockUpdate();
38+
#if !defined(TOOLCHAIN_GCC_ARM)
3839
// Need to restart HAL driver after the RAM is initialized
3940
HAL_Init();
41+
#endif
4042
}
4143

4244

targets/TARGET_STM/TARGET_STM32L0/mbed_overrides.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,8 @@ void mbed_sdk_init()
3232
{
3333
// Update the SystemCoreClock variable.
3434
SystemCoreClockUpdate();
35+
#if !defined(TOOLCHAIN_GCC_ARM)
36+
// Need to restart HAL driver after the RAM is initialized
37+
HAL_Init();
38+
#endif
3539
}

targets/TARGET_STM/TARGET_STM32L1/mbed_overrides.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ void mbed_sdk_init()
3535
{
3636
// Update the SystemCoreClock variable.
3737
SystemCoreClockUpdate();
38+
#if !defined(TOOLCHAIN_GCC_ARM)
39+
// Need to restart HAL driver after the RAM is initialized
40+
HAL_Init();
41+
#endif
3842

3943
#if defined(TARGET_XDOT_L151CC)
4044
if (PWR->CSR & PWR_CSR_SBF) {

targets/TARGET_STM/TARGET_STM32L4/mbed_overrides.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,8 @@ void mbed_sdk_init()
3232
{
3333
// Update the SystemCoreClock variable.
3434
SystemCoreClockUpdate();
35+
#if !defined(TOOLCHAIN_GCC_ARM)
36+
// Need to restart HAL driver after the RAM is initialized
37+
HAL_Init();
38+
#endif
3539
}

0 commit comments

Comments
 (0)