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:Luca Burelli <l.burelli@arduino.cc>
Loading
Please sign in to comment