Skip to content

Commit ea1245e

Browse files
rpiperkartben
authored andcommitted
drivers: flash_stm32h7: Fix REAL_FLASH_SIZE_KB size
For devices other than the stm32h745/747/755/757 that use dual-core cortex-M4/cortex-M7, do not multiply flash controller size by 2. Single-core stm32h7x devices define their flash-controllers dtsi as a single area, not two banks. Use the presence of the bank2-flash-size prop to determine if this is a dual-core stm3h7x or not. Signed-off-by: Rory Piper <[email protected]>
1 parent 071b571 commit ea1245e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/flash/flash_stm32h7x.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ LOG_MODULE_REGISTER(LOG_DOMAIN);
3737
/* No information in documentation about that. */
3838
#define STM32H7_FLASH_OPT_TIMEOUT_MS 800
3939

40+
#if DT_NODE_HAS_PROP(DT_INST(0, st_stm32_nv_flash), bank2_flash_size)
4041
#define STM32H7_M4_FLASH_SIZE DT_PROP_OR(DT_INST(0, st_stm32_nv_flash), bank2_flash_size, 0)
4142
#ifdef CONFIG_CPU_CORTEX_M4
4243
#if STM32H7_M4_FLASH_SIZE == 0
@@ -45,12 +46,11 @@ LOG_MODULE_REGISTER(LOG_DOMAIN);
4546
#define REAL_FLASH_SIZE_KB (KB(STM32H7_M4_FLASH_SIZE * 2))
4647
#endif
4748
#else
48-
#if defined(DUAL_BANK)
4949
#define REAL_FLASH_SIZE_KB (DT_REG_SIZE(DT_INST(0, st_stm32_nv_flash)) * 2)
50+
#endif
5051
#else
5152
#define REAL_FLASH_SIZE_KB DT_REG_SIZE(DT_INST(0, st_stm32_nv_flash))
5253
#endif
53-
#endif
5454
#define SECTOR_PER_BANK ((REAL_FLASH_SIZE_KB / FLASH_SECTOR_SIZE) / 2)
5555
#if defined(DUAL_BANK)
5656
#define STM32H7_SERIES_MAX_FLASH_KB KB(2048)

0 commit comments

Comments
 (0)