From 227c456cb9486c6400745b3ce23ea18ac05c8a4d Mon Sep 17 00:00:00 2001 From: Titouan Christophe Date: Sat, 11 Jan 2025 12:49:53 +0100 Subject: [PATCH 01/10] st: stm32h7rs: add xspi peripherals Add entries in the device tree for the xspi1 and xspi2 controllers. Signed-off-by: Titouan Christophe --- boards/st/stm32h7s78_dk/stm32h7s78_dk.dts | 1 + dts/arm/st/h7rs/stm32h7rs.dtsi | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/boards/st/stm32h7s78_dk/stm32h7s78_dk.dts b/boards/st/stm32h7s78_dk/stm32h7s78_dk.dts index 5cfbbb449b85a..fe16d9804e904 100644 --- a/boards/st/stm32h7s78_dk/stm32h7s78_dk.dts +++ b/boards/st/stm32h7s78_dk/stm32h7s78_dk.dts @@ -9,6 +9,7 @@ #include #include "arduino_r3_connector.dtsi" #include +#include / { model = "STMicroelectronics STM32H7S78 DISCOVERY KIT board"; diff --git a/dts/arm/st/h7rs/stm32h7rs.dtsi b/dts/arm/st/h7rs/stm32h7rs.dtsi index e41e465c7ebfa..d74e67c76b0ce 100644 --- a/dts/arm/st/h7rs/stm32h7rs.dtsi +++ b/dts/arm/st/h7rs/stm32h7rs.dtsi @@ -428,6 +428,28 @@ status = "disabled"; }; + xspi1: xspi@52005000 { + compatible = "st,stm32-xspi"; + reg = <0x52005000 0x1000>; + interrupts = <105 0>; + clock-names = "bus"; + clocks = <&rcc STM32_CLOCK(AHB5, 14U)>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + xspi2: xspi@5200a000 { + compatible = "st,stm32-xspi"; + reg = <0x5200a000 0x1000>; + interrupts = <106 0>; + clock-names = "bus"; + clocks = <&rcc STM32_CLOCK(AHB5, 12U)>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + spi1: spi@42003000 { compatible = "st,stm32h7-spi", "st,stm32-spi-fifo", "st,stm32-spi"; #address-cells = <1>; From 1bc78e26fd836630c56068acc33ce66eae67eaff Mon Sep 17 00:00:00 2001 From: Titouan Christophe Date: Sat, 11 Jan 2025 12:52:39 +0100 Subject: [PATCH 02/10] board: st: stm32h7s78-dk: add support for on-board flash on xspi2 Add device tree entry for the 1Gbit octo-spi flash on the board, wired to the xspi2 peripheral. Signed-off-by: Titouan Christophe --- boards/st/stm32h7s78_dk/stm32h7s78_dk.dts | 32 +++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/boards/st/stm32h7s78_dk/stm32h7s78_dk.dts b/boards/st/stm32h7s78_dk/stm32h7s78_dk.dts index fe16d9804e904..b6b19af0a6e27 100644 --- a/boards/st/stm32h7s78_dk/stm32h7s78_dk.dts +++ b/boards/st/stm32h7s78_dk/stm32h7s78_dk.dts @@ -186,6 +186,38 @@ status = "okay"; }; +&xspi2 { + pinctrl-0 = <&xspim_p2_clk_pn6 &xspim_p2_ncs1_pn1 + &xspim_p2_io0_pn2 &xspim_p2_io1_pn3 + &xspim_p2_io2_pn4 &xspim_p2_io3_pn5 + &xspim_p2_io4_pn8 &xspim_p2_io5_pn9 + &xspim_p2_io6_pn10 &xspim_p2_io7_pn11 + &xspim_p2_dqs0_pn0>; + pinctrl-names = "default"; + status = "okay"; + + mx66uw1g45g: xspi-nor-flash@70000000 { + compatible = "st,stm32-xspi-nor"; + reg = <0x70000000 DT_SIZE_M(128)>; /* 1 Gbits */ + ospi-max-frequency = ; + spi-bus-width = ; + data-rate = ; + four-byte-opcodes; + status = "okay"; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "nor"; + reg = <0x00000000 DT_SIZE_M(16)>; + }; + }; + }; +}; + usb2: &usbotg_fs { pinctrl-0 = <&usb_otg_fs_dm_pm12 &usb_otg_fs_dp_pm11>; pinctrl-names = "default"; From 648f56bae2486e5756b4748f448492a085136a2f Mon Sep 17 00:00:00 2001 From: Titouan Christophe Date: Tue, 11 Mar 2025 22:48:19 +0100 Subject: [PATCH 03/10] Add flash partitions Signed-off-by: Titouan Christophe --- boards/st/stm32h7s78_dk/stm32h7s78_dk.dts | 34 +++++++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/boards/st/stm32h7s78_dk/stm32h7s78_dk.dts b/boards/st/stm32h7s78_dk/stm32h7s78_dk.dts index b6b19af0a6e27..92134fff159ab 100644 --- a/boards/st/stm32h7s78_dk/stm32h7s78_dk.dts +++ b/boards/st/stm32h7s78_dk/stm32h7s78_dk.dts @@ -210,10 +210,38 @@ #address-cells = <1>; #size-cells = <1>; - partition@0 { - label = "nor"; - reg = <0x00000000 DT_SIZE_M(16)>; + slot0_partition: partition@0 { + label = "image-0"; + reg = <0x00040000 DT_SIZE_M(16)>; }; + + slot1_partition: partition@1000000 { + label = "image-1"; + reg = <0x00080000 DT_SIZE_M(16)>; + }; + + scratch_partition: partition@2000000 { + label = "image-scratch"; + reg = <0x000c0000 DT_SIZE_M(16)>; + }; + + storage_partition: partition@3000000 { + label = "storage"; + reg = <0x00020000 DT_SIZE_M(80)>; + }; + }; + }; +}; + +&flash0 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + boot_partition: partition@0 { + label = "mcuboot"; + reg = <0 DT_SIZE_K(64)>; }; }; }; From ddb41b4a3bafcca20e51a8c4d5a741d4a396f8ec Mon Sep 17 00:00:00 2001 From: Titouan Christophe Date: Tue, 11 Mar 2025 22:48:40 +0100 Subject: [PATCH 04/10] Rename xspi->spi to remove warnings Signed-off-by: Titouan Christophe --- dts/arm/st/h7rs/stm32h7rs.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dts/arm/st/h7rs/stm32h7rs.dtsi b/dts/arm/st/h7rs/stm32h7rs.dtsi index d74e67c76b0ce..8a6196f458718 100644 --- a/dts/arm/st/h7rs/stm32h7rs.dtsi +++ b/dts/arm/st/h7rs/stm32h7rs.dtsi @@ -428,7 +428,7 @@ status = "disabled"; }; - xspi1: xspi@52005000 { + xspi1: spi@52005000 { compatible = "st,stm32-xspi"; reg = <0x52005000 0x1000>; interrupts = <105 0>; @@ -439,7 +439,7 @@ status = "disabled"; }; - xspi2: xspi@5200a000 { + xspi2: spi@5200a000 { compatible = "st,stm32-xspi"; reg = <0x5200a000 0x1000>; interrupts = <106 0>; From 8ab91297b9b274868aaf016d848d2b9a604654d8 Mon Sep 17 00:00:00 2001 From: Titouan Christophe Date: Wed, 12 Mar 2025 00:08:24 +0100 Subject: [PATCH 05/10] Fix partitions addresses Signed-off-by: Titouan Christophe --- boards/st/stm32h7s78_dk/stm32h7s78_dk.dts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/boards/st/stm32h7s78_dk/stm32h7s78_dk.dts b/boards/st/stm32h7s78_dk/stm32h7s78_dk.dts index 92134fff159ab..84f5e9f917354 100644 --- a/boards/st/stm32h7s78_dk/stm32h7s78_dk.dts +++ b/boards/st/stm32h7s78_dk/stm32h7s78_dk.dts @@ -212,22 +212,22 @@ slot0_partition: partition@0 { label = "image-0"; - reg = <0x00040000 DT_SIZE_M(16)>; + reg = <0x00000000 DT_SIZE_M(16)>; }; slot1_partition: partition@1000000 { label = "image-1"; - reg = <0x00080000 DT_SIZE_M(16)>; + reg = <0x01000000 DT_SIZE_M(16)>; }; scratch_partition: partition@2000000 { label = "image-scratch"; - reg = <0x000c0000 DT_SIZE_M(16)>; + reg = <0x02000000 DT_SIZE_M(16)>; }; storage_partition: partition@3000000 { label = "storage"; - reg = <0x00020000 DT_SIZE_M(80)>; + reg = <0x03000000 DT_SIZE_M(80)>; }; }; }; From 3af6faf208c354ada1b462bd92eb8a2260c8a9e9 Mon Sep 17 00:00:00 2001 From: Titouan Christophe Date: Thu, 13 Mar 2025 18:58:25 +0100 Subject: [PATCH 06/10] Better partitioning Signed-off-by: Titouan Christophe --- boards/st/stm32h7s78_dk/stm32h7s78_dk.dts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/boards/st/stm32h7s78_dk/stm32h7s78_dk.dts b/boards/st/stm32h7s78_dk/stm32h7s78_dk.dts index 84f5e9f917354..1de77d827802c 100644 --- a/boards/st/stm32h7s78_dk/stm32h7s78_dk.dts +++ b/boards/st/stm32h7s78_dk/stm32h7s78_dk.dts @@ -19,7 +19,9 @@ zephyr,console = &uart4; zephyr,shell-uart = &uart4; zephyr,flash = &flash0; + zephyr,flash-controller = &mx66uw1g45g; zephyr,sram = &sram0; + zephyr,code-partition = &slot0_partition; }; leds { @@ -199,7 +201,7 @@ mx66uw1g45g: xspi-nor-flash@70000000 { compatible = "st,stm32-xspi-nor"; reg = <0x70000000 DT_SIZE_M(128)>; /* 1 Gbits */ - ospi-max-frequency = ; + ospi-max-frequency = ; spi-bus-width = ; data-rate = ; four-byte-opcodes; @@ -212,22 +214,22 @@ slot0_partition: partition@0 { label = "image-0"; - reg = <0x00000000 DT_SIZE_M(16)>; + reg = <0x00000000 DT_SIZE_M(1)>; }; - slot1_partition: partition@1000000 { + slot1_partition: partition@100000 { label = "image-1"; - reg = <0x01000000 DT_SIZE_M(16)>; + reg = <0x00100000 DT_SIZE_M(1)>; }; - scratch_partition: partition@2000000 { + scratch_partition: partition@200000 { label = "image-scratch"; - reg = <0x02000000 DT_SIZE_M(16)>; + reg = <0x00200000 DT_SIZE_M(1)>; }; - storage_partition: partition@3000000 { + storage_partition: partition@300000 { label = "storage"; - reg = <0x03000000 DT_SIZE_M(80)>; + reg = <0x00300000 DT_SIZE_M(125)>; }; }; }; From edba44c08c7928c2fe8e569933e8c83eac68d4d8 Mon Sep 17 00:00:00 2001 From: Titouan Christophe Date: Thu, 13 Mar 2025 18:58:56 +0100 Subject: [PATCH 07/10] Fix clock bit number for xspi1 Signed-off-by: Titouan Christophe --- dts/arm/st/h7rs/stm32h7rs.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dts/arm/st/h7rs/stm32h7rs.dtsi b/dts/arm/st/h7rs/stm32h7rs.dtsi index 8a6196f458718..d9b42c918c8b9 100644 --- a/dts/arm/st/h7rs/stm32h7rs.dtsi +++ b/dts/arm/st/h7rs/stm32h7rs.dtsi @@ -433,7 +433,7 @@ reg = <0x52005000 0x1000>; interrupts = <105 0>; clock-names = "bus"; - clocks = <&rcc STM32_CLOCK(AHB5, 14U)>; + clocks = <&rcc STM32_CLOCK(AHB5, 5U)>; #address-cells = <1>; #size-cells = <0>; status = "disabled"; From 3e583abbc83b1a9a28631765df7f41a224c47ccb Mon Sep 17 00:00:00 2001 From: Titouan Christophe Date: Fri, 14 Mar 2025 11:05:56 +0100 Subject: [PATCH 08/10] Add loader for external flash in stm cube programmer Signed-off-by: Titouan Christophe --- boards/st/stm32h7s78_dk/board.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/boards/st/stm32h7s78_dk/board.cmake b/boards/st/stm32h7s78_dk/board.cmake index 79bb6fcc70bef..2039c4fe5d83d 100644 --- a/boards/st/stm32h7s78_dk/board.cmake +++ b/boards/st/stm32h7s78_dk/board.cmake @@ -2,6 +2,8 @@ # keep first board_runner_args(stm32cubeprogrammer "--port=swd" "--reset-mode=hw") +board_runner_args(stm32cubeprogrammer "--extload=MX66UW1G45G_STM32H7S78-DK.stldr") + board_runner_args(openocd --target-handle=_CHIPNAME.cpu0) # keep first From 612ea67ef697f49c97b120c1114462a6a7640815 Mon Sep 17 00:00:00 2001 From: Titouan Christophe Date: Tue, 18 Mar 2025 08:17:02 +0100 Subject: [PATCH 09/10] Fix memory attr for EXTMEM (otherwise code relocated in EXTMEM fails with an MPU fault) Signed-off-by: Titouan Christophe --- boards/st/stm32h7s78_dk/stm32h7s78_dk.dts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/boards/st/stm32h7s78_dk/stm32h7s78_dk.dts b/boards/st/stm32h7s78_dk/stm32h7s78_dk.dts index 1de77d827802c..074c37056426e 100644 --- a/boards/st/stm32h7s78_dk/stm32h7s78_dk.dts +++ b/boards/st/stm32h7s78_dk/stm32h7s78_dk.dts @@ -10,6 +10,7 @@ #include "arduino_r3_connector.dtsi" #include #include +#include / { model = "STMicroelectronics STM32H7S78 DISCOVERY KIT board"; @@ -63,6 +64,11 @@ }; }; +&ext_memory { + /* ATTR_MPU_EXTMEM is causing MPU FAULT */ + zephyr,memory-attr = ; +}; + &clk_hsi48 { status = "okay"; }; From 7538026d36f44131923b665461d5769fcc45f2cd Mon Sep 17 00:00:00 2001 From: Titouan Christophe Date: Wed, 2 Apr 2025 16:05:27 +0200 Subject: [PATCH 10/10] Fix DLYB not defined in hal for stm32h7rs Signed-off-by: Titouan Christophe --- drivers/flash/flash_stm32_xspi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/flash/flash_stm32_xspi.c b/drivers/flash/flash_stm32_xspi.c index 0cb785c7df5a8..b28d353b3b5e3 100644 --- a/drivers/flash/flash_stm32_xspi.c +++ b/drivers/flash/flash_stm32_xspi.c @@ -2163,6 +2163,7 @@ static int flash_stm32_xspi_init(const struct device *dev) #endif /* XSPIM */ +#if defined(XSPI_DCR1_DLYBYP) #if defined(DLYB_XSPI1) || defined(DLYB_XSPI2) || defined(DLYB_OCTOSPI1) || defined(DLYB_OCTOSPI2) /* XSPI delay block init Function */ HAL_XSPI_DLYB_CfgTypeDef xspi_delay_block_cfg = {0}; @@ -2178,6 +2179,7 @@ static int flash_stm32_xspi_init(const struct device *dev) LOG_DBG("Delay Block Init"); #endif /* DLYB_ */ +#endif /* XSPI_DCR1_DLYBYP */ #if STM32_XSPI_USE_DMA /* Configure and enable the DMA channels after XSPI config */