From 863c64ba41d1d774285b2ad046932cb9e2d97998 Mon Sep 17 00:00:00 2001 From: Francois Ramu Date: Fri, 11 Jul 2025 15:47:28 +0200 Subject: [PATCH 1/3] soc: st: stm32 devices define flash base address of OSPI instance Define with CONFIG_FLASH_BASE_ADDRESS when the external flash is on an octoSPI node : "st,stm32-ospi" compatible Signed-off-by: Francois Ramu --- soc/st/stm32/Kconfig.defconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/soc/st/stm32/Kconfig.defconfig b/soc/st/stm32/Kconfig.defconfig index aafb321151a46..e18bc5d5bbadb 100644 --- a/soc/st/stm32/Kconfig.defconfig +++ b/soc/st/stm32/Kconfig.defconfig @@ -28,10 +28,12 @@ DT_STM32_LPTIM_PATH := $(dt_nodelabel_path,stm32_lp_tick_source) DT_CHOSEN_Z_FLASH := zephyr,flash DT_COMPAT_XSPI := st,stm32-xspi +DT_COMPAT_OSPI := st,stm32-ospi DT_CHOSEN_FLASH_NODE := $(dt_chosen_path,$(DT_CHOSEN_Z_FLASH)) DT_CHOSEN_FLASH_PARENT := $(dt_node_parent,$(DT_CHOSEN_FLASH_NODE)) DT_FLASH_PARENT_IS_XSPI := $(dt_node_has_compat,$(DT_CHOSEN_FLASH_PARENT),$(DT_COMPAT_XSPI)) +DT_FLASH_PARENT_IS_OSPI := $(dt_node_has_compat,$(DT_CHOSEN_FLASH_PARENT),$(DT_COMPAT_OSPI)) config SYS_CLOCK_HW_CYCLES_PER_SEC default "$(DT_STM32_RCC_CLOCK_FREQ)" if "$(dt_nodelabel_enabled,rcc)" @@ -82,7 +84,7 @@ config BUILD_WITH_TFM config FLASH_BASE_ADDRESS default $(dt_node_reg_addr_hex,$(DT_CHOSEN_FLASH_PARENT),1) \ - if $(DT_FLASH_PARENT_IS_XSPI) + if $(DT_FLASH_PARENT_IS_XSPI) || $(DT_FLASH_PARENT_IS_OSPI) default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_FLASH)) # The XSPI PSRAM driver creates a SMH region with attribute SMH_REG_ATTR_EXTERNAL (2) From c34d8bac80c65042d91adcc077f5994b63a3f8a2 Mon Sep 17 00:00:00 2001 From: Francois Ramu Date: Wed, 7 May 2025 15:06:05 +0200 Subject: [PATCH 2/3] boards: arm: stm32u585 disco kit move partition to ext flash Add the XSPI 2 which is an octoSPI connection to a octo NOR flash mx25lm51245 on the stm32u585 disco kit Define the partition on the 64MBytes space of the external flash Use the STM32Cube programmer to flash with the corresponding external loader for XiP mode. Removing usb_device will avoid test feature for that board. Signed-off-by: Francois Ramu --- .../st/b_u585i_iot02a/b_u585i_iot02a-common.dtsi | 15 +++++++++++++-- boards/st/b_u585i_iot02a/b_u585i_iot02a.dts | 15 --------------- boards/st/b_u585i_iot02a/b_u585i_iot02a.yaml | 1 - boards/st/b_u585i_iot02a/board.cmake | 6 ++---- 4 files changed, 15 insertions(+), 22 deletions(-) diff --git a/boards/st/b_u585i_iot02a/b_u585i_iot02a-common.dtsi b/boards/st/b_u585i_iot02a/b_u585i_iot02a-common.dtsi index d6f4ebfe7e7db..9c0dc5e26616b 100644 --- a/boards/st/b_u585i_iot02a/b_u585i_iot02a-common.dtsi +++ b/boards/st/b_u585i_iot02a/b_u585i_iot02a-common.dtsi @@ -152,8 +152,19 @@ stm32_lp_tick_source: &lptim1 { #address-cells = <1>; #size-cells = <1>; - partition@0 { - reg = <0x00000000 DT_SIZE_M(64)>; + slot0_partition: partition@0 { + label = "image-0"; + reg = <0x00000000 DT_SIZE_K(256)>; + }; + + slot1_partition: partition@40000 { + label = "image-1"; + reg = <0x00040000 DT_SIZE_K(256)>; + }; + + scratch_partition: partition@e0000 { + label = "image-scratch"; + reg = <0x000e0000 DT_SIZE_K(64)>; }; }; }; diff --git a/boards/st/b_u585i_iot02a/b_u585i_iot02a.dts b/boards/st/b_u585i_iot02a/b_u585i_iot02a.dts index fc824417d2050..6347cfad85f8f 100644 --- a/boards/st/b_u585i_iot02a/b_u585i_iot02a.dts +++ b/boards/st/b_u585i_iot02a/b_u585i_iot02a.dts @@ -54,21 +54,6 @@ reg = <0x00000000 DT_SIZE_K(64)>; }; - slot0_partition: partition@10000 { - label = "image-0"; - reg = <0x00010000 DT_SIZE_K(416)>; - }; - - slot1_partition: partition@78000 { - label = "image-1"; - reg = <0x00078000 DT_SIZE_K(416)>; - }; - - scratch_partition: partition@e0000 { - label = "image-scratch"; - reg = <0x000e0000 DT_SIZE_K(64)>; - }; - storage_partition: partition@f0000 { label = "storage"; reg = <0x000f0000 DT_SIZE_K(64)>; diff --git a/boards/st/b_u585i_iot02a/b_u585i_iot02a.yaml b/boards/st/b_u585i_iot02a/b_u585i_iot02a.yaml index 621e455720497..93ff03bda277f 100644 --- a/boards/st/b_u585i_iot02a/b_u585i_iot02a.yaml +++ b/boards/st/b_u585i_iot02a/b_u585i_iot02a.yaml @@ -12,7 +12,6 @@ supported: - arduino_spi - hts221 - dma - - usb_device - spi - dac - adc diff --git a/boards/st/b_u585i_iot02a/board.cmake b/boards/st/b_u585i_iot02a/board.cmake index bb801eaae547d..5764f61791382 100644 --- a/boards/st/b_u585i_iot02a/board.cmake +++ b/boards/st/b_u585i_iot02a/board.cmake @@ -13,11 +13,9 @@ if(CONFIG_BUILD_WITH_TFM) endif() # keep first -if(CONFIG_STM32_MEMMAP) board_runner_args(stm32cubeprogrammer "--port=swd" "--reset-mode=hw") -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)) + board_runner_args(stm32cubeprogrammer "--extload=MX25LM51245G_STM32U585I-IOT02A.stldr") endif() board_runner_args(openocd "--tcl-port=6666") From 8c58be376223db61b06fe321159973d465939198 Mon Sep 17 00:00:00 2001 From: Francois Ramu Date: Wed, 7 May 2025 15:31:40 +0200 Subject: [PATCH 3/3] samples: sysbuild: with mcu_boot on the stm32u585 target Run the sample to execute in place on the external flash of the b_u585i_iot02a disco kit. with_boot application is built and linked for the external flash Signed-off-by: Francois Ramu --- .../with_mcuboot/boards/b_u585i_iot02a.overlay | 17 +++++++++++++++++ samples/sysbuild/with_mcuboot/sample.yaml | 1 + 2 files changed, 18 insertions(+) create mode 100644 samples/sysbuild/with_mcuboot/boards/b_u585i_iot02a.overlay diff --git a/samples/sysbuild/with_mcuboot/boards/b_u585i_iot02a.overlay b/samples/sysbuild/with_mcuboot/boards/b_u585i_iot02a.overlay new file mode 100644 index 0000000000000..f109c447c637e --- /dev/null +++ b/samples/sysbuild/with_mcuboot/boards/b_u585i_iot02a.overlay @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2025 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * Define the device, controller and partition to be the external memory + * for running the application in external NOR from MCUboot + */ + +/ { + chosen { + zephyr,flash = &mx25lm51245; + zephyr,flash-controller = &mx25lm51245; + }; +}; diff --git a/samples/sysbuild/with_mcuboot/sample.yaml b/samples/sysbuild/with_mcuboot/sample.yaml index a2e53a4fbecb0..ec72ef4e2f8bd 100644 --- a/samples/sysbuild/with_mcuboot/sample.yaml +++ b/samples/sysbuild/with_mcuboot/sample.yaml @@ -17,6 +17,7 @@ tests: - nucleo_h7s3l8 - nucleo_u385rg_q - stm32h7s78_dk + - b_u585i_iot02a integration_platforms: - nrf52840dk/nrf52840 - esp32_devkitc/esp32/procpu