Skip to content

Commit 4021dd3

Browse files
kbidanijhedberg
authored andcommitted
soc: stm32g0: Add configurable FLASH prefetch option for G0B0/G0B1/G0C1
Default disable flash prefetch on G0Bx/G0C1 to prevent issues described by errata ES0548 2.2.10. Project can still enable the config if applicable. Signed-off-by: Khaoula Bidani <[email protected]>
1 parent 5cbb2a4 commit 4021dd3

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

soc/st/stm32/stm32g0x/Kconfig.defconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,12 @@ config SHARED_INTERRUPTS
4949

5050
endif # UART_STM32
5151

52+
# Default enable flash prefetch for all G0xx SoCs but G0Bx, G0Cx since ErrataSheet
53+
# ES0548/ES0549, section "Prefetch failure when branching across flash memory banks
54+
# which causes code execution corruption and may lead to HardFault interrupt"
55+
# Project may override this configuration if sure no cross-bank prefetch access is
56+
# awaited.
57+
config STM32_FLASH_PREFETCH
58+
default y if !SOC_STM32G0B0XX && !SOC_STM32G0B1XX && !SOC_STM32G0C1XX
59+
5260
endif # SOC_SERIES_STM32G0X

soc/st/stm32/stm32g0x/soc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ void soc_early_init_hook(void)
8282
{
8383
/* Enable ART Accelerator I-cache and prefetch */
8484
LL_FLASH_EnableInstCache();
85+
86+
/* Working around ErrataSheets ES0548/ES0549 section 2.2.10 may prevent enabling flash prefetch */
87+
#if defined(CONFIG_STM32_FLASH_PREFETCH)
8588
LL_FLASH_EnablePrefetch();
89+
#endif
8690

8791
/* Update CMSIS SystemCoreClock variable (HCLK) */
8892
/* At reset, system core clock is set to 16 MHz from HSI */

0 commit comments

Comments
 (0)