From f80eefaf77dbf04d4ae0b4100efec1a09b05ad53 Mon Sep 17 00:00:00 2001 From: Francois Ramu Date: Thu, 17 Jul 2025 12:31:32 +0200 Subject: [PATCH 1/3] boards: st: b_u585i disco kit variant "ext_flash_app" for XIP Create a new variant to execute in place on the external octoSPI flash NOR of the b_u585i_iot02a disco kit Signed-off-by: Francois Ramu --- .../b_u585i_iot02a/b_u585i_iot02a-common.dtsi | 10 +- boards/st/b_u585i_iot02a/b_u585i_iot02a.dts | 12 ++ ...u585i_iot02a_stm32u585xx_ext_flash_app.dts | 110 ++++++++++++++++++ ...585i_iot02a_stm32u585xx_ext_flash_app.yaml | 10 ++ ...iot02a_stm32u585xx_ext_flash_app_defconfig | 11 ++ boards/st/b_u585i_iot02a/board.cmake | 6 +- boards/st/b_u585i_iot02a/board.yml | 1 + 7 files changed, 147 insertions(+), 13 deletions(-) create mode 100644 boards/st/b_u585i_iot02a/b_u585i_iot02a_stm32u585xx_ext_flash_app.dts create mode 100644 boards/st/b_u585i_iot02a/b_u585i_iot02a_stm32u585xx_ext_flash_app.yaml create mode 100644 boards/st/b_u585i_iot02a/b_u585i_iot02a_stm32u585xx_ext_flash_app_defconfig 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..6de49cca7ef30 100644 --- a/boards/st/b_u585i_iot02a/b_u585i_iot02a-common.dtsi +++ b/boards/st/b_u585i_iot02a/b_u585i_iot02a-common.dtsi @@ -147,15 +147,7 @@ stm32_lp_tick_source: &lptim1 { four-byte-opcodes; status = "okay"; - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - partition@0 { - reg = <0x00000000 DT_SIZE_M(64)>; - }; - }; + /* Partition of the external NOR is defined in each variant. */ }; }; diff --git a/boards/st/b_u585i_iot02a/b_u585i_iot02a.dts b/boards/st/b_u585i_iot02a/b_u585i_iot02a.dts index fc824417d2050..b032764f96e59 100644 --- a/boards/st/b_u585i_iot02a/b_u585i_iot02a.dts +++ b/boards/st/b_u585i_iot02a/b_u585i_iot02a.dts @@ -100,3 +100,15 @@ st,adc-prescaler = <4>; status = "okay"; }; + +&mx25lm51245 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + reg = <0x00000000 DT_SIZE_M(64)>; + }; + }; +}; diff --git a/boards/st/b_u585i_iot02a/b_u585i_iot02a_stm32u585xx_ext_flash_app.dts b/boards/st/b_u585i_iot02a/b_u585i_iot02a_stm32u585xx_ext_flash_app.dts new file mode 100644 index 0000000000000..3f10fcb65355a --- /dev/null +++ b/boards/st/b_u585i_iot02a/b_u585i_iot02a_stm32u585xx_ext_flash_app.dts @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2025 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include "b_u585i_iot02a-common.dtsi" +#include +#include + +/ { + model = "STMicroelectronics B-U585I-IOT02A discovery kit"; + compatible = "st,b-u585i-iot02a"; + + chosen { + zephyr,console = &usart1; + zephyr,shell-uart = &usart1; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zephyr,code-partition = &slot0_partition; + zephyr,bt-hci = &bt_hci_uart; + }; + + aliases { + led0 = &green_led_1; + led1 = &red_led_1; + sw0 = &user_button; + die-temp0 = &die_temp; + }; + + octo_nor: memory@70000000 { + compatible = "zephyr,memory-region"; + 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) )>; + }; +}; + +&flash0 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + /* + * Following flash partition is dedicated to the use of b_u585i_iot02a + * with TZEN=0 (so w/o TFM). + * Set the partitions with first MB to make use of the whole Bank1 + */ + boot_partition: partition@0 { + label = "mcuboot"; + reg = <0x00000000 DT_SIZE_K(64)>; + }; + + storage_partition: partition@f0000 { + label = "storage"; + reg = <0x000f0000 DT_SIZE_K(64)>; + }; + }; +}; + +&gpdma1 { + status = "okay"; +}; + +&uart4 { + pinctrl-0 = <&uart4_tx_pc10 &uart4_rx_pc11>; + pinctrl-names = "default"; + current-speed = <100000>; + status = "okay"; + + bt_hci_uart: bt_hci_uart { + compatible = "zephyr,bt-hci-uart"; + status = "okay"; + }; +}; + +&die_temp { + status = "okay"; +}; + +&adc1 { + st,adc-prescaler = <4>; + status = "okay"; +}; + +&mx25lm51245 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + slot0_partition: partition@0 { + label = "image-0"; + reg = <0x00000000 DT_SIZE_K(416)>; + }; + + slot1_partition: partition@68000 { + label = "image-1"; + reg = <0x00068000 DT_SIZE_K(416)>; + }; + + scratch_partition: partition@d0000 { + label = "image-scratch"; + reg = <0x000d0000 DT_SIZE_K(192)>; + }; + }; +}; diff --git a/boards/st/b_u585i_iot02a/b_u585i_iot02a_stm32u585xx_ext_flash_app.yaml b/boards/st/b_u585i_iot02a/b_u585i_iot02a_stm32u585xx_ext_flash_app.yaml new file mode 100644 index 0000000000000..2569a38d5a219 --- /dev/null +++ b/boards/st/b_u585i_iot02a/b_u585i_iot02a_stm32u585xx_ext_flash_app.yaml @@ -0,0 +1,10 @@ +identifier: b_u585i_iot02a/stm32u585xx/xip +name: ST B_U585I_IOT02A Discovery kit xip target +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb +ram: 786 +flash: 512 +vendor: st diff --git a/boards/st/b_u585i_iot02a/b_u585i_iot02a_stm32u585xx_ext_flash_app_defconfig b/boards/st/b_u585i_iot02a/b_u585i_iot02a_stm32u585xx_ext_flash_app_defconfig new file mode 100644 index 0000000000000..0f4ce3ee7b48b --- /dev/null +++ b/boards/st/b_u585i_iot02a/b_u585i_iot02a_stm32u585xx_ext_flash_app_defconfig @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: Apache-2.0 + +# enable uart driver +CONFIG_SERIAL=y + +# enable GPIO +CONFIG_GPIO=y + +# console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y 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") diff --git a/boards/st/b_u585i_iot02a/board.yml b/boards/st/b_u585i_iot02a/board.yml index c5ae28435f0aa..e003cf57ee897 100644 --- a/boards/st/b_u585i_iot02a/board.yml +++ b/boards/st/b_u585i_iot02a/board.yml @@ -6,3 +6,4 @@ board: - name: stm32u585xx variants: - name: ns + - name: ext_flash_app From 643b6edc5405b88ed6497cc1bebc7ebeaa89bd25 Mon Sep 17 00:00:00 2001 From: Francois Ramu Date: Tue, 15 Jul 2025 11:48:18 +0200 Subject: [PATCH 2/3] samples: sysbuild: with mcu_boot on the stm32u5 with octoSPI 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 --- ..._u585i_iot02a_stm32u585xx_ext_flash_app.conf | 1 + ...85i_iot02a_stm32u585xx_ext_flash_app.overlay | 17 +++++++++++++++++ samples/sysbuild/with_mcuboot/sample.yaml | 1 + 3 files changed, 19 insertions(+) create mode 100644 samples/sysbuild/with_mcuboot/boards/b_u585i_iot02a_stm32u585xx_ext_flash_app.conf create mode 100644 samples/sysbuild/with_mcuboot/boards/b_u585i_iot02a_stm32u585xx_ext_flash_app.overlay diff --git a/samples/sysbuild/with_mcuboot/boards/b_u585i_iot02a_stm32u585xx_ext_flash_app.conf b/samples/sysbuild/with_mcuboot/boards/b_u585i_iot02a_stm32u585xx_ext_flash_app.conf new file mode 100644 index 0000000000000..8303508138954 --- /dev/null +++ b/samples/sysbuild/with_mcuboot/boards/b_u585i_iot02a_stm32u585xx_ext_flash_app.conf @@ -0,0 +1 @@ +CONFIG_FLASH=y diff --git a/samples/sysbuild/with_mcuboot/boards/b_u585i_iot02a_stm32u585xx_ext_flash_app.overlay b/samples/sysbuild/with_mcuboot/boards/b_u585i_iot02a_stm32u585xx_ext_flash_app.overlay new file mode 100644 index 0000000000000..f109c447c637e --- /dev/null +++ b/samples/sysbuild/with_mcuboot/boards/b_u585i_iot02a_stm32u585xx_ext_flash_app.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 bdd79980ed298..3d7790e969378 100644 --- a/samples/sysbuild/with_mcuboot/sample.yaml +++ b/samples/sysbuild/with_mcuboot/sample.yaml @@ -16,6 +16,7 @@ tests: - esp32c6_devkitc/esp32c6/hpcore - nucleo_h7s3l8 - nucleo_u385rg_q + - b_u585i_iot02a/stm32u585xx/ext_flash_app - stm32h7s78_dk - stm32h573i_dk integration_platforms: From eda3d25394f8a8736df225822e0654a190516be3 Mon Sep 17 00:00:00 2001 From: Francois Ramu Date: Wed, 23 Jul 2025 17:35:35 +0200 Subject: [PATCH 3/3] west.yml: MCUBoot updated to support stm32 variants Takes the https://github.com/mcu-tools/mcuboot/pull/2399 Signed-off-by: Francois Ramu --- west.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/west.yml b/west.yml index 0a0ec073f52b9..dd01c54769342 100644 --- a/west.yml +++ b/west.yml @@ -310,7 +310,7 @@ manifest: groups: - crypto - name: mcuboot - revision: 461e060e8687c9a75074effcc61d7f68c5112cfd + revision: pull/2399/head path: bootloader/mcuboot groups: - bootloader