From b73e8bf453f809164874cd16dbdba4a8d346f830 Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Mon, 26 Jul 2021 11:21:36 +0200 Subject: arm: stm32mp: add defconfig for trusted boot with FIP Add TF-A FIP support for trusted boot on STM32MP15x, when STM32MP15x_STM32IMAGE is not activated. With FIP support the SSBL partition is named "fip" and its size is 4MB, so the ENV partition name in device tree (for SD card or eMMC) or offset in defconfig (CONFIG_ENV_OFFSET / CONFIG_ENV_OFFSET_REDUND) need to be modified. With FIP the TEE MTD partitions are removed because the OP-TEE binray are included in the FIP containers. Signed-off-by: Patrick Delaunay Reviewed-by: Patrice Chotard --- board/st/common/Kconfig | 21 +++++++++++++++------ board/st/common/stm32mp_mtdparts.c | 31 +++++++++++++++++++++++-------- board/st/stm32mp1/MAINTAINERS | 1 + 3 files changed, 39 insertions(+), 14 deletions(-) (limited to 'board') diff --git a/board/st/common/Kconfig b/board/st/common/Kconfig index ddcf33a..2f57118 100644 --- a/board/st/common/Kconfig +++ b/board/st/common/Kconfig @@ -8,18 +8,22 @@ config CMD_STBOARD config MTDPARTS_NAND0_BOOT string "mtd boot partitions for nand0" - default "2m(fsbl),2m(ssbl1),2m(ssbl2)" + default "2m(fsbl),2m(ssbl1),2m(ssbl2)" if STM32MP15x_STM32IMAGE || \ + !TFABOOT + default "2m(fsbl),4m(fip1),4m(fip2)" depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP help This define the partitions of nand0 used to build mtparts dynamically for boot from nand0. Each partition need to be aligned with the device erase block size, 512KB is the max size for the NAND supported by stm32mp1 platform. + The fsbl partition support multiple copy of the same binary, one by + erase block. config MTDPARTS_NAND0_TEE string "mtd tee partitions for nand0" default "512k(teeh),512k(teed),512k(teex)" - depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP + depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP && STM32MP15x_STM32IMAGE help This define the tee partitions added in mtparts dynamically when tee is supported with boot from nand0. @@ -28,7 +32,9 @@ config MTDPARTS_NAND0_TEE config MTDPARTS_NOR0_BOOT string "mtd boot partitions for nor0" - default "256k(fsbl1),256k(fsbl2),2m(ssbl),512k(u-boot-env)" + default "256k(fsbl1),256k(fsbl2),2m(ssbl),512k(u-boot-env)" if STM32MP15x_STM32IMAGE || \ + !TFABOOT + default "256k(fsbl1),256k(fsbl2),4m(fip),512k(u-boot-env)" depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP help This define the partitions of nand0 used to build mtparts dynamically @@ -40,24 +46,27 @@ config MTDPARTS_NOR0_BOOT config MTDPARTS_NOR0_TEE string "mtd tee partitions for nor0" default "256k(teeh),512k(teed),256k(teex)" - depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP + depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP && STM32MP15x_STM32IMAGE help This define the tee partitions added in mtparts dynamically when tee is supported with boot from nor0. config MTDPARTS_SPINAND0_BOOT string "mtd boot partitions for spi-nand0" - default "2m(fsbl),2m(ssbl1),2m(ssbl2)" + default "2m(fsbl),2m(ssbl1),2m(ssbl2)" if STM32MP15x_STM32IMAGE || !TFABOOT + default "2m(fsbl),4m(fip1),4m(fip2)" depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP help This define the partitions of nand0 used to build mtparts dynamically for boot from spi-nand0, 512KB is the max size for the NAND supported by stm32mp1 platform. + The fsbl partition support multiple copy of the same binary, one by + erase block. config MTDPARTS_SPINAND0_TEE string "mtd tee partitions for spi-nand0" default "512k(teeh),512k(teed),512k(teex)" - depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP + depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP && STM32MP15x_STM32IMAGE help This define the tee partitions added in mtparts dynamically when tee is supported with boot from spi-nand0, diff --git a/board/st/common/stm32mp_mtdparts.c b/board/st/common/stm32mp_mtdparts.c index f074fc1..8b636d6 100644 --- a/board/st/common/stm32mp_mtdparts.c +++ b/board/st/common/stm32mp_mtdparts.c @@ -11,7 +11,9 @@ #include #include #include +#ifdef CONFIG_STM32MP15x_STM32IMAGE #include +#endif #include #include #include @@ -31,7 +33,9 @@ static void board_set_mtdparts(const char *dev, char *mtdids, char *mtdparts, const char *boot, +#ifdef CONFIG_STM32MP15x_STM32IMAGE const char *tee, +#endif const char *user) { /* mtdids: "=, ...." */ @@ -55,10 +59,12 @@ static void board_set_mtdparts(const char *dev, strncat(mtdparts, ",", MTDPARTS_LEN); } +#ifdef CONFIG_STM32MP15x_STM32IMAGE if (tee) { strncat(mtdparts, tee, MTDPARTS_LEN); strncat(mtdparts, ",", MTDPARTS_LEN); } +#endif strncat(mtdparts, user, MTDPARTS_LEN); } @@ -70,7 +76,10 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts) static char parts[3 * MTDPARTS_LEN + 1]; static char ids[MTDIDS_LEN + 1]; static bool mtd_initialized; - bool tee, nor, nand, spinand, serial; + bool nor, nand, spinand, serial; +#ifdef CONFIG_STM32MP15x_STM32IMAGE + bool tee = false; +#endif if (mtd_initialized) { *mtdids = ids; @@ -78,7 +87,6 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts) return; } - tee = false; nor = false; nand = false; spinand = false; @@ -89,7 +97,9 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts) case BOOT_SERIAL_USB: serial = true; if (CONFIG_IS_ENABLED(CMD_STM32PROG)) { +#ifdef CONFIG_STM32MP15x_STM32IMAGE tee = stm32prog_get_tee_partitions(); +#endif nor = stm32prog_get_fsbl_nor(); } nand = true; @@ -108,9 +118,11 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts) break; } +#ifdef CONFIG_STM32MP15x_STM32IMAGE if (!serial && CONFIG_IS_ENABLED(OPTEE) && tee_find_device(NULL, NULL, NULL, NULL)) tee = true; +#endif memset(parts, 0, sizeof(parts)); memset(ids, 0, sizeof(ids)); @@ -125,10 +137,11 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts) if (nand) { mtd = get_mtd_device_nm("nand0"); if (!IS_ERR_OR_NULL(mtd)) { - const char *mtd_tee = CONFIG_MTDPARTS_NAND0_TEE; board_set_mtdparts("nand0", ids, parts, CONFIG_MTDPARTS_NAND0_BOOT, - !nor && tee ? mtd_tee : NULL, +#ifdef CONFIG_STM32MP15x_STM32IMAGE + !nor && tee ? CONFIG_MTDPARTS_NAND0_TEE : NULL, +#endif "-(UBI)"); put_mtd_device(mtd); } @@ -137,10 +150,11 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts) if (spinand) { mtd = get_mtd_device_nm("spi-nand0"); if (!IS_ERR_OR_NULL(mtd)) { - const char *mtd_tee = CONFIG_MTDPARTS_SPINAND0_TEE; board_set_mtdparts("spi-nand0", ids, parts, CONFIG_MTDPARTS_SPINAND0_BOOT, - !nor && tee ? mtd_tee : NULL, +#ifdef CONFIG_STM32MP15x_STM32IMAGE + !nor && tee ? CONFIG_MTDPARTS_SPINAND0_TEE : NULL, +#endif "-(UBI)"); put_mtd_device(mtd); } @@ -148,10 +162,11 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts) if (nor) { if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev)) { - const char *mtd_tee = CONFIG_MTDPARTS_NOR0_TEE; board_set_mtdparts("nor0", ids, parts, CONFIG_MTDPARTS_NOR0_BOOT, - tee ? mtd_tee : NULL, +#ifdef CONFIG_STM32MP15x_STM32IMAGE + tee ? CONFIG_MTDPARTS_NOR0_TEE : NULL, +#endif "-(nor_user)"); } } diff --git a/board/st/stm32mp1/MAINTAINERS b/board/st/stm32mp1/MAINTAINERS index fe8fc6f..0e6d80f 100644 --- a/board/st/stm32mp1/MAINTAINERS +++ b/board/st/stm32mp1/MAINTAINERS @@ -5,6 +5,7 @@ T: git https://source.denx.de/u-boot/custodians/u-boot-stm.git S: Maintained F: arch/arm/dts/stm32mp15* F: board/st/stm32mp1/ +F: configs/stm32mp15_defconfig F: configs/stm32mp15_basic_defconfig F: configs/stm32mp15_trusted_defconfig F: include/configs/stm32mp1.h -- cgit v1.1