Skip to content

Flash writing is broken for some dual-bank STM32H7 variants #97593

@zagor

Description

@zagor

Describe the bug

Pull request #88377 changed how flash size is obtained, from calling LL_GetFlashSize() to extracting the information from the device tree.

Pull request #90254 added a workaround for dual-bank flashes, on the assumption that the device tree only specifies the per-bank flash size. This assumption was unfortunately wrong. Only some H7 variants specify per-bank size, the other ones specify full flash size:

.../dts/arm/st/h7 (main)$ git grep 0x08000000 *Xi*
stm32h742Xi.dtsi:                               reg = <0x08000000 DT_SIZE_K(2048)>;
stm32h743Xi.dtsi:                               reg = <0x08000000 DT_SIZE_K(2048)>;
stm32h745Xi_m7.dtsi:                            reg = <0x08000000 DT_SIZE_K(1024)>;
stm32h747Xi_m7.dtsi:                            reg = <0x08000000 DT_SIZE_K(1024)>;
stm32h753Xi.dtsi:                               reg = <0x08000000 DT_SIZE_K(2048)>;
stm32h755Xi_m7.dtsi:                            reg = <0x08000000 DT_SIZE_K(1024)>;
stm32h757Xi_m7.dtsi:                            reg = <0x08000000 DT_SIZE_K(1024)>;
stm32h7a3Xi.dtsi:                               reg = <0x08000000 DT_SIZE_K(2048)>;
stm32h7b3Xi.dtsi:                               reg = <0x08000000 DT_SIZE_K(2048)>;

The effect of this is that get_sector() in flash_stm32h7.c returns .bank = 1 for flash offsets that are in bank 2, causing the driver to use the wrong set of registers and thus failing to perform the write.

I am unsure what the proper fix is here, which is why I'm writing this in a bug report rather than a pull request.

Ping @pillo79 @erwango @FRASTM @kartben @djiatsaf-st

Regression

  • This is a regression.

Steps to reproduce

No response

Relevant log output

Impact

Major – Severely degrades functionality; workaround is difficult or unavailable.

Environment

No response

Additional Context

No response

Metadata

Metadata

Assignees

Labels

area: FlashbugThe issue is a bug, or the PR is fixing a bugplatform: STM32ST Micro STM32priority: lowLow impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions