drivers: flash_stm32h7: fix flash size detection #90254
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



Commit 0e41b07 ("drivers : flash: update way to get flash size") changed the way total Flash size is retrieved from the
LL_FLASH_GetSize()HAL function to the currentDT_REG_SIZE()macro.However, they are not equivalent:
With
LL_FLASH_GetSize(),REAL_FLASH_SIZE_KBreturned 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()reads the size from a flash bank, therefore it only returns half of the total Flash size on dual bank devices.This mismatch causes issues with the
DISCONTINUOUS_BANKSlogic 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.
Fixes #90252.