Skip to contentSkip to conversation

stm32mp1: add OP-TEE configuration and associated MTD partitions

PATCH New Patrick Delaunay 1 participant 7 messages Jul 2, 2019 – Jul 12, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover stm32mp1: add OP-TEE configuration and associated MTD partitions

Added features for v2019.10
- Add Trusted boot chain with OP-TEE
- fixup of MTDPARTS in kernel device tree

Patrick Delaunay (3):
stm32mp1: reorder some CONFIG in stm32mp1.h
stm32mp1: add configuration op-tee
stm32mp1: activate OF_BOARD_SETUP and FDT_FIXUP_PARTITIONS

 arch/arm/mach-stm32mp/Kconfig       |  13 ++++-
 board/st/stm32mp1/MAINTAINERS       |   1 +
 board/st/stm32mp1/README            |  29 +++++++---
 board/st/stm32mp1/stm32mp1.c        |  22 +++++++-
 configs/stm32mp15_basic_defconfig   |   1 +
 configs/stm32mp15_optee_defconfig   | 104 ++++++++++++++++++++++++++++++++++++
 configs/stm32mp15_trusted_defconfig |   1 +
 include/configs/stm32mp1.h          |  30 ++++++++---
 8 files changed, 186 insertions(+), 15 deletions(-)
 create mode 100644 configs/stm32mp15_optee_defconfig
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/3 stm32mp1: reorder some CONFIG in stm32mp1.h

Change config not directly linked to CONFIG_DISTRO_DEFAULTS. Allow to deactivate CONFIG_SYS_MTDPARTS_RUNTIME when CONFIG_MTDPARTS_DEFAULT is defined in defconfig.

---

 include/configs/stm32mp1.h | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
include/configs/stm32mp1.h +12 -7
index 1d385e0..6626be7 100644
@@ -77,6 +77,10 @@
 /*MMC SD*/
 #define CONFIG_SYS_MMC_MAX_DEVICE	3
 
+/* NAND support */
+#define CONFIG_SYS_NAND_ONFI_DETECTION
+#define CONFIG_SYS_MAX_NAND_DEVICE	1
+
 /* Ethernet need */
 #ifdef CONFIG_DWC_ETH_QOS
 #define CONFIG_SYS_NONCACHED_MEMORY	(1 * SZ_1M)	/* 1M */
@@ -85,15 +89,15 @@
 #define CONFIG_SYS_AUTOLOAD		"no"
 #endif
 
+/* Dynamic MTD partition support */
+#define CONFIG_SYS_MTDPARTS_RUNTIME
+
 /*****************************************************************************/
 #ifdef CONFIG_DISTRO_DEFAULTS
 /*****************************************************************************/
 
 #if !defined(CONFIG_SPL_BUILD)
 
-/* NAND support */
-#define CONFIG_SYS_NAND_ONFI_DETECTION
-#define CONFIG_SYS_MAX_NAND_DEVICE	1
 #define BOOT_TARGET_DEVICES(func) \
 	func(MMC, mmc, 1) \
 	func(MMC, mmc, 0) \
@@ -121,14 +125,15 @@
 
 #include <config_distro_bootcmd.h>
 
-#if defined(CONFIG_STM32_QSPI) || defined(CONFIG_NAND_STM32_FMC)
-#define CONFIG_SYS_MTDPARTS_RUNTIME
-#endif
-
 #define STM32MP_MTDPARTS \
 	"mtdparts_nor0=256k(fsbl1),256k(fsbl2),2m(ssbl),256k(u-boot-env),-(nor_user)\0" \
 	"mtdparts_nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),-(UBI)\0"
 
+#ifndef CONFIG_SYS_MTDPARTS_RUNTIME
+#undef STM32MP_MTDPARTS
+#define STM32MP_MTDPARTS
+#endif
+
 /*
  * memory layout for 32M uncompressed/compressed kernel,
  * 1M fdt, 1M script, 1M pxe and 1M for splashimage
Signature · 1 line
2.7.4
#2 lore raw

PATCH 1/3 stm32mp1: reorder some CONFIG in stm32mp1.h

Hi,

Quoted 7 lines

From: Patrick DELAUNAY <[email protected]>
Sent: mardi 2 juillet 2019 13:26

Change config not directly linked to CONFIG_DISTRO_DEFAULTS. Allow to deactivate CONFIG_SYS_MTDPARTS_RUNTIME when CONFIG_MTDPARTS_DEFAULT is defined in defconfig.

Quoted 6 lines

---

 include/configs/stm32mp1.h | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

Applied to u-boot-stm32/master, thanks!

Patrick

#3 lore raw

PATCH 2/3 stm32mp1: add configuration op-tee

In reply to Patrick Delaunay

Add support of Trusted boot chain with OP-TEE
- reserved 32MB at the end of the DDR for OP-TEE

---

 arch/arm/mach-stm32mp/Kconfig     |  12 ++++-
 board/st/stm32mp1/MAINTAINERS     |   1 +
 board/st/stm32mp1/README          |  29 ++++++++---
 board/st/stm32mp1/stm32mp1.c      |   4 +-
 configs/stm32mp15_optee_defconfig | 103 ++++++++++++++++++++++++++++++++++++++
 include/configs/stm32mp1.h        |  13 +++++
 6 files changed, 153 insertions(+), 9 deletions(-)
 create mode 100644 configs/stm32mp15_optee_defconfig
arch/arm/mach-stm32mp/Kconfig +11 -1
index d9ad6b4..a00c8ab 100644
@@ -62,7 +62,17 @@ config STM32MP1_TRUSTED
 		Say Y here to enable boot with TF-A
 		Trusted boot chain is :
 		BootRom => TF-A.stm32 (clock & DDR) => U-Boot.stm32
-		TF-A monitor provides proprietary smc to manage secure devices
+		TF-A monitor provides proprietary SMC to manage secure devices
+
+config STM32MP1_OPTEE
+	bool "Support trusted boot with TF-A and OP-TEE"
+	depends on STM32MP1_TRUSTED
+	default n
+	help
+		Say Y here to enable boot with TF-A and OP-TEE
+		Trusted boot chain is :
+		BootRom => TF-A.stm32 (clock & DDR) => OP-TEE => U-Boot.stm32
+		OP-TEE monitor provides ST SMC to access to secure resources
 
 config SYS_TEXT_BASE
 	prompt "U-Boot base address"
board/st/stm32mp1/MAINTAINERS +1 -0
index 0a2eddb..3bf4c21 100644
@@ -5,5 +5,6 @@ S:	Maintained
 F:	arch/arm/dts/stm32mp157*
 F:	board/st/stm32mp1
 F:	configs/stm32mp15_basic_defconfig
+F:	configs/stm32mp15_optee_defconfig
 F:	configs/stm32mp15_trusted_defconfig
 F:	include/configs/stm32mp1.h
board/st/stm32mp1/README +22 -7
index b0c8325..583d92e 100644
@@ -47,7 +47,7 @@ BootRom => FSBL in SYSRAM => SSBL in DDR => OS (Linux Kernel)
 with FSBL = First Stage Bootloader
      SSBL = Second Stage Bootloader
 
-2 boot configurations are supported:
+3 boot configurations are supported:
 
 1) The "Trusted" boot chain (defconfig_file : stm32mp15_trusted_defconfig)
    BootRom => FSBL = Trusted Firmware-A (TF-A) => SSBL = U-Boot
@@ -56,7 +56,15 @@ with FSBL = First Stage Bootloader
    U-Boot is running in normal world and uses TF-A monitor
    to access to secure resources
 
-2) The "Basic" boot chain (defconfig_file : stm32mp15_basic_defconfig)
+2) The "Trusted" boot chain with OP-TEE
+   (defconfig_file : stm32mp15_optee_defconfig)
+   BootRom => FSBL = Trusted Firmware-A (TF-A) => SSBL = U-Boot
+   TF-A performs a full initialization of Secure peripherals and installs OP-TEE
+   from specific partitions (teeh, teed, teex).
+   U-Boot is running in normal world and uses OP-TEE monitor to access
+   to secure resources.
+
+3) The "Basic" boot chain (defconfig_file : stm32mp15_basic_defconfig)
    BootRom => FSBL = U-Boot SPL => SSBL = U-Boot
    SPL has limited security initialisation
    U-Boot is running in secure mode and provide a secure monitor to the kernel
@@ -109,6 +117,7 @@ the supported device trees for stm32mp157 are:
 
 	for example: use one output directory for each configuration
 	# export KBUILD_OUTPUT=stm32mp15_trusted
+	# export KBUILD_OUTPUT=stm32mp15_optee
 	# export KBUILD_OUTPUT=stm32mp15_basic
 
 4. Configure U-Boot:
@@ -116,6 +125,7 @@ the supported device trees for stm32mp157 are:
 	# make <defconfig_file>
 
 	- For trusted boot mode : "stm32mp15_trusted_defconfig"
+	- For trusted with OP-TEE boot mode : "stm32mp15_optee_defconfig"
 	- For basic boot mode: "stm32mp15_basic_defconfig"
 
 5. Configure the device-tree and build the U-Boot image:
@@ -129,20 +139,25 @@ the supported device trees for stm32mp157 are:
 	# make stm32mp15_trusted_defconfig
 	# make DEVICE_TREE=stm32mp157c-ev1 all
 
-  b) basic boot on ev1
+  b) trusted with OP-TEE boot on dk2
+	# export KBUILD_OUTPUT=stm32mp15_optee
+	# make stm32mp15_optee_defconfig
+	# make DEVICE_TREE=stm32mp157c-dk2 all
+
+  c) basic boot on ev1
 	# export KBUILD_OUTPUT=stm32mp15_basic
 	# make stm32mp15_basic_defconfig
 	# make DEVICE_TREE=stm32mp157c-ev1 all
 
-  c) basic boot on ed1
+  d) basic boot on ed1
 	# export KBUILD_OUTPUT=stm32mp15_basic
 	# make stm32mp15_basic_defconfig
 	# make DEVICE_TREE=stm32mp157c-ed1 all
 
-  d) basic boot on dk2
+  e) basic boot on dk1
 	# export KBUILD_OUTPUT=stm32mp15_basic
 	# make stm32mp15_basic_defconfig
-	# make DEVICE_TREE=stm32mp157c-dk2 all
+	# make DEVICE_TREE=stm32mp157a-dk1 all
 
   d) basic boot on avenger96
 	# export KBUILD_OUTPUT=stm32mp15_basic
@@ -157,7 +172,7 @@ the supported device trees for stm32mp157 are:
   So in the output directory (selected by KBUILD_OUTPUT),
   you can found the needed files:
 
-  a) For Trusted boot
+  a) For Trusted boot (with or without OP-TEE)
    + FSBL = tf-a.stm32 (provided by TF-A compilation)
    + SSBL = u-boot.stm32
 
board/st/stm32mp1/stm32mp1.c +3 -1
index 7769293..d62d180 100644
@@ -76,7 +76,9 @@ int checkboard(void)
 	const char *fdt_compat;
 	int fdt_compat_len;
 
-	if (IS_ENABLED(CONFIG_STM32MP1_TRUSTED))
+	if (IS_ENABLED(CONFIG_STM32MP1_OPTEE))
+		mode = "trusted with OP-TEE";
+	else if (IS_ENABLED(CONFIG_STM32MP1_TRUSTED))
 		mode = "trusted";
 	else
 		mode = "basic";
configs/stm32mp15_optee_defconfig new file +103 -0

103 lines not on this page · raw message

include/configs/stm32mp1.h +13 -0
index 6626be7..d4805c2 100644
@@ -28,6 +28,10 @@
 #define CONFIG_SYS_SDRAM_BASE			STM32_DDR_BASE
 #define CONFIG_SYS_INIT_SP_ADDR			CONFIG_SYS_TEXT_BASE
 
+#ifdef CONFIG_STM32MP1_OPTEE
+#define CONFIG_SYS_MEM_TOP_HIDE			SZ_32M
+#endif /* CONFIG_STM32MP1_OPTEE */
+
 /*
  * Console I/O buffer size
  */
@@ -125,10 +129,19 @@
 
 #include <config_distro_bootcmd.h>
 
+#ifdef CONFIG_STM32MP1_OPTEE
+/* with OPTEE: define specific MTD partitions = teeh, teed, teex */
+#define STM32MP_MTDPARTS \
+	"mtdparts_nor0=256k(fsbl1),256k(fsbl2),2m(ssbl),256k(u-boot-env),256k(teeh),256k(teed),256k(teex),-(nor_user)\0" \
+	"mtdparts_nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),512k(teeh),512k(teed),512k(teex),-(UBI)\0"
+
+#else /* CONFIG_STM32MP1_OPTEE */
 #define STM32MP_MTDPARTS \
 	"mtdparts_nor0=256k(fsbl1),256k(fsbl2),2m(ssbl),256k(u-boot-env),-(nor_user)\0" \
 	"mtdparts_nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),-(UBI)\0"
 
+#endif /* CONFIG_STM32MP1_OPTEE */
+
 #ifndef CONFIG_SYS_MTDPARTS_RUNTIME
 #undef STM32MP_MTDPARTS
 #define STM32MP_MTDPARTS
Signature · 1 line
2.7.4
#4 lore raw

PATCH 2/3 stm32mp1: add configuration op-tee

Hi,

Quoted 17 lines

From: Patrick DELAUNAY <[email protected]>
Sent: mardi 2 juillet 2019 13:26

Add support of Trusted boot chain with OP-TEE
- reserved 32MB at the end of the DDR for OP-TEE

---

 arch/arm/mach-stm32mp/Kconfig     |  12 ++++-
 board/st/stm32mp1/MAINTAINERS     |   1 +
 board/st/stm32mp1/README          |  29 ++++++++---
 board/st/stm32mp1/stm32mp1.c      |   4 +-
 configs/stm32mp15_optee_defconfig | 103
++++++++++++++++++++++++++++++++++++++
 include/configs/stm32mp1.h        |  13 +++++
 6 files changed, 153 insertions(+), 9 deletions(-)  create mode 100644
Quoted 2 lines

configs/stm32mp15_optee_defconfig

Applied to u-boot-stm32/master, thanks!

Patrick

#5 lore raw

PATCH 3/3 stm32mp1: activate OF_BOARD_SETUP and FDT_FIXUP_PARTITIONS

In reply to Patrick Delaunay

Update kernel MTD partition in device tree with U-Boot information.

---

 arch/arm/mach-stm32mp/Kconfig       |  1 +
 board/st/stm32mp1/stm32mp1.c        | 18 ++++++++++++++++++
 configs/stm32mp15_basic_defconfig   |  1 +
 configs/stm32mp15_optee_defconfig   |  1 +
 configs/stm32mp15_trusted_defconfig |  1 +
 5 files changed, 22 insertions(+)
arch/arm/mach-stm32mp/Kconfig +1 -0
index a00c8ab..50594c6 100644
@@ -38,6 +38,7 @@ config TARGET_STM32MP1
 	select CPU_V7A
 	select CPU_V7_HAS_NONSEC if !STM32MP1_TRUSTED
 	select CPU_V7_HAS_VIRT
+	select OF_BOARD_SETUP
 	select PINCTRL_STM32
 	select STM32_RCC
 	select STM32_RESET
board/st/stm32mp1/stm32mp1.c +18 -0
index d62d180..475af25 100644
@@ -13,6 +13,8 @@
 #include <i2c.h>
 #include <led.h>
 #include <misc.h>
+#include <mtd.h>
+#include <mtd_node.h>
 #include <phy.h>
 #include <reset.h>
 #include <syscon.h>
@@ -21,6 +23,7 @@
 #include <asm/gpio.h>
 #include <asm/arch/stm32.h>
 #include <asm/arch/sys_proto.h>
+#include <jffs2/load_kernel.h>
 #include <power/regulator.h>
 #include <usb/dwc2_udc.h>
 
@@ -747,3 +750,18 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
 	debug("%s:mtdids=%s & mtdparts=%s\n", __func__, ids, parts);
 }
 #endif
+
+#if defined(CONFIG_OF_BOARD_SETUP)
+int ft_board_setup(void *blob, bd_t *bd)
+{
+#ifdef CONFIG_FDT_FIXUP_PARTITIONS
+	struct node_info nodes[] = {
+		{ "st,stm32f469-qspi",		MTD_DEV_TYPE_NOR,  },
+		{ "st,stm32mp15-fmc2",		MTD_DEV_TYPE_NAND, },
+	};
+	fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
+#endif
+
+	return 0;
+}
+#endif
configs/stm32mp15_basic_defconfig +1 -0
index 4aa184f..f2fb254 100644
@@ -112,3 +112,4 @@ CONFIG_USB_GADGET_PRODUCT_NUM=0x5720
 CONFIG_USB_GADGET_DWC2_OTG=y
 CONFIG_WDT=y
 CONFIG_WDT_STM32MP=y
+CONFIG_FDT_FIXUP_PARTITIONS=y
configs/stm32mp15_optee_defconfig +1 -0
index f3e4ea6..f63c122 100644
@@ -101,3 +101,4 @@ CONFIG_USB_GADGET_MANUFACTURER="STMicroelectronics"
 CONFIG_USB_GADGET_VENDOR_NUM=0x0483
 CONFIG_USB_GADGET_PRODUCT_NUM=0x5720
 CONFIG_USB_GADGET_DWC2_OTG=y
+CONFIG_FDT_FIXUP_PARTITIONS=y
configs/stm32mp15_trusted_defconfig +1 -0
index 5fe9477..94c610b 100644
@@ -102,3 +102,4 @@ CONFIG_USB_GADGET_PRODUCT_NUM=0x5720
 CONFIG_USB_GADGET_DWC2_OTG=y
 CONFIG_WDT=y
 CONFIG_WDT_STM32MP=y
+CONFIG_FDT_FIXUP_PARTITIONS=y
Signature · 1 line
2.7.4
#6 lore raw

PATCH 3/3 stm32mp1: activate OF_BOARD_SETUP and FDT_FIXUP_PARTITIONS

Hi,

Quoted 6 lines

From: Patrick DELAUNAY <[email protected]>
Sent: mardi 2 juillet 2019 13:26

Update kernel MTD partition in device tree with U-Boot information.

Quoted 9 lines

---

 arch/arm/mach-stm32mp/Kconfig       |  1 +
 board/st/stm32mp1/stm32mp1.c        | 18 ++++++++++++++++++
 configs/stm32mp15_basic_defconfig   |  1 +
 configs/stm32mp15_optee_defconfig   |  1 +
 configs/stm32mp15_trusted_defconfig |  1 +
 5 files changed, 22 insertions(+)

Applied to u-boot-stm32/master, thanks!

Patrick