Skip to content

Conversation

tpambor
Copy link
Contributor

@tpambor tpambor commented Oct 16, 2025

Commit 5d0306c of #88579 moved the slot0_partition, slot1_partition, scratch_partition from the internal flash to the external OSPI NOR flash. At the same time, the nor partition on the external NOR flash was deleted. This breaks all applications that rely on the slot0_partition, slot1_partition, scratch_partition to be on internal flash as well as all applications that use the nor partition on external flash with the stm32h573i_dk board.

To avoid breaking existing projects and maintain compatibility with previous versions of Zephyr, this PR restores the default flash layout and introduces a new board variant for applications stored in external flash. This approach allows users to opt-in to the new flash layout without affecting existing projects.

A similar ext_flash_app variant is proposed for the STM32H750B-DK in #97037.

Fixes #97423.

@erwango
Copy link
Member

erwango commented Oct 16, 2025

@tpambor Thanks for this, but don't you miss to add an overlay in mcuboot repo to provide the right zephyr,flash and zephyr,flash-controller ? (Dependency that I'd like to get rid of but mandatory today for current version of #97037)

@tpambor
Copy link
Contributor Author

tpambor commented Oct 16, 2025

@tpambor Thanks for this, but don't you miss to add an overlay in mcuboot repo to provide the right zephyr,flash and zephyr,flash-controller ? (Dependency that I'd like to get rid of but mandatory today for current version of #97037)

You are right, I missed that, currently it places mcuboot in external flash, so a overlay is necessary for mcuboot.

	/* node '/chosen' defined in zephyr/dts/common/skeleton.dtsi:13 */
	chosen {
...
		zephyr,flash = &ext_flash;                 /* in zephyr/boards/st/stm32h573i_dk/stm32h573i_dk_stm32h573xx_ext_flash_app.dts:15 */
		zephyr,flash-controller = &ext_flash_ctrl; /* in zephyr/boards/st/stm32h573i_dk/stm32h573i_dk_stm32h573xx_ext_flash_app.dts:16 */
		zephyr,code-partition = &boot_partition;   /* in bootloader/mcuboot/boot/zephyr/app.overlay:3 */
	};

Copy link
Contributor

@etienne-lms etienne-lms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overall looks good to me and is more consistent regarding the board initial layout.

For commit "boards: st: stm32h573i_dk: Add board variant for app in external flash":
Would it be worth to add an entry in the board doc to mention the new variant?

For commit "mgmt: hawkbit: Replace overlay with new board variant":
Could you prefix the commit message header line with samples: ?

@tpambor tpambor force-pushed the stm32h573-flash-layout branch from 152ff6c to 96a7604 Compare October 16, 2025 12:13
@github-actions
Copy link

github-actions bot commented Oct 16, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff

All manifest checks OK

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@github-actions github-actions bot removed manifest-mcuboot_upstream DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Oct 22, 2025
@tpambor tpambor force-pushed the stm32h573-flash-layout branch from 172518b to 2561112 Compare October 22, 2025 11:47
if BOARD_STM32H573I_DK_STM32H573XX_EXT_FLASH_APP

choice MCUBOOT_MODE
default MCUBOOT_MODE_DIRECT_XIP
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK with boards using different defaults for the mode, sure some other features might not be compatible with a specific configuration but that's just how those features are, direct-xip is a valid supported MCUboot mode and fine for any board to use (by default or otherwise)

@tpambor tpambor force-pushed the stm32h573-flash-layout branch from 2561112 to 654e8cd Compare October 22, 2025 12:07
Copy link
Contributor

@JarmouniA JarmouniA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please rework the 2 commits concerning the board, put everything concerning the base variant (with the common dtsi) in a 1st commit which builds and runs correctly with & without MCUboot. Then, introduce the ext_flash_app variant in a 2nd commit.

@tpambor
Copy link
Contributor Author

tpambor commented Oct 22, 2025

Can you please rework the 2 commits concerning the board, put everything concerning the base variant (with the common dtsi) in a 1st commit which builds and runs correctly with & without MCUboot. Then, introduce the ext_flash_app variant in a 2nd commit.

The motivation for having the two commits like this was that current main is external flash only, so splitting it into first commit internal flash, second commit external flash, would require reverting some changes and re-introduce at the same time the old layout from 4.2 which used internal flash and then in second commit re-apply the changes from master to have external flash.

@JarmouniA
Copy link
Contributor

JarmouniA commented Oct 22, 2025

so splitting it into first commit internal flash, second commit external flash, would require reverting some changes and re-introduce at the same time the old layout from 4.2 which used internal flash and then in second commit re-apply the changes from master to have external flash.

I don't see an issue with that. You can also just put everything (board-related) is one commit (and detail all the changes & the reasoning behind them in the commit message).

FYI, a commit is required to build & run correctly without the following one(s). See the 7th point https://docs.zephyrproject.org/latest/contribute/contributor_expectations.html#pr-requirements

@tpambor tpambor force-pushed the stm32h573-flash-layout branch from 654e8cd to 0c01bea Compare October 22, 2025 13:43
JarmouniA
JarmouniA previously approved these changes Oct 22, 2025
Copy link
Contributor

@JarmouniA JarmouniA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single App mode does not support image upgrade.

@tpambor tpambor force-pushed the stm32h573-flash-layout branch from 91c3987 to a6736b2 Compare October 22, 2025 19:00
@tpambor tpambor requested a review from JarmouniA October 22, 2025 19:11
JarmouniA
JarmouniA previously approved these changes Oct 22, 2025
compatible = "soc-nv-flash";
reg = <0x0 DT_SIZE_M(64)>;
write-block-size = <1>;
erase-block-size = <DT_SIZE_K(64)>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
erase-block-size = <DT_SIZE_K(64)>;
erase-block-size = <DT_SIZE_K(4)>;

should be the smallest supported

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #97037 (comment)

It should probably also fix the swap modes, meaning we can get rid of the default. But I have to verify this tomorrow on my dev board

Copy link
Contributor

@JarmouniA JarmouniA Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tpambor I switched H750B-DK to swap-using-offset after fixing the erase-block-size (which fixed all swap modes), up to you if you want to do the same here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just do it like in the other PR, but add both variants to the hawkbit sample test.

Copy link
Contributor Author

@tpambor tpambor Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, now it boots here also in swap mode. I kept both variants for the hawkbit sample.

@sonarqubecloud
Copy link

Restore old internal flash layout as default and make app in external
flash a new board variant

Switch mcuboot to use swap mode and remove the no longer required
scratch partitions from the internal and external flash layout.

Introduce a 'soc-nv-flash' node in the stm32h573i_dk board DTS file
to define the external flash memory parameters used for MCUBoot
integration. This way BOOT_MAX_IMG_SECTORS_AUTO can be used to
automatically calculate the maximum number of image sectors based
on the actual external flash configuration.

Signed-off-by: Tim Pambor <[email protected]>
Replace overlay for stm32h573i_dk with new board variant designed to
run from external flash.

Signed-off-by: Tim Pambor <[email protected]>
Replace overlay for stm32h573i_dk with new board variant designed to
run in external flash. Keep stm32h573i_dk as it also can run mcuboot.

Signed-off-by: Tim Pambor <[email protected]>
Add stm32h573i_dk and the ext_flash_app board to the allowed boards
for the mcuboot tests.

Signed-off-by: Tim Pambor <[email protected]>
@tpambor tpambor force-pushed the stm32h573-flash-layout branch from 63c9afe to 51fb7c3 Compare October 22, 2025 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flash partitions layout changed for stm32h573i_dk

7 participants