Skip to content
Commit 8151dd9c authored by Luca Burelli's avatar Luca Burelli Committed by Benjamin Cabé
Browse files

drivers: flash_stm32h7: fix flash size detection



Commit 0e41b073 ("drivers : flash:
update way to get flash size") changed the way to get flash size from
the LL_FLASH_GetSize() HAL function to the current DT_REG_SIZE() macro.

However, they are not equivalent:

- With LL_FLASH_GetSize(), REAL_FLASH_SIZE_KB returned the *total* size
  of the Flash memory, reading it from a ROM register of the CPU. For
  example, it was 2048 (2MB) for a STM32H747xI.

- The current DT_REG_SIZE() applies to a flash *bank*, therefore it only
  returns half of the total Flash size on dual bank devices.

This mismatch causes issues with the DISCONTINUOUS_BANKS logic below,
incorrectly matching partitions close to the end of the first bank as
appearing to span both and triggering the "range overlaps discontinuity"
check later.

Fix it by doubling the size when appropriate, in the same way it is
already done for the M4 core.

Signed-off-by: default avatarLuca Burelli <l.burelli@arduino.cc>
parent 65b74709
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment