diff --git a/os/hal/platforms/STM32F4xx/hal_lld.c b/os/hal/platforms/STM32F4xx/hal_lld.c index e3cf144e1..521a1723a 100644 --- a/os/hal/platforms/STM32F4xx/hal_lld.c +++ b/os/hal/platforms/STM32F4xx/hal_lld.c @@ -208,9 +208,14 @@ void stm32_clock_init(void) { RCC->CFGR |= STM32_MCO2PRE | STM32_MCO2SEL | STM32_MCO1PRE | STM32_MCO1SEL | STM32_RTCPRE | STM32_PPRE2 | STM32_PPRE1 | STM32_HPRE; - /* Flash setup.*/ - FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN | FLASH_ACR_DCEN | - STM32_FLASHBITS; + /* Flash setup. + Some old revisions of F4x MCUs randomly crashes with compiler + optimizations enabled AND flash caches enabled. */ + if ((DBGMCU->IDCODE == 0x20006411) && (SCB->CPUID == 0x410FC241)) + FLASH->ACR = FLASH_ACR_PRFTEN | STM32_FLASHBITS; + else + FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN | + FLASH_ACR_DCEN | STM32_FLASHBITS; /* Switching to the configured clock source if it is different from MSI.*/ #if (STM32_SW != STM32_SW_HSI) diff --git a/readme.txt b/readme.txt index b63beac99..a31dcb240 100644 --- a/readme.txt +++ b/readme.txt @@ -82,6 +82,8 @@ ***************************************************************************** *** 2.5.1 *** +- FIX: Fixed workaround for errata in STM32F4-A devices (bug 3586425) + (backported to 2.4.3). - FIX: Fixed error in palWritePad() macro (bug 3586230)(backported to 2.2.10 and 2.4.3). - FIX: Fixed missing ; in testmbox.c (bug 3585979)(backported to 2.4.3).