From 3597e899c90ac79c3c5ac43f9ba8d159ddecebfd Mon Sep 17 00:00:00 2001 From: Hans Christian Olaussen <41271048+klutvott123@users.noreply.github.com> Date: Sun, 10 Mar 2019 20:11:26 +0100 Subject: [PATCH] Move enabling of caches for F7 Moves cache enabling from SystemInit() to init() as it is not recommended to enable caches before entering main function. --- src/main/fc/init.c | 16 ++++++++++++++++ src/main/startup/system_stm32f7xx.c | 14 -------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/main/fc/init.c b/src/main/fc/init.c index 1b78b59bf2..e5a7a51d61 100644 --- a/src/main/fc/init.c +++ b/src/main/fc/init.c @@ -249,6 +249,22 @@ void init(void) HAL_Init(); #endif +#if defined(STM32F7) + /* Enable I-Cache */ + if (INSTRUCTION_CACHE_ENABLE) { + SCB_EnableICache(); + } + + /* Enable D-Cache */ + if (DATA_CACHE_ENABLE) { + SCB_EnableDCache(); + } + + if (PREFETCH_ENABLE) { + LL_FLASH_EnablePrefetch(); + } +#endif + printfSupportInit(); systemInit(); diff --git a/src/main/startup/system_stm32f7xx.c b/src/main/startup/system_stm32f7xx.c index 36cfea6760..182b8a789c 100644 --- a/src/main/startup/system_stm32f7xx.c +++ b/src/main/startup/system_stm32f7xx.c @@ -345,20 +345,6 @@ void SystemInit(void) } SCB->VTOR = vtorOffset; - /* Enable I-Cache */ - if (INSTRUCTION_CACHE_ENABLE) { - SCB_EnableICache(); - } - - /* Enable D-Cache */ - if (DATA_CACHE_ENABLE) { - SCB_EnableDCache(); - } - - if (PREFETCH_ENABLE) { - LL_FLASH_EnablePrefetch(); - } - /* Configure the system clock to specified frequency */ SystemClock_Config();