Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mcuboot supports the stm32 external flash in XiP mode #2154

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions boot/zephyr/boards/b_u585i_iot02a.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_BOOT_DIRECT_XIP=y
CONFIG_STM32_MEMMAP=y
11 changes: 11 additions & 0 deletions boot/zephyr/boards/b_u585i_iot02a.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright (c) 2024 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/
/ {
chosen {
zephyr,flash = &flash0;
zephyr,code-partition = &boot_partition;
};
};
3 changes: 3 additions & 0 deletions boot/zephyr/boards/nucleo_h7s3l8.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CONFIG_BOOT_DIRECT_XIP=y
CONFIG_STM32_MEMMAP=y
CONFIG_BOOT_MAX_IMG_SECTORS_AUTO=n
12 changes: 12 additions & 0 deletions boot/zephyr/boards/nucleo_h7s3l8.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright (c) 2024 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/

/ {
chosen {
zephyr,flash = &flash0;
zephyr,code-partition = &boot_partition;
};
};
2 changes: 2 additions & 0 deletions boot/zephyr/boards/stm32f746g_disco.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_BOOT_DIRECT_XIP=y
CONFIG_STM32_MEMMAP=y
11 changes: 11 additions & 0 deletions boot/zephyr/boards/stm32f746g_disco.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright (c) 2024 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/
/ {
chosen {
zephyr,flash = &flash0;
zephyr,code-partition = &boot_partition;
};
};
2 changes: 2 additions & 0 deletions boot/zephyr/boards/stm32h735g_disco.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_BOOT_DIRECT_XIP=y
CONFIG_STM32_MEMMAP=y
11 changes: 11 additions & 0 deletions boot/zephyr/boards/stm32h735g_disco.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright (c) 2024 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/
/ {
chosen {
zephyr,flash = &flash0;
zephyr,code-partition = &boot_partition;
};
};
2 changes: 2 additions & 0 deletions boot/zephyr/boards/stm32h747i_disco_m7.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_BOOT_DIRECT_XIP=y
CONFIG_STM32_MEMMAP=y
11 changes: 11 additions & 0 deletions boot/zephyr/boards/stm32h747i_disco_m7.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright (c) 2024 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/
/ {
chosen {
zephyr,flash = &flash0;
zephyr,code-partition = &boot_partition;
};
};
2 changes: 2 additions & 0 deletions boot/zephyr/boards/stm32h750b_dk.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_BOOT_DIRECT_XIP=y
CONFIG_STM32_MEMMAP=y
11 changes: 11 additions & 0 deletions boot/zephyr/boards/stm32h750b_dk.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright (c) 2024 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/
/ {
chosen {
zephyr,flash = &flash0;
zephyr,code-partition = &boot_partition;
};
};
2 changes: 2 additions & 0 deletions boot/zephyr/boards/stm32h7b3i_dk.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_BOOT_DIRECT_XIP=y
CONFIG_STM32_MEMMAP=y
11 changes: 11 additions & 0 deletions boot/zephyr/boards/stm32h7b3i_dk.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright (c) 2024 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/

/ {
chosen {
zephyr,code-partition = &boot_partition;
};
};
2 changes: 2 additions & 0 deletions boot/zephyr/boards/stm32h7s78_dk.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_BOOT_DIRECT_XIP=y
CONFIG_STM32_MEMMAP=y
56 changes: 56 additions & 0 deletions boot/zephyr/boards/stm32h7s78_dk.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2024 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/

/ {
chosen {
zephyr,flash = &flash0;
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 = <DT_FREQ_M(50)>;
spi-bus-width = <XSPI_OCTO_MODE>;
data-rate = <XSPI_DTR_TRANSFER>;
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)>;
};
};
};
};

2 changes: 2 additions & 0 deletions boot/zephyr/boards/stm32l496g_disco.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_BOOT_DIRECT_XIP=y
CONFIG_STM32_MEMMAP=y
11 changes: 11 additions & 0 deletions boot/zephyr/boards/stm32l496g_disco.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright (c) 2024 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/
/ {
chosen {
zephyr,flash = &flash0;
zephyr,code-partition = &boot_partition;
};
};
18 changes: 17 additions & 1 deletion boot/zephyr/flash_map_extended.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading