From 0adf7c02d7d3bac24c36986ec4dd8a59b7fb1fd6 Mon Sep 17 00:00:00 2001 From: Francois Ramu Date: Fri, 1 Sep 2023 10:20:40 +0200 Subject: [PATCH 1/5] 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 4a29750f75..e57d9c92eb 100644 --- a/boot/zephyr/flash_map_extended.c +++ b/boot/zephyr/flash_map_extended.c @@ -20,7 +20,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 9794d4070ac19587a1279b8ab90f0303e9cebb13 Mon Sep 17 00:00:00 2001 From: Francois Ramu Date: Thu, 19 Oct 2023 09:34:43 +0200 Subject: [PATCH 2/5] 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 The zephyr, chosen zephyr,flash = &flash0; is in the board dts. The zephyr,code-partition = &boot_partition; is given by the app.overlay Signed-off-by: Francois Ramu --- boot/zephyr/boards/b_u585i_iot02a.conf | 2 ++ boot/zephyr/boards/stm32f746g_disco.conf | 2 ++ boot/zephyr/boards/stm32h735g_disco.conf | 2 ++ boot/zephyr/boards/stm32h747i_disco_m7.conf | 2 ++ boot/zephyr/boards/stm32h750b_dk.conf | 2 ++ boot/zephyr/boards/stm32h7b3i_dk.conf | 2 ++ boot/zephyr/boards/stm32l496g_disco.conf | 2 ++ 7 files changed, 14 insertions(+) create mode 100644 boot/zephyr/boards/b_u585i_iot02a.conf create mode 100644 boot/zephyr/boards/stm32f746g_disco.conf create mode 100644 boot/zephyr/boards/stm32h735g_disco.conf create mode 100644 boot/zephyr/boards/stm32h747i_disco_m7.conf create mode 100644 boot/zephyr/boards/stm32h750b_dk.conf create mode 100644 boot/zephyr/boards/stm32h7b3i_dk.conf create mode 100644 boot/zephyr/boards/stm32l496g_disco.conf 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/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/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/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/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/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/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 From b8556b9178b7f30028688d2323bb2a3411f74737 Mon Sep 17 00:00:00 2001 From: "F. Ramu" Date: Thu, 29 Feb 2024 15:27:40 +0100 Subject: [PATCH 3/5] boot: zephyr: boards config of the stm32h7rs target boards Define the stm32h7s7 and stm32h73 board configuration to set the STM32 XIP mode that will enable the MemoryMapped mode. Gives larger sector size for the external NOR flash See Kconfig of the stm32 soc. Choose the mcu_boot partition where to build ../bootloader/mcuboot/boot/zephyr The zephyr, chosen zephyr,flash = &flash0; is in the board dts. The zephyr,code-partition = &boot_partition; is given by the app.overlay Signed-off-by: F. Ramu --- boot/zephyr/boards/nucleo_h7s3l8.conf | 4 ++++ boot/zephyr/boards/stm32h7s78_dk.conf | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 boot/zephyr/boards/nucleo_h7s3l8.conf create mode 100644 boot/zephyr/boards/stm32h7s78_dk.conf diff --git a/boot/zephyr/boards/nucleo_h7s3l8.conf b/boot/zephyr/boards/nucleo_h7s3l8.conf new file mode 100644 index 0000000000..93013ed9a1 --- /dev/null +++ b/boot/zephyr/boards/nucleo_h7s3l8.conf @@ -0,0 +1,4 @@ +CONFIG_BOOT_DIRECT_XIP=y +CONFIG_STM32_MEMMAP=y +CONFIG_BOOT_MAX_IMG_SECTORS_AUTO=n +CONFIG_BOOT_MAX_IMG_SECTORS=4096 diff --git a/boot/zephyr/boards/stm32h7s78_dk.conf b/boot/zephyr/boards/stm32h7s78_dk.conf new file mode 100644 index 0000000000..93013ed9a1 --- /dev/null +++ b/boot/zephyr/boards/stm32h7s78_dk.conf @@ -0,0 +1,4 @@ +CONFIG_BOOT_DIRECT_XIP=y +CONFIG_STM32_MEMMAP=y +CONFIG_BOOT_MAX_IMG_SECTORS_AUTO=n +CONFIG_BOOT_MAX_IMG_SECTORS=4096 From 0def128e3c879d01b697cc914ff462a85c7ecc02 Mon Sep 17 00:00:00 2001 From: Francois Ramu Date: Tue, 8 Apr 2025 17:42:59 +0200 Subject: [PATCH 4/5] boot: zephyr: boards config of the stm32h573 disco kit Define the stm32h573 board configuration to set the STM32 XIP mode that will enable the MemoryMapped mode. Gives larger sector size for the external NOR flash See Kconfig of the stm32 soc. Choose the mcu_boot partition where to build ../bootloader/mcuboot/boot/zephyr The zephyr, chosen zephyr,flash = &flash0; is in the board dts. The zephyr,code-partition = &boot_partition; is given by the app.overlay Signed-off-by: Francois Ramu --- boot/zephyr/boards/stm32h573i_dk.conf | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 boot/zephyr/boards/stm32h573i_dk.conf diff --git a/boot/zephyr/boards/stm32h573i_dk.conf b/boot/zephyr/boards/stm32h573i_dk.conf new file mode 100644 index 0000000000..93013ed9a1 --- /dev/null +++ b/boot/zephyr/boards/stm32h573i_dk.conf @@ -0,0 +1,4 @@ +CONFIG_BOOT_DIRECT_XIP=y +CONFIG_STM32_MEMMAP=y +CONFIG_BOOT_MAX_IMG_SECTORS_AUTO=n +CONFIG_BOOT_MAX_IMG_SECTORS=4096 From 22d64bceca08cbd5be134a68d0fc36b308b9bcf8 Mon Sep 17 00:00:00 2001 From: Francois Ramu Date: Tue, 29 Apr 2025 09:34:53 +0200 Subject: [PATCH 5/5] boot: zephyr: defines FLASH base address device for external NOR FLASH_DEVICE_BASE is now given by the parent of the "st,stm32-xspi-nor" node, which is the "st,stm32-xspi" compatible Signed-off-by: Francois Ramu --- boot/zephyr/flash_map_extended.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot/zephyr/flash_map_extended.c b/boot/zephyr/flash_map_extended.c index e57d9c92eb..3922b4f99e 100644 --- a/boot/zephyr/flash_map_extended.c +++ b/boot/zephyr/flash_map_extended.c @@ -25,7 +25,7 @@ BOOT_LOG_MODULE_DECLARE(mcuboot); #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)) +#define FLASH_DEVICE_BASE DT_REG_ADDR_BY_IDX(DT_INST(0, st_stm32_xspi),1) #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))