mbed
Fork of mbed-dev by
Diff: targets/TARGET_STM/mbed_overrides.c
- Revision:
- 182:57724642e740
- Parent:
- 168:9672193075cf
--- a/targets/TARGET_STM/mbed_overrides.c Wed Jan 17 15:23:54 2018 +0000 +++ b/targets/TARGET_STM/mbed_overrides.c Fri Feb 16 16:09:33 2018 +0000 @@ -30,16 +30,23 @@ // This function is called after RAM initialization and before main. void mbed_sdk_init() { +#if TARGET_STM32F7 + // The mbed_sdk_init can be called either during cold boot or during + // application boot after bootloader has been executed. + // In case the bootloader has already enabled the cache, + // is is needed to not enable it again. + if ((SCB->CCR & (uint32_t)SCB_CCR_IC_Msk) == 0) { // If ICache is disabled + SCB_EnableICache(); + } + if ((SCB->CCR & (uint32_t)SCB_CCR_DC_Msk) == 0) { // If DCache is disabled + SCB_EnableDCache(); + } +#endif /* TARGET_STM32F7 */ + // Update the SystemCoreClock variable. SystemCoreClockUpdate(); HAL_Init(); -#if TARGET_STM32F7 - // Enable CPU L1-Cache - SCB_EnableICache(); - SCB_EnableDCache(); -#endif /* TARGET_STM32F7 */ - /* Configure the System clock source, PLL Multiplier and Divider factors, AHB/APBx prescalers and Flash settings */ SetSysClock();