From bf8295421cba70837f751d8fa8ec675aba2c180f Mon Sep 17 00:00:00 2001 From: Francois Ramu Date: Fri, 1 Sep 2023 10:20:40 +0200 Subject: [PATCH 1/4] boot: zephyr: defines FLASH device for external NOR With CONFIG_STM32_MEMMAP flag get NOR flash 32 bytes header Read the NOR flash to get header of the image. The FLASH_DEVICE is now the external NOR defined by the board device tree to be the first qspi/ospi/xspi instance (not necessarily zephyr, flash-controller) Signed-off-by: Francois Ramu --- boot/zephyr/flash_map_extended.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/boot/zephyr/flash_map_extended.c b/boot/zephyr/flash_map_extended.c index 4631da75b8..e7b781f1ed 100644 --- a/boot/zephyr/flash_map_extended.c +++ b/boot/zephyr/flash_map_extended.c @@ -18,7 +18,23 @@ BOOT_LOG_MODULE_DECLARE(mcuboot); -#if (!defined(CONFIG_XTENSA) && DT_HAS_CHOSEN(zephyr_flash_controller)) +#if defined(CONFIG_STM32_MEMMAP) +/* MEMORY MAPPED for XiP on external NOR flash takes the sspi-nor or ospi-nor or qspi-nor device */ +#define FLASH_DEVICE_ID SPI_FLASH_0_ID +#if DT_NODE_HAS_STATUS(DT_INST(0, st_stm32_xspi_nor), okay) +#define FLASH_DEVICE_NODE DT_INST(0, st_stm32_xspi_nor) +#define FLASH_DEVICE_BASE DT_REG_ADDR(DT_INST(0, st_stm32_xspi_nor)) +#elif DT_NODE_HAS_STATUS(DT_INST(0, st_stm32_ospi_nor), okay) +#define FLASH_DEVICE_NODE DT_INST(0, st_stm32_ospi_nor) +#define FLASH_DEVICE_BASE DT_REG_ADDR(DT_INST(0, st_stm32_ospi_nor)) +#elif DT_NODE_HAS_STATUS(DT_INST(0, st_stm32_qspi_nor), okay) +#define FLASH_DEVICE_NODE DT_INST(0, st_stm32_qspi_nor) +#define FLASH_DEVICE_BASE DT_REG_ADDR(DT_INST(0, st_stm32_qspi_nor)) +#else +#error "FLASH_DEVICE_NODE could not be determined" +#endif + +#elif (!defined(CONFIG_XTENSA) && DT_HAS_CHOSEN(zephyr_flash_controller)) #define FLASH_DEVICE_ID SOC_FLASH_0_ID #define FLASH_DEVICE_BASE CONFIG_FLASH_BASE_ADDRESS #define FLASH_DEVICE_NODE DT_CHOSEN(zephyr_flash_controller) From 69c81523f1235b651bd27216779e12568efbee7d Mon Sep 17 00:00:00 2001 From: Francois Ramu Date: Thu, 19 Oct 2023 09:34:43 +0200 Subject: [PATCH 2/4] boot: zephyr: boards config of the stm32 disco kit Define the stm32 disco board configuration to set the STM32 XIP mode that will enable the MemoryMapped mode. See Kconfig of the stm32 soc. Choose the mcu_boot partition where to build ../bootloader/mcuboot/boot/zephyr Signed-off-by: Francois Ramu --- boot/zephyr/boards/b_u585i_iot02a.conf | 2 ++ boot/zephyr/boards/b_u585i_iot02a.overlay | 11 +++++++++++ boot/zephyr/boards/stm32f746g_disco.conf | 2 ++ boot/zephyr/boards/stm32f746g_disco.overlay | 11 +++++++++++ boot/zephyr/boards/stm32h735g_disco.conf | 2 ++ boot/zephyr/boards/stm32h735g_disco.overlay | 11 +++++++++++ boot/zephyr/boards/stm32h747i_disco_m7.conf | 2 ++ boot/zephyr/boards/stm32h747i_disco_m7.overlay | 11 +++++++++++ boot/zephyr/boards/stm32h750b_dk.conf | 2 ++ boot/zephyr/boards/stm32h750b_dk.overlay | 11 +++++++++++ boot/zephyr/boards/stm32h7b3i_dk.conf | 2 ++ boot/zephyr/boards/stm32h7b3i_dk.overlay | 11 +++++++++++ boot/zephyr/boards/stm32l496g_disco.conf | 2 ++ boot/zephyr/boards/stm32l496g_disco.overlay | 11 +++++++++++ 14 files changed, 91 insertions(+) create mode 100644 boot/zephyr/boards/b_u585i_iot02a.conf create mode 100644 boot/zephyr/boards/b_u585i_iot02a.overlay create mode 100644 boot/zephyr/boards/stm32f746g_disco.conf create mode 100644 boot/zephyr/boards/stm32f746g_disco.overlay create mode 100644 boot/zephyr/boards/stm32h735g_disco.conf create mode 100644 boot/zephyr/boards/stm32h735g_disco.overlay create mode 100644 boot/zephyr/boards/stm32h747i_disco_m7.conf create mode 100644 boot/zephyr/boards/stm32h747i_disco_m7.overlay create mode 100644 boot/zephyr/boards/stm32h750b_dk.conf create mode 100644 boot/zephyr/boards/stm32h750b_dk.overlay create mode 100644 boot/zephyr/boards/stm32h7b3i_dk.conf create mode 100644 boot/zephyr/boards/stm32h7b3i_dk.overlay create mode 100644 boot/zephyr/boards/stm32l496g_disco.conf create mode 100644 boot/zephyr/boards/stm32l496g_disco.overlay diff --git a/boot/zephyr/boards/b_u585i_iot02a.conf b/boot/zephyr/boards/b_u585i_iot02a.conf new file mode 100644 index 0000000000..7a89dffe67 --- /dev/null +++ b/boot/zephyr/boards/b_u585i_iot02a.conf @@ -0,0 +1,2 @@ +CONFIG_BOOT_DIRECT_XIP=y +CONFIG_STM32_MEMMAP=y diff --git a/boot/zephyr/boards/b_u585i_iot02a.overlay b/boot/zephyr/boards/b_u585i_iot02a.overlay new file mode 100644 index 0000000000..0d8a6cfe0d --- /dev/null +++ b/boot/zephyr/boards/b_u585i_iot02a.overlay @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2024 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ +/ { + chosen { + zephyr,flash = &flash0; + zephyr,code-partition = &boot_partition; + }; +}; diff --git a/boot/zephyr/boards/stm32f746g_disco.conf b/boot/zephyr/boards/stm32f746g_disco.conf new file mode 100644 index 0000000000..7a89dffe67 --- /dev/null +++ b/boot/zephyr/boards/stm32f746g_disco.conf @@ -0,0 +1,2 @@ +CONFIG_BOOT_DIRECT_XIP=y +CONFIG_STM32_MEMMAP=y diff --git a/boot/zephyr/boards/stm32f746g_disco.overlay b/boot/zephyr/boards/stm32f746g_disco.overlay new file mode 100644 index 0000000000..0d8a6cfe0d --- /dev/null +++ b/boot/zephyr/boards/stm32f746g_disco.overlay @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2024 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ +/ { + chosen { + zephyr,flash = &flash0; + zephyr,code-partition = &boot_partition; + }; +}; diff --git a/boot/zephyr/boards/stm32h735g_disco.conf b/boot/zephyr/boards/stm32h735g_disco.conf new file mode 100644 index 0000000000..7a89dffe67 --- /dev/null +++ b/boot/zephyr/boards/stm32h735g_disco.conf @@ -0,0 +1,2 @@ +CONFIG_BOOT_DIRECT_XIP=y +CONFIG_STM32_MEMMAP=y diff --git a/boot/zephyr/boards/stm32h735g_disco.overlay b/boot/zephyr/boards/stm32h735g_disco.overlay new file mode 100644 index 0000000000..0d8a6cfe0d --- /dev/null +++ b/boot/zephyr/boards/stm32h735g_disco.overlay @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2024 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ +/ { + chosen { + zephyr,flash = &flash0; + zephyr,code-partition = &boot_partition; + }; +}; diff --git a/boot/zephyr/boards/stm32h747i_disco_m7.conf b/boot/zephyr/boards/stm32h747i_disco_m7.conf new file mode 100644 index 0000000000..7a89dffe67 --- /dev/null +++ b/boot/zephyr/boards/stm32h747i_disco_m7.conf @@ -0,0 +1,2 @@ +CONFIG_BOOT_DIRECT_XIP=y +CONFIG_STM32_MEMMAP=y diff --git a/boot/zephyr/boards/stm32h747i_disco_m7.overlay b/boot/zephyr/boards/stm32h747i_disco_m7.overlay new file mode 100644 index 0000000000..0d8a6cfe0d --- /dev/null +++ b/boot/zephyr/boards/stm32h747i_disco_m7.overlay @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2024 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ +/ { + chosen { + zephyr,flash = &flash0; + zephyr,code-partition = &boot_partition; + }; +}; diff --git a/boot/zephyr/boards/stm32h750b_dk.conf b/boot/zephyr/boards/stm32h750b_dk.conf new file mode 100644 index 0000000000..7a89dffe67 --- /dev/null +++ b/boot/zephyr/boards/stm32h750b_dk.conf @@ -0,0 +1,2 @@ +CONFIG_BOOT_DIRECT_XIP=y +CONFIG_STM32_MEMMAP=y diff --git a/boot/zephyr/boards/stm32h750b_dk.overlay b/boot/zephyr/boards/stm32h750b_dk.overlay new file mode 100644 index 0000000000..0d8a6cfe0d --- /dev/null +++ b/boot/zephyr/boards/stm32h750b_dk.overlay @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2024 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ +/ { + chosen { + zephyr,flash = &flash0; + zephyr,code-partition = &boot_partition; + }; +}; diff --git a/boot/zephyr/boards/stm32h7b3i_dk.conf b/boot/zephyr/boards/stm32h7b3i_dk.conf new file mode 100644 index 0000000000..7a89dffe67 --- /dev/null +++ b/boot/zephyr/boards/stm32h7b3i_dk.conf @@ -0,0 +1,2 @@ +CONFIG_BOOT_DIRECT_XIP=y +CONFIG_STM32_MEMMAP=y diff --git a/boot/zephyr/boards/stm32h7b3i_dk.overlay b/boot/zephyr/boards/stm32h7b3i_dk.overlay new file mode 100644 index 0000000000..36305407a2 --- /dev/null +++ b/boot/zephyr/boards/stm32h7b3i_dk.overlay @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2024 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + chosen { + zephyr,code-partition = &boot_partition; + }; +}; diff --git a/boot/zephyr/boards/stm32l496g_disco.conf b/boot/zephyr/boards/stm32l496g_disco.conf new file mode 100644 index 0000000000..7a89dffe67 --- /dev/null +++ b/boot/zephyr/boards/stm32l496g_disco.conf @@ -0,0 +1,2 @@ +CONFIG_BOOT_DIRECT_XIP=y +CONFIG_STM32_MEMMAP=y diff --git a/boot/zephyr/boards/stm32l496g_disco.overlay b/boot/zephyr/boards/stm32l496g_disco.overlay new file mode 100644 index 0000000000..0d8a6cfe0d --- /dev/null +++ b/boot/zephyr/boards/stm32l496g_disco.overlay @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2024 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ +/ { + chosen { + zephyr,flash = &flash0; + zephyr,code-partition = &boot_partition; + }; +}; From cb2dfffe8454239837d67a704bc749f169f59f35 Mon Sep 17 00:00:00 2001 From: "F. Ramu" Date: Thu, 29 Feb 2024 15:27:40 +0100 Subject: [PATCH 3/4] boot: zephyr: boards config of the stm32h7s78 disco kit Define the stm32 disco board configuration to set the STM32 XIP mode that will enable the MemoryMapped mode. See Kconfig of the stm32 soc. Choose the mcu_boot partition where to build ../bootloader/mcuboot/boot/zephyr Signed-off-by: F. Ramu --- boot/zephyr/boards/stm32h7s78_dk.conf | 2 ++ boot/zephyr/boards/stm32h7s78_dk.overlay | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 boot/zephyr/boards/stm32h7s78_dk.conf create mode 100644 boot/zephyr/boards/stm32h7s78_dk.overlay diff --git a/boot/zephyr/boards/stm32h7s78_dk.conf b/boot/zephyr/boards/stm32h7s78_dk.conf new file mode 100644 index 0000000000..7a89dffe67 --- /dev/null +++ b/boot/zephyr/boards/stm32h7s78_dk.conf @@ -0,0 +1,2 @@ +CONFIG_BOOT_DIRECT_XIP=y +CONFIG_STM32_MEMMAP=y diff --git a/boot/zephyr/boards/stm32h7s78_dk.overlay b/boot/zephyr/boards/stm32h7s78_dk.overlay new file mode 100644 index 0000000000..d374529d60 --- /dev/null +++ b/boot/zephyr/boards/stm32h7s78_dk.overlay @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2024 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + chosen { + zephyr,flash = &flash0; + zephyr,code-partition = &boot_partition; + }; +}; From b0cb1a475c4277169c86638811def520e8019b1d Mon Sep 17 00:00:00 2001 From: "F. Ramu" Date: Mon, 15 Apr 2024 10:51:27 +0200 Subject: [PATCH 4/4] boot: zephyr: xspi1 for RWW on external NOR of stm32h7s78 disco kit Signed-off-by: F. Ramu --- boot/zephyr/boards/stm32h7s78_dk.overlay | 44 ++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/boot/zephyr/boards/stm32h7s78_dk.overlay b/boot/zephyr/boards/stm32h7s78_dk.overlay index d374529d60..6ee22e7afa 100644 --- a/boot/zephyr/boards/stm32h7s78_dk.overlay +++ b/boot/zephyr/boards/stm32h7s78_dk.overlay @@ -10,3 +10,47 @@ zephyr,code-partition = &boot_partition; }; }; + +&xspi1 { + /* same pining as 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"; + + mx66uw1g45: xspi-nor-flash@72000000 { + compatible = "st,stm32-xspi-nor"; + reg = <0x72000000 DT_SIZE_M(96)>; /* bank1 - 3*/ + ospi-max-frequency = ; + spi-bus-width = ; + data-rate = ; + status = "okay"; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + /* bank1 */ + slot1_partition: partition@0000000 { + label = "image-1"; + reg = <0x0000000 DT_SIZE_K(416)>; + }; + /* bank2 */ + scratch_partition: partition@2000000 { + label = "image-scratch"; + reg = <0x2000000 DT_SIZE_M(32)>; + }; + /* bank3 */ + storage_partition: partition@4000000 { + label = "storage"; + reg = <0x4000000 DT_SIZE_M(32)>; + }; + }; + }; +}; +