From fe9d3174bfc0c2c0020f0f56bc33943f6adadb00 Mon Sep 17 00:00:00 2001 From: Laurent MEUNIER Date: Mon, 11 Jul 2016 16:14:03 +0200 Subject: [PATCH 1/6] 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 --- targets/TARGET_STM/TARGET_STM32F0/mbed_overrides.c | 4 ++-- targets/TARGET_STM/TARGET_STM32F1/mbed_overrides.c | 2 ++ targets/TARGET_STM/TARGET_STM32F3/mbed_overrides.c | 2 ++ targets/TARGET_STM/TARGET_STM32F4/mbed_overrides.c | 2 ++ targets/TARGET_STM/TARGET_STM32F7/mbed_overrides.c | 2 ++ targets/TARGET_STM/TARGET_STM32L0/mbed_overrides.c | 4 ++++ targets/TARGET_STM/TARGET_STM32L1/mbed_overrides.c | 4 ++++ targets/TARGET_STM/TARGET_STM32L4/mbed_overrides.c | 4 ++++ 8 files changed, 22 insertions(+), 2 deletions(-) diff --git a/targets/TARGET_STM/TARGET_STM32F0/mbed_overrides.c b/targets/TARGET_STM/TARGET_STM32F0/mbed_overrides.c index cf25b0328c..a14c2980e1 100644 --- a/targets/TARGET_STM/TARGET_STM32F0/mbed_overrides.c +++ b/targets/TARGET_STM/TARGET_STM32F0/mbed_overrides.c @@ -31,8 +31,8 @@ void mbed_sdk_init() { // Update the SystemCoreClock variable. SystemCoreClockUpdate(); - +#if !defined(TOOLCHAIN_GCC_ARM) // Need to restart HAL driver after the RAM is initialized HAL_Init(); - +#endif } diff --git a/targets/TARGET_STM/TARGET_STM32F1/mbed_overrides.c b/targets/TARGET_STM/TARGET_STM32F1/mbed_overrides.c index 9783dd90a5..2252f1c824 100644 --- a/targets/TARGET_STM/TARGET_STM32F1/mbed_overrides.c +++ b/targets/TARGET_STM/TARGET_STM32F1/mbed_overrides.c @@ -32,6 +32,8 @@ void mbed_sdk_init() { // Update the SystemCoreClock variable. SystemCoreClockUpdate(); +#if !defined(TOOLCHAIN_GCC_ARM) // Need to restart HAL driver after the RAM is initialized HAL_Init(); +#endif } diff --git a/targets/TARGET_STM/TARGET_STM32F3/mbed_overrides.c b/targets/TARGET_STM/TARGET_STM32F3/mbed_overrides.c index 9783dd90a5..2252f1c824 100644 --- a/targets/TARGET_STM/TARGET_STM32F3/mbed_overrides.c +++ b/targets/TARGET_STM/TARGET_STM32F3/mbed_overrides.c @@ -32,6 +32,8 @@ void mbed_sdk_init() { // Update the SystemCoreClock variable. SystemCoreClockUpdate(); +#if !defined(TOOLCHAIN_GCC_ARM) // Need to restart HAL driver after the RAM is initialized HAL_Init(); +#endif } diff --git a/targets/TARGET_STM/TARGET_STM32F4/mbed_overrides.c b/targets/TARGET_STM/TARGET_STM32F4/mbed_overrides.c index a21a749f80..93e4da780b 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/mbed_overrides.c +++ b/targets/TARGET_STM/TARGET_STM32F4/mbed_overrides.c @@ -33,8 +33,10 @@ void mbed_sdk_init() { // Update the SystemCoreClock variable. SystemCoreClockUpdate(); +#if !defined(TOOLCHAIN_GCC_ARM) // Need to restart HAL driver after the RAM is initialized HAL_Init(); +#endif } /** diff --git a/targets/TARGET_STM/TARGET_STM32F7/mbed_overrides.c b/targets/TARGET_STM/TARGET_STM32F7/mbed_overrides.c index 496c4adc66..6b174b8980 100644 --- a/targets/TARGET_STM/TARGET_STM32F7/mbed_overrides.c +++ b/targets/TARGET_STM/TARGET_STM32F7/mbed_overrides.c @@ -35,8 +35,10 @@ void mbed_sdk_init() { // Update the SystemCoreClock variable. SystemCoreClockUpdate(); +#if !defined(TOOLCHAIN_GCC_ARM) // Need to restart HAL driver after the RAM is initialized HAL_Init(); +#endif } diff --git a/targets/TARGET_STM/TARGET_STM32L0/mbed_overrides.c b/targets/TARGET_STM/TARGET_STM32L0/mbed_overrides.c index 509fed2198..4025d0aaa0 100644 --- a/targets/TARGET_STM/TARGET_STM32L0/mbed_overrides.c +++ b/targets/TARGET_STM/TARGET_STM32L0/mbed_overrides.c @@ -32,4 +32,8 @@ void mbed_sdk_init() { // Update the SystemCoreClock variable. SystemCoreClockUpdate(); +#if !defined(TOOLCHAIN_GCC_ARM) + // Need to restart HAL driver after the RAM is initialized + HAL_Init(); +#endif } diff --git a/targets/TARGET_STM/TARGET_STM32L1/mbed_overrides.c b/targets/TARGET_STM/TARGET_STM32L1/mbed_overrides.c index 2d91ef23c1..9b9c85031f 100644 --- a/targets/TARGET_STM/TARGET_STM32L1/mbed_overrides.c +++ b/targets/TARGET_STM/TARGET_STM32L1/mbed_overrides.c @@ -35,6 +35,10 @@ void mbed_sdk_init() { // Update the SystemCoreClock variable. 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 (PWR->CSR & PWR_CSR_SBF) { diff --git a/targets/TARGET_STM/TARGET_STM32L4/mbed_overrides.c b/targets/TARGET_STM/TARGET_STM32L4/mbed_overrides.c index 509fed2198..4025d0aaa0 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/mbed_overrides.c +++ b/targets/TARGET_STM/TARGET_STM32L4/mbed_overrides.c @@ -32,4 +32,8 @@ void mbed_sdk_init() { // Update the SystemCoreClock variable. SystemCoreClockUpdate(); +#if !defined(TOOLCHAIN_GCC_ARM) + // Need to restart HAL driver after the RAM is initialized + HAL_Init(); +#endif } From f50e23aea6d5c4dab6db6ada61de4e0efde9a0e2 Mon Sep 17 00:00:00 2001 From: Laurent MEUNIER Date: Mon, 11 Jul 2016 16:14:03 +0200 Subject: [PATCH 2/6] 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 --- platform/retarget.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/platform/retarget.cpp b/platform/retarget.cpp index 17af0798b3..fbeff4c6a7 100644 --- a/platform/retarget.cpp +++ b/platform/retarget.cpp @@ -524,10 +524,14 @@ extern "C" WEAK void mbed_sdk_init(void) { extern "C" int $Super$$main(void); extern "C" int $Sub$$main(void) { - mbed_sdk_init(); mbed_main(); return $Super$$main(); } + +extern "C" void _platform_post_stackheap_init (void) { + mbed_sdk_init(); +} + #elif defined(TOOLCHAIN_GCC) extern "C" int __real_main(void); From e8d67ac530bc6e229c2fb53a63eea32bea726325 Mon Sep 17 00:00:00 2001 From: Laurent MEUNIER Date: Mon, 11 Jul 2016 16:14:03 +0200 Subject: [PATCH 3/6] INIT: uARM no rtos: Align pre-main initialization steps between TCs In uARM, the library's hook _platform_post_stackheap_init does not seem to exist and I couldnot find a documentation describing the initialisation flow. All we know is that _open is called after RAM init and before the C++ init, so this is a working placeholder. This is maybe not acceptable so a uARM lib expert may propose a better hook to fullfil the requirement. At least this is a workign setup. This series should solve issue reported here: STM32 (At least F401) breaks if Tickers are activated in a global object #2115 --- platform/retarget.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/platform/retarget.cpp b/platform/retarget.cpp index fbeff4c6a7..d9787c8298 100644 --- a/platform/retarget.cpp +++ b/platform/retarget.cpp @@ -149,13 +149,21 @@ static inline int openmode_to_posix(int openmode) { return posix; } +extern "C" WEAK void mbed_sdk_init(void); +extern "C" WEAK void mbed_sdk_init(void) { +} + extern "C" FILEHANDLE PREFIX(_open)(const char* name, int openmode) { #if defined(__MICROLIB) && (__ARMCC_VERSION>5030000) // Before version 5.03, we were using a patched version of microlib with proper names // This is the workaround that the microlib author suggested us static int n = 0; + static int mbed_sdk_inited = 0; + if (!mbed_sdk_inited) { + mbed_sdk_inited = 1; + mbed_sdk_init(); + } if (!std::strcmp(name, ":tt")) return n++; - #else /* Use the posix convention that stdin,out,err are filehandles 0,1,2. */ @@ -516,10 +524,6 @@ extern "C" WEAK void mbed_main(void); extern "C" WEAK void mbed_main(void) { } -extern "C" WEAK void mbed_sdk_init(void); -extern "C" WEAK void mbed_sdk_init(void) { -} - #if defined(TOOLCHAIN_ARM) extern "C" int $Super$$main(void); From 3a61bd025f0d1c8f1fe5637b66eec78af11550b9 Mon Sep 17 00:00:00 2001 From: Laurent MEUNIER Date: Tue, 12 Jul 2016 18:09:08 +0200 Subject: [PATCH 4/6] 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 --- rtos/rtx/TARGET_CORTEX_M/RTX_CM_lib.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rtos/rtx/TARGET_CORTEX_M/RTX_CM_lib.h b/rtos/rtx/TARGET_CORTEX_M/RTX_CM_lib.h index ec59ccb760..267cec0d92 100644 --- a/rtos/rtx/TARGET_CORTEX_M/RTX_CM_lib.h +++ b/rtos/rtx/TARGET_CORTEX_M/RTX_CM_lib.h @@ -538,6 +538,7 @@ void pre_main (void) __asm void __rt_entry (void) { IMPORT __user_setup_stackheap + IMPORT _platform_post_stackheap_init IMPORT os_thread_def_main IMPORT osKernelInitialize #ifdef __MBED_CMSIS_RTOS_CM @@ -558,6 +559,7 @@ __asm void __rt_entry (void) { /* Ignore return value of __user_setup_stackheap since * this will be setup by set_stack_heap */ + BL _platform_post_stackheap_init BL osKernelInitialize #ifdef __MBED_CMSIS_RTOS_CM BL set_stack_heap From bcbe0b17de49dd926ac706c0be49e9a89d978203 Mon Sep 17 00:00:00 2001 From: Laurent MEUNIER Date: Wed, 17 Aug 2016 13:21:25 +0200 Subject: [PATCH 5/6] INIT:GCC with rtos: Align pre-main initialization steps between TCs In this commit we're moving the mbed_sdk_init call before the RTOS initialisation so that the sequence is similar to other toolchains. --- platform/retarget.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/platform/retarget.cpp b/platform/retarget.cpp index d9787c8298..3a1d3aef9e 100644 --- a/platform/retarget.cpp +++ b/platform/retarget.cpp @@ -509,7 +509,7 @@ extern "C" void software_init_hook(void) mbed_die(); } #endif/* FEATURE_UVISOR */ - + mbed_sdk_init(); software_init_hook_rtos(); } #endif @@ -540,7 +540,6 @@ extern "C" void _platform_post_stackheap_init (void) { extern "C" int __real_main(void); extern "C" int __wrap_main(void) { - mbed_sdk_init(); mbed_main(); return __real_main(); } From e8675033f47609e9be89c1b1e0602ae95d53f4d6 Mon Sep 17 00:00:00 2001 From: Laurent MEUNIER Date: Tue, 12 Jul 2016 18:16:12 +0200 Subject: [PATCH 6/6] [STM32] remove superfluous calls to SystemCoreClockUpdate Supported toolchains initialization steps have been modified to make sure that mbed_sdk_initi is called _after_ RAM initialization and _before_ C++ objects creation. since this was done, there is no need to redundant SystemCoreClockUpdates in the drivers --- targets/TARGET_STM/TARGET_STM32F0/pwmout_api.c | 3 --- targets/TARGET_STM/TARGET_STM32F0/serial_api.c | 4 ---- targets/TARGET_STM/TARGET_STM32F1/pwmout_api.c | 3 --- targets/TARGET_STM/TARGET_STM32F1/serial_api.c | 4 ---- targets/TARGET_STM/TARGET_STM32F2/serial_api.c | 4 ---- targets/TARGET_STM/TARGET_STM32F3/i2c_api.c | 3 --- targets/TARGET_STM/TARGET_STM32F3/serial_api.c | 3 --- targets/TARGET_STM/TARGET_STM32F4/serial_api.c | 4 ---- targets/TARGET_STM/TARGET_STM32F7/serial_api.c | 4 ---- targets/TARGET_STM/TARGET_STM32L1/pwmout_api.c | 2 -- targets/TARGET_STM/TARGET_STM32L1/serial_api.c | 4 ---- targets/TARGET_STM/TARGET_STM32L4/pwmout_api.c | 2 -- targets/TARGET_STM/TARGET_STM32L4/serial_api.c | 4 ---- 13 files changed, 44 deletions(-) diff --git a/targets/TARGET_STM/TARGET_STM32F0/pwmout_api.c b/targets/TARGET_STM/TARGET_STM32F0/pwmout_api.c index 6cea9f9b18..63368cc4c1 100644 --- a/targets/TARGET_STM/TARGET_STM32F0/pwmout_api.c +++ b/targets/TARGET_STM/TARGET_STM32F0/pwmout_api.c @@ -162,9 +162,6 @@ void pwmout_period_us(pwmout_t* obj, int us) { __HAL_TIM_DISABLE(&TimHandle); - // Update the SystemCoreClock variable - SystemCoreClockUpdate(); - /* To make it simple, we use to possible prescaler values which lead to: * pwm unit = 1us, period/pulse can be from 1us to 65535us * or diff --git a/targets/TARGET_STM/TARGET_STM32F0/serial_api.c b/targets/TARGET_STM/TARGET_STM32F0/serial_api.c index a5b49e1ef8..d956c5489e 100644 --- a/targets/TARGET_STM/TARGET_STM32F0/serial_api.c +++ b/targets/TARGET_STM/TARGET_STM32F0/serial_api.c @@ -90,10 +90,6 @@ static void init_uart(serial_t *obj) huart->Init.Mode = UART_MODE_TX_RX; } - /* uAMR & ARM: Call to UART init is done between reset of pre-initialized variables */ - /* and before HAL Init. SystemCoreClock init required here */ - SystemCoreClockUpdate(); - if (HAL_UART_Init(huart) != HAL_OK) { error("Cannot initialize UART\n"); } diff --git a/targets/TARGET_STM/TARGET_STM32F1/pwmout_api.c b/targets/TARGET_STM/TARGET_STM32F1/pwmout_api.c index cb24045c9e..4eb3a28c4f 100644 --- a/targets/TARGET_STM/TARGET_STM32F1/pwmout_api.c +++ b/targets/TARGET_STM/TARGET_STM32F1/pwmout_api.c @@ -152,9 +152,6 @@ void pwmout_period_us(pwmout_t* obj, int us) __HAL_TIM_DISABLE(&TimHandle); - // Update the SystemCoreClock variable - SystemCoreClockUpdate(); - /* To make it simple, we use to possible prescaler values which lead to: * pwm unit = 1us, period/pulse can be from 1us to 65535us * or diff --git a/targets/TARGET_STM/TARGET_STM32F1/serial_api.c b/targets/TARGET_STM/TARGET_STM32F1/serial_api.c index e88f9885b8..8d7940508f 100644 --- a/targets/TARGET_STM/TARGET_STM32F1/serial_api.c +++ b/targets/TARGET_STM/TARGET_STM32F1/serial_api.c @@ -82,10 +82,6 @@ static void init_uart(serial_t *obj) huart->Init.Mode = UART_MODE_TX_RX; } - /* uAMR & ARM: Call to UART init is done between reset of pre-initialized variables */ - /* and before HAL Init. SystemCoreClock init required here */ - SystemCoreClockUpdate(); - if (HAL_UART_Init(huart) != HAL_OK) { error("Cannot initialize UART\n"); } diff --git a/targets/TARGET_STM/TARGET_STM32F2/serial_api.c b/targets/TARGET_STM/TARGET_STM32F2/serial_api.c index e3a90c285a..5c9a12bc88 100644 --- a/targets/TARGET_STM/TARGET_STM32F2/serial_api.c +++ b/targets/TARGET_STM/TARGET_STM32F2/serial_api.c @@ -82,10 +82,6 @@ static void init_uart(serial_t *obj) huart->Init.Mode = UART_MODE_TX_RX; } - /* uAMR & ARM: Call to UART init is done between reset of pre-initialized variables */ - /* and before HAL Init. SystemCoreClock init required here */ - SystemCoreClockUpdate(); - if (HAL_UART_Init(huart) != HAL_OK) { error("Cannot initialize UART\n"); } diff --git a/targets/TARGET_STM/TARGET_STM32F3/i2c_api.c b/targets/TARGET_STM/TARGET_STM32F3/i2c_api.c index fae23e0501..5ecd267446 100644 --- a/targets/TARGET_STM/TARGET_STM32F3/i2c_api.c +++ b/targets/TARGET_STM/TARGET_STM32F3/i2c_api.c @@ -113,9 +113,6 @@ void i2c_frequency(i2c_t *obj, int hz) timeout = LONG_TIMEOUT; while ((__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_BUSY)) && (timeout-- != 0)); - // Update the SystemCoreClock variable. - SystemCoreClockUpdate(); - /* Values calculated with I2C_Timing_Configuration_V1.0.1.xls file (see AN4235) * Standard mode (up to 100 kHz) diff --git a/targets/TARGET_STM/TARGET_STM32F3/serial_api.c b/targets/TARGET_STM/TARGET_STM32F3/serial_api.c index 7624baa6f4..97b5f9e8eb 100644 --- a/targets/TARGET_STM/TARGET_STM32F3/serial_api.c +++ b/targets/TARGET_STM/TARGET_STM32F3/serial_api.c @@ -82,9 +82,6 @@ static void init_uart(serial_t *obj) huart->Init.Mode = UART_MODE_TX_RX; } - /* uAMR & ARM: Call to UART init is done between reset of pre-initialized variables */ - /* and before HAL Init. SystemCoreClock init required here */ - SystemCoreClockUpdate(); if (HAL_UART_Init(huart) != HAL_OK) { error("Cannot initialize UART\n"); diff --git a/targets/TARGET_STM/TARGET_STM32F4/serial_api.c b/targets/TARGET_STM/TARGET_STM32F4/serial_api.c index e77c92497f..7ac2dc9501 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/serial_api.c +++ b/targets/TARGET_STM/TARGET_STM32F4/serial_api.c @@ -84,10 +84,6 @@ static void init_uart(serial_t *obj) huart->Init.Mode = UART_MODE_TX_RX; } - /* uAMR & ARM: Call to UART init is done between reset of pre-initialized variables */ - /* and before HAL Init. SystemCoreClock init required here */ - SystemCoreClockUpdate(); - if (HAL_UART_Init(huart) != HAL_OK) { error("Cannot initialize UART\n"); } diff --git a/targets/TARGET_STM/TARGET_STM32F7/serial_api.c b/targets/TARGET_STM/TARGET_STM32F7/serial_api.c index 832e07bd88..32f890e870 100644 --- a/targets/TARGET_STM/TARGET_STM32F7/serial_api.c +++ b/targets/TARGET_STM/TARGET_STM32F7/serial_api.c @@ -83,10 +83,6 @@ static void init_uart(serial_t *obj) huart->Init.Mode = UART_MODE_TX_RX; } - /* uAMR & ARM: Call to UART init is done between reset of pre-initialized variables */ - /* and before HAL Init. SystemCoreClock init required here */ - SystemCoreClockUpdate(); - if (HAL_UART_Init(huart) != HAL_OK) { error("Cannot initialize UART\n"); } diff --git a/targets/TARGET_STM/TARGET_STM32L1/pwmout_api.c b/targets/TARGET_STM/TARGET_STM32L1/pwmout_api.c index bbbcbb3567..6e4e85e835 100644 --- a/targets/TARGET_STM/TARGET_STM32L1/pwmout_api.c +++ b/targets/TARGET_STM/TARGET_STM32L1/pwmout_api.c @@ -166,8 +166,6 @@ void pwmout_period_us(pwmout_t* obj, int us) __HAL_TIM_DISABLE(&TimHandle); - SystemCoreClockUpdate(); - /* To make it simple, we use to possible prescaler values which lead to: * pwm unit = 1us, period/pulse can be from 1us to 65535us * or diff --git a/targets/TARGET_STM/TARGET_STM32L1/serial_api.c b/targets/TARGET_STM/TARGET_STM32L1/serial_api.c index 2dce257a06..9f804f521e 100755 --- a/targets/TARGET_STM/TARGET_STM32L1/serial_api.c +++ b/targets/TARGET_STM/TARGET_STM32L1/serial_api.c @@ -82,10 +82,6 @@ static void init_uart(serial_t *obj) huart->Init.Mode = UART_MODE_TX_RX; } - /* uAMR & ARM: Call to UART init is done between reset of pre-initialized variables */ - /* and before HAL Init. SystemCoreClock init required here */ - SystemCoreClockUpdate(); - if (HAL_UART_Init(huart) != HAL_OK) { error("Cannot initialize UART\n"); } diff --git a/targets/TARGET_STM/TARGET_STM32L4/pwmout_api.c b/targets/TARGET_STM/TARGET_STM32L4/pwmout_api.c index 8d12141400..8b8cfe9068 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/pwmout_api.c +++ b/targets/TARGET_STM/TARGET_STM32L4/pwmout_api.c @@ -167,8 +167,6 @@ void pwmout_period_us(pwmout_t* obj, int us) __HAL_TIM_DISABLE(&TimHandle); - SystemCoreClockUpdate(); - /* To make it simple, we use to possible prescaler values which lead to: * pwm unit = 1us, period/pulse can be from 1us to 65535us * or diff --git a/targets/TARGET_STM/TARGET_STM32L4/serial_api.c b/targets/TARGET_STM/TARGET_STM32L4/serial_api.c index 0664d1fdc9..3458a8bf39 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/serial_api.c +++ b/targets/TARGET_STM/TARGET_STM32L4/serial_api.c @@ -82,10 +82,6 @@ static void init_uart(serial_t *obj) huart->Init.Mode = UART_MODE_TX_RX; } - /* uAMR & ARM: Call to UART init is done between reset of pre-initialized variables */ - /* and before HAL Init. SystemCoreClock init required here */ - SystemCoreClockUpdate(); - if (HAL_UART_Init(huart) != HAL_OK) { error("Cannot initialize UART\n"); }