Skip to content

Conversation

@pillo79
Copy link
Contributor

@pillo79 pillo79 commented May 21, 2025

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 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() 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_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.

Fixes #90252.

Commit 0e41b07 ("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>
@sonarqubecloud
Copy link

@pillo79 pillo79 added the bug The issue is a bug, or the PR is fixing a bug label May 21, 2025
@kartben kartben merged commit 8151dd9 into zephyrproject-rtos:main May 23, 2025
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Flash bug The issue is a bug, or the PR is fixing a bug platform: STM32 ST Micro STM32

Projects

None yet

Development

Successfully merging this pull request may close these issues.

drivers: flash_stm32h7: partition check issue

5 participants