Skip to content

Conversation

FRASTM
Copy link
Contributor

@FRASTM FRASTM commented Jul 11, 2025

Following the stm32h5 run application in external flash memory XIP

This PR makes the samples/sysbuild/with_mcuboot --sysbuild running on a variant of the stm32u585 disco kit.

Requires the ./bootloader/mcuboot/bootzephyr/boards/b_u585i_iot02a_stm32u585xx_ext_flash_app.conf :

CONFIG_BOOT_DIRECT_XIP=y
CONFIG_STM32_MEMMAP=y

run the west build -p -b b_u585i_iot02a/stm32u585xx/ext_flash_app samples/sysbuild/with_mcuboot --sysbuild

*** Booting MCUboot v2.1.0-rc1-390-gfbc9aff5acc1 ***
*** Using Zephyr OS build v4.2.0-rc2-72-g8c58be376223 ***
*** Booting Zephyr OS build v4.2.0-rc2-72-g8c58be376223 ***
Address of sample 0x70000000
Hello sysbuild with mcuboot! b_u585i_iot02a

Requires boot/zephyr/boards/b_u585i_iot02a.conf

CONFIG_BOOT_DIRECT_XIP=y
CONFIG_STM32_MEMMAP=y

@FRASTM FRASTM force-pushed the stm32u5_xip branch 2 times, most recently from d02c1a8 to f4991ef Compare July 15, 2025 09:50
@JarmouniA
Copy link
Contributor

Requires boot/zephyr/boards/b_u585i_iot02a.conf

CONFIG_BOOT_DIRECT_XIP=y
CONFIG_STM32_MEMMAP=y

MCUboot mode should not be set on MCUboot side in my opinion, it should be set on Zephyr side using Sysbuild (SB_CONFIG_MCUBOOT_MODE_DIRECT_XIP) at the board or app level so that the setting is propagated properly to both MCUboot and App builds.
Furthermore, this approach is creating some problems already, see #93113

@FRASTM
Copy link
Contributor Author

FRASTM commented Jul 15, 2025

Define the partition of the external octo NOR in the b_u858i_iot02a.dts to avoid conflict with the partitioning of the b_u858i_iot02a_ns.dts.

@FRASTM FRASTM changed the title stm32u5 run application in external flash memory XIP stm32 ospi driver : run application in external flash memory XIP Jul 15, 2025
@FRASTM
Copy link
Contributor Author

FRASTM commented Jul 16, 2025

fixing compliance issues

@FRASTM FRASTM force-pushed the stm32u5_xip branch 2 times, most recently from 4028e70 to a08697f Compare July 17, 2025 12:42
@FRASTM
Copy link
Contributor Author

FRASTM commented Jul 17, 2025

Creating a variant (only) for the b_u585i_iot02a disco kit : b_u585i_iot02a/stm32u585xx/xip
Requires the mcuboot to define the corresponding conf file: ../bootloader/mcuboot/boot/zephyr/boards/b_u585i_iot02a_stm32u585xx_xip.conf

*** Booting MCUboot v2.1.0-rc1-390-gfbc9aff5acc1 ***
*** Using Zephyr OS build v4.2.0-rc3-36-ga08697fb1810 ***
*** Booting Zephyr OS build v4.2.0-rc3-38-g84c417194c74 ***
Address of sample 0x70000000
Hello sysbuild with mcuboot! b_u585i_iot02a

@FRASTM
Copy link
Contributor Author

FRASTM commented Jul 21, 2025

rebase on 87917a1

@FRASTM FRASTM force-pushed the stm32u5_xip branch 2 times, most recently from 84e4be6 to 30f5ca9 Compare July 22, 2025 11:38
@FRASTM
Copy link
Contributor Author

FRASTM commented Jul 22, 2025

changing the name of the variant to "ext_flash_app"

@FRASTM
Copy link
Contributor Author

FRASTM commented Jul 22, 2025

rebase

Requires boot/zephyr/boards/b_u585i_iot02a.conf

CONFIG_BOOT_DIRECT_XIP=y
CONFIG_STM32_MEMMAP=y

MCUboot mode should not be set on MCUboot side in my opinion, it should be set on Zephyr side using Sysbuild (SB_CONFIG_MCUBOOT_MODE_DIRECT_XIP) at the board or app level so that the setting is propagated properly to both MCUboot and App builds. Furthermore, this approach is creating some problems already, see #93113

Do you mean that .conf file in the mcuboot do not need to set

CONFIG_BOOT_DIRECT_XIP=y

@JarmouniA
Copy link
Contributor

JarmouniA commented Jul 23, 2025

MCUboot mode should not be set on MCUboot side in my opinion, it should be set on Zephyr side using Sysbuild (SB_CONFIG_MCUBOOT_MODE_DIRECT_XIP) at the board or app level so that the setting is propagated properly to both MCUboot and App builds. Furthermore, this approach is creating some problems already, see #93113

Do you mean that .conf file in the mcuboot do not need to set

CONFIG_BOOT_DIRECT_XIP=y

Yes, it doesn't.

SB_CONFIG_MCUBOOT_MODE_OVERWRITE_ONLY=y

default MCUBOOT_MODE_OVERWRITE_ONLY if SOC_FAMILY_ESPRESSIF_ESP32

default MCUBOOT_MODE_OVERWRITE_ONLY

@FRASTM
Copy link
Contributor Author

FRASTM commented Jul 23, 2025

Rebase on 47b07e5
Add the link to mcuboot : mcu-tools/mcuboot#2399

@FRASTM FRASTM added platform: STM32 ST Micro STM32 DNM This PR should not be merged (Do Not Merge) labels Jul 23, 2025
Copy link

@FRASTM
Copy link
Contributor Author

FRASTM commented Jul 31, 2025

waiting for the #93762 to report all modifications to stm32 ospi flash and then stm32 flash qspi drivers

@FRASTM
Copy link
Contributor Author

FRASTM commented Oct 3, 2025

rebase on 727c15a

@github-actions github-actions bot removed manifest manifest-mcuboot DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Oct 3, 2025
zephyr,console = &usart1;
zephyr,shell-uart = &usart1;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the purpose of zephyr,flash here?

Copy link
Contributor Author

@FRASTM FRASTM Oct 3, 2025

Choose a reason for hiding this comment

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

it indicates where to download the application
With this, mcuboot is downloaded in the (internal) flash (like any other samples/basic application).

Copy link
Contributor

@JarmouniA JarmouniA Oct 6, 2025

Choose a reason for hiding this comment

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

It should be in MCUboot overlay, please see #97037 and mcu-tools/mcuboot#2479

Copy link
Contributor Author

@FRASTM FRASTM Oct 6, 2025

Choose a reason for hiding this comment

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

Removing

chosen {
		zephyr,flash = &flash0;
}

and the samples/hello_world/ cannot build anymore

section `rom_start' will not fit in region `FLASH'
 region `FLASH' overflowed by 17616 bytes

It should, though, without any mcuboot

Copy link
Contributor

@JarmouniA JarmouniA Oct 6, 2025

Choose a reason for hiding this comment

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

The ext_flash_app variant is only meant to be used with MCUboot, and its zephyr,flash should point to external Flash, this way no overlay with be needed at the user app level.

@FRASTM FRASTM force-pushed the stm32u5_xip branch 2 times, most recently from a2e5177 to ee425a8 Compare October 6, 2025 09:07
FRASTM added 2 commits October 6, 2025 11:52
Create a new variant to execute in place on the external octoSPI
flash NOR of the b_u585i_iot02a disco kit
The flash size in the yaml corresponds to the the slot0
of that external NOR memory.

Signed-off-by: Francois Ramu <[email protected]>
Run the sample to execute in place on the external flash of the
b_u585i_iot02a variant 'ext_flash_app' disco kit,
with_boot application is built and linked for the external flash

Signed-off-by: Francois Ramu <[email protected]>
Copy link

sonarqubecloud bot commented Oct 6, 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.

Missing Kconfig.sysbuild at the board level, which shall contain at minimum

choice BOOTLOADER
	default BOOTLOADER_MCUBOOT
endchoice

choice MCUBOOT_MODE
	default MCUBOOT_MODE_DIRECT_XIP
endchoice

reg = <0x70000000 DT_SIZE_M(64)>;
zephyr,memory-region = "EXTMEM";
/* The ATTR_MPU_EXTMEM attribut causing a MPU FAULT */
zephyr,memory-attr = <DT_MEM_ARM(ATTR_MPU_IO)>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
zephyr,memory-attr = <DT_MEM_ARM(ATTR_MPU_IO)>;
zephyr,memory-attr = <DT_MEM_ARM_MPU_FLASH>;

IO is for memory-mapped devices.

board_runner_args(stm32cubeprogrammer "--extload=MX25LM51245G_STM32U585I-IOT02A.stldr")
else()
board_runner_args(stm32cubeprogrammer "--erase" "--port=swd" "--reset-mode=hw")
if(CONFIG_STM32_MEMMAP OR (CONFIG_XIP AND CONFIG_BOOTLOADER_MCUBOOT))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if(CONFIG_STM32_MEMMAP OR (CONFIG_XIP AND CONFIG_BOOTLOADER_MCUBOOT))
if(CONFIG_STM32_MEMMAP OR CONFIG_BOOTLOADER_MCUBOOT)

RAM Load MCUboot mode can be used as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

not needed, should be in ext_flash_app variant DTS.

data-rate = <OSPI_DTR_TRANSFER>;
four-byte-opcodes;
status = "okay";

Copy link
Contributor

Choose a reason for hiding this comment

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

st,stm32-ospi-nor binding shall include soc-nv-flash binding, then ext Flash node should define write-block-size and erase-block-size properties, this way MCUboot MAX_IMG_SECTORS will be calculated automatically. See 1st commit of #97037.

@JarmouniA JarmouniA changed the title stm32 ospi driver : run application in external flash memory XIP STM32 OSPI NOR: run application from external flash memory Oct 6, 2025
- gnuarmemb
ram: 786
flash: 416
vendor: st
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
vendor: st
vendor: st
sysbuild: true

@FRASTM
Copy link
Contributor Author

FRASTM commented Oct 7, 2025

to be refined according to the #97037

@FRASTM FRASTM closed this Oct 7, 2025
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.

5 participants