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
pull/2917/head
Laurent MEUNIER 2016-07-11 16:14:03 +02:00 committed by Russ Butler
parent cb9a4b124b
commit fe9d3174bf
8 changed files with 22 additions and 2 deletions

View File

@ -31,8 +31,8 @@
void mbed_sdk_init() { void mbed_sdk_init() {
// Update the SystemCoreClock variable. // Update the SystemCoreClock variable.
SystemCoreClockUpdate(); SystemCoreClockUpdate();
#if !defined(TOOLCHAIN_GCC_ARM)
// Need to restart HAL driver after the RAM is initialized // Need to restart HAL driver after the RAM is initialized
HAL_Init(); HAL_Init();
#endif
} }

View File

@ -32,6 +32,8 @@ void mbed_sdk_init()
{ {
// Update the SystemCoreClock variable. // Update the SystemCoreClock variable.
SystemCoreClockUpdate(); SystemCoreClockUpdate();
#if !defined(TOOLCHAIN_GCC_ARM)
// Need to restart HAL driver after the RAM is initialized // Need to restart HAL driver after the RAM is initialized
HAL_Init(); HAL_Init();
#endif
} }

View File

@ -32,6 +32,8 @@ void mbed_sdk_init()
{ {
// Update the SystemCoreClock variable. // Update the SystemCoreClock variable.
SystemCoreClockUpdate(); SystemCoreClockUpdate();
#if !defined(TOOLCHAIN_GCC_ARM)
// Need to restart HAL driver after the RAM is initialized // Need to restart HAL driver after the RAM is initialized
HAL_Init(); HAL_Init();
#endif
} }

View File

@ -33,8 +33,10 @@ void mbed_sdk_init()
{ {
// Update the SystemCoreClock variable. // Update the SystemCoreClock variable.
SystemCoreClockUpdate(); SystemCoreClockUpdate();
#if !defined(TOOLCHAIN_GCC_ARM)
// Need to restart HAL driver after the RAM is initialized // Need to restart HAL driver after the RAM is initialized
HAL_Init(); HAL_Init();
#endif
} }
/** /**

View File

@ -35,8 +35,10 @@ void mbed_sdk_init()
{ {
// Update the SystemCoreClock variable. // Update the SystemCoreClock variable.
SystemCoreClockUpdate(); SystemCoreClockUpdate();
#if !defined(TOOLCHAIN_GCC_ARM)
// Need to restart HAL driver after the RAM is initialized // Need to restart HAL driver after the RAM is initialized
HAL_Init(); HAL_Init();
#endif
} }

View File

@ -32,4 +32,8 @@ void mbed_sdk_init()
{ {
// Update the SystemCoreClock variable. // Update the SystemCoreClock variable.
SystemCoreClockUpdate(); SystemCoreClockUpdate();
#if !defined(TOOLCHAIN_GCC_ARM)
// Need to restart HAL driver after the RAM is initialized
HAL_Init();
#endif
} }

View File

@ -35,6 +35,10 @@ void mbed_sdk_init()
{ {
// Update the SystemCoreClock variable. // Update the SystemCoreClock variable.
SystemCoreClockUpdate(); SystemCoreClockUpdate();
#if !defined(TOOLCHAIN_GCC_ARM)
// Need to restart HAL driver after the RAM is initialized
HAL_Init();
#endif
#if defined(TARGET_XDOT_L151CC) #if defined(TARGET_XDOT_L151CC)
if (PWR->CSR & PWR_CSR_SBF) { if (PWR->CSR & PWR_CSR_SBF) {

View File

@ -32,4 +32,8 @@ void mbed_sdk_init()
{ {
// Update the SystemCoreClock variable. // Update the SystemCoreClock variable.
SystemCoreClockUpdate(); SystemCoreClockUpdate();
#if !defined(TOOLCHAIN_GCC_ARM)
// Need to restart HAL driver after the RAM is initialized
HAL_Init();
#endif
} }