All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 00/11] Enable Windows 10 IoT Core on i.MX6 and i.MX7
@ 2018-07-14  0:11 Henry Beberman
  2018-07-14  0:11 ` [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc Henry Beberman
                   ` (10 more replies)
  0 siblings, 11 replies; 33+ messages in thread
From: Henry Beberman @ 2018-07-14  0:11 UTC (permalink / raw)
  To: u-boot

From: Henry Beberman <henry.beberman@microsoft.com>

This patch series is a collaboration between Microsoft and NXP to
enable Windows 10 IoT Core on NXP's iMX6 and iMX7 platforms.

The series contains reference configurations to enable Windows boot on the following
platforms: mx6sabresd, mx7dsabresd, mx6cuboxi, udoo_neo, and cl-som-imx7

These patches enable the following Windows boot flow:
1) U-Boot SPL loads from the MMC into on-chip RAM.
2) SPL loads a Flat Image Tree containing the OP-TEE runtime and U-Boot Proper.
3) SPL disables caches/interrupts and jumps into OP-TEE.
4) OP-TEE initializes then returns to the entry point of U-Boot
Proper in normal mode. OP-TEE is later used as a runtime for Trusted Applications from within Windows.
5) U-Boot Proper initializes the platform bypassing several actions
that would require secure world access.
6) The U-Boot Proper bootcmd loads a UEFI firmware binary from the
first FAT partition of the MMC into memory.
7) An overridden go command will stash the platform MAC address
from the U-Boot env into a page of memory that is preserved for UEFI.
8) The overridden go command will disable caches and interrupts then
jump into UEFI.
9) UEFI initializes the platform further and boots Windows from MMC.

Henry Beberman (11):
  imx: Add bootcmd to load and run UEFI from mmc
  arm: Allow U-Boot Proper to run in normal world
  spl: Add FIT boot into OP-TEE then U-Boot proper
  spl: imx: Add optional lds to keep SPL entirely in on-chip RAM
  mx6sabresd: nt: Add Windows boot support for iMX6 Sabre
  mx7dsabresd: Add Windows boot support for iMX7 Sabre
  mx6cuboxi: Add Windows boot support for mx6cuboxi
  udoo_neo: Add Windows boot support for UDOO Neo
  cl-som-imx7: Add Windows boot support for cl-som-imx7
  imx: Reserve a global page in memory to pass configuration to UEFI
  imx: Add MAC addresses to global page to pass MAC into UEFI

Cc:  Stefano Babic <sbabic@denx.de>
Cc:  Fabio Estevam <fabio.estevam@nxp.com>
Cc:  Tom Rini <trini@konsulko.com>
Cc:  Robert Solomon <robsol@exchange.microsoft.com>
Cc:  Chirag Shah <chsha@microsoft.com>
Cc:  Robert Oshana <robert.oshana@nxp.com>
Cc:  Patrick Stilwell <patrick.stilwell@nxp.com>

 arch/arm/cpu/armv7/Kconfig                |   7 ++
 arch/arm/cpu/armv7/Makefile               |   1 +
 arch/arm/cpu/armv7/optee_jump.S           |  31 +++++++++
 arch/arm/cpu/armv7/start.S                |  11 ++--
 arch/arm/dts/Makefile                     |   4 ++
 arch/arm/dts/imx6qdl-mx6cuboxi.dts        |   8 +++
 arch/arm/dts/imx6qdl-sdb.dts              |   8 +++
 arch/arm/dts/imx6sx-udoo-neo.dts          |   8 +++
 arch/arm/dts/imx7d-cl-som-imx7.dts        |   8 +++
 arch/arm/lib/spl.c                        |  16 +++++
 arch/arm/mach-imx/Kconfig                 |  23 +++++++
 arch/arm/mach-imx/Makefile                |   2 +
 arch/arm/mach-imx/boot.c                  |  25 ++++++++
 arch/arm/mach-imx/global_page.c           |  52 +++++++++++++++
 arch/arm/mach-imx/mx7/Kconfig             |   1 +
 arch/arm/mach-imx/mx7/soc.c               |   7 +-
 arch/arm/mach-imx/syscounter.c            |   2 +
 arch/arm/mach-imx/u-boot-spl-sram.lds     |  59 +++++++++++++++++
 board/compulab/cl-som-imx7/MAINTAINERS    |   2 +
 board/compulab/cl-som-imx7/cl-som-imx7.c  |  47 +++++++++++++-
 board/compulab/cl-som-imx7/spl.c          |   7 ++
 board/freescale/mx6sabresd/MAINTAINERS    |   2 +
 board/freescale/mx6sabresd/mx6sabresd.c   |   9 ++-
 board/freescale/mx7dsabresd/MAINTAINERS   |   1 +
 board/freescale/mx7dsabresd/mx7dsabresd.c |  79 +++++++++++++++++++++++
 board/solidrun/mx6cuboxi/MAINTAINERS      |   2 +
 board/solidrun/mx6cuboxi/mx6cuboxi.c      |   7 ++
 board/udoo/neo/MAINTAINERS                |   2 +
 board/udoo/neo/neo.c                      |   7 ++
 common/Kconfig                            |  17 +++++
 common/spl/Kconfig                        |   9 +++
 common/spl/spl.c                          |   6 ++
 configs/cl-som-imx7_nt_defconfig          |  82 ++++++++++++++++++++++++
 configs/mx6cuboxi_nt_defconfig            |  64 +++++++++++++++++++
 configs/mx6sabresd_nt_defconfig           |  60 ++++++++++++++++++
 configs/mx7dsabresd_nt_defconfig          | 102 ++++++++++++++++++++++++++++++
 configs/udoo_neo_nt_defconfig             |  57 +++++++++++++++++
 drivers/gpio/Makefile                     |   3 +
 drivers/pinctrl/nxp/pinctrl-imx7.c        |   4 +-
 include/config_uefi_bootcmd.h             |  29 +++++++++
 include/configs/cl-som-imx7.h             |  18 +++++-
 include/configs/imx6_spl.h                |   2 +
 include/configs/imx7_spl.h                |   2 +
 include/configs/mx6_common.h              |  16 +++++
 include/configs/mx6cuboxi.h               |   8 +++
 include/configs/mx6sabre_common.h         |  10 +++
 include/configs/mx7_common.h              |  10 +++
 include/configs/mx7dsabresd.h             |  10 +++
 include/configs/udoo_neo.h                |   8 +++
 include/global_page.h                     |  32 ++++++++++
 include/spl.h                             |  21 ++++++
 51 files changed, 995 insertions(+), 13 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/optee_jump.S
 create mode 100644 arch/arm/dts/imx6qdl-mx6cuboxi.dts
 create mode 100644 arch/arm/dts/imx6qdl-sdb.dts
 create mode 100644 arch/arm/dts/imx6sx-udoo-neo.dts
 create mode 100644 arch/arm/dts/imx7d-cl-som-imx7.dts
 create mode 100644 arch/arm/mach-imx/boot.c
 create mode 100644 arch/arm/mach-imx/global_page.c
 create mode 100644 arch/arm/mach-imx/u-boot-spl-sram.lds
 create mode 100644 configs/cl-som-imx7_nt_defconfig
 create mode 100644 configs/mx6cuboxi_nt_defconfig
 create mode 100644 configs/mx6sabresd_nt_defconfig
 create mode 100644 configs/mx7dsabresd_nt_defconfig
 create mode 100644 configs/udoo_neo_nt_defconfig
 create mode 100644 include/config_uefi_bootcmd.h
 create mode 100644 include/global_page.h

-- 
2.16.2.gvfs.1.33.gf5370f1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc
  2018-07-14  0:11 [U-Boot] [PATCH 00/11] Enable Windows 10 IoT Core on i.MX6 and i.MX7 Henry Beberman
@ 2018-07-14  0:11 ` Henry Beberman
  2018-07-16 17:16   ` Trent Piepho
  2018-08-07 11:11   ` Stefano Babic
  2018-07-14  0:11 ` [U-Boot] [PATCH 03/11] spl: Add FIT boot into OP-TEE then U-Boot proper Henry Beberman
                   ` (9 subsequent siblings)
  10 siblings, 2 replies; 33+ messages in thread
From: Henry Beberman @ 2018-07-14  0:11 UTC (permalink / raw)
  To: u-boot

From: Henry Beberman <henry.beberman@microsoft.com>

This patch enables i.MX platforms to easily add a boot script to their
U-Boot Proper environment to automatically load and execute an EFI
firmware from the first FAT partition of an MMC device.

This is a portion of enabling the Windows 10 IoT Core boot path.

The go command is overridden when CONFIG_UEFI_BOOT is specified. This
new go will perform a cache flush/disable, disable interrupts, then
jump to the address where UEFI was loaded.

This patch adds two new Kconfig options:
CONFIG_UEFI_BOOT: Selects the UEFI bootcmd and overrides go to flush
caches and disable interrupts.
CONFIG_UEFI_LOAD_ADDR: Specifies the load address for the UEFI image

Signed-off-by: Henry Beberman <henry.beberman@microsoft.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Tom Rini <trini@konsulko.com>
---
 arch/arm/mach-imx/Makefile    |  1 +
 arch/arm/mach-imx/boot.c      | 19 +++++++++++++++++++
 common/Kconfig                | 17 +++++++++++++++++
 include/config_uefi_bootcmd.h | 29 +++++++++++++++++++++++++++++
 4 files changed, 66 insertions(+)
 create mode 100644 arch/arm/mach-imx/boot.c
 create mode 100644 include/config_uefi_bootcmd.h

diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 733c308670..a81af51f03 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -42,6 +42,7 @@ endif
 obj-$(CONFIG_SATA) += sata.o
 obj-$(CONFIG_SECURE_BOOT)    += hab.o
 obj-$(CONFIG_SYSCOUNTER_TIMER) += syscounter.o
+obj-$(CONFIG_UEFI_BOOT) += boot.o
 endif
 ifeq ($(SOC),$(filter $(SOC),mx7ulp))
 obj-y  += cache.o
diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
new file mode 100644
index 0000000000..457a323fa2
--- /dev/null
+++ b/arch/arm/mach-imx/boot.c
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Microsoft Corporation
+ */
+
+#include <common.h>
+#include <command.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#if defined(CONFIG_UEFI_BOOT)
+unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
+			 char * const argv[])
+{
+	cleanup_before_linux();
+
+	return entry(argc, argv);
+}
+#endif /* CONFIG_UEFI_BOOT */
diff --git a/common/Kconfig b/common/Kconfig
index 4c7a1a9af8..35362b629c 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -217,6 +217,23 @@ config BOOTCOMMAND
 	  This is the string of commands that will be used as bootcmd and if
 	  AUTOBOOT is set, automatically run.
 
+config UEFI_BOOT
+	bool "Boot a UEFI firmware loaded from the first FAT partition on the mmc"
+	default n
+	help
+	  Override the CONFIG_BOOTCOMMAND to load a UEFI firmware image from the
+	  first FAT partition on the mmc. Override the go command to make it disable
+	  interrupts and flush the cache before jumping to the specified address.
+
+config UEFI_LOAD_ADDR
+	hex "Load address for the UEFI image"
+	depends on UEFI_BOOT
+	help
+	  CONFIG_UEFI_BOOT uses this as the address to load the UEFI image.
+	  The uefi_bootcmd script in the environment will fatload efi from the mmc
+	  to this location, then use an overridden go command to disable caches and
+	  interrupts then jump to this location.
+
 menu "Console"
 
 config MENU
diff --git a/include/config_uefi_bootcmd.h b/include/config_uefi_bootcmd.h
new file mode 100644
index 0000000000..03903abf8f
--- /dev/null
+++ b/include/config_uefi_bootcmd.h
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2018 Microsoft Corporation
+ */
+
+#ifndef _CONFIG_UEFI_BOOTCMD_H
+#define _CONFIG_UEFI_BOOTCMD_H
+
+#define BOOTENV \
+	"uefi_image_name=imxboard_efi.fd\0" \
+	"uefi_addr=" __stringify(CONFIG_UEFI_LOAD_ADDR) "\0" \
+	"uefi_bootcmd=" \
+		"part list mmc ${mmcdev} -bootable devplist; " \
+		"env exists devplist || setenv devplist 1; " \
+		"for bootpart in ${devplist}; do " \
+			"if fatload mmc ${mmcdev}:${bootpart} " \
+			"${uefi_addr} ${uefi_image_name}; then " \
+				"echo \"Jumping to ${uefi_image_name} at " \
+				"${uefi_addr}\"; " \
+				"go ${uefi_addr}; " \
+			"fi; " \
+		"done; " \
+		"echo \"Could not find ${uefi_image_name} on mmc ${mmcdev}\";\0"
+
+#ifdef CONFIG_UEFI_BOOT
+#define CONFIG_BOOTCOMMAND "run uefi_bootcmd"
+#endif
+
+#endif  /* _CONFIG_UEFI_BOOTCMD_H */
-- 
2.16.2.gvfs.1.33.gf5370f1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 02/11] arm: Allow U-Boot Proper to run in normal world
  2018-07-14  0:11 [U-Boot] [PATCH 00/11] Enable Windows 10 IoT Core on i.MX6 and i.MX7 Henry Beberman
  2018-07-14  0:11 ` [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc Henry Beberman
  2018-07-14  0:11 ` [U-Boot] [PATCH 03/11] spl: Add FIT boot into OP-TEE then U-Boot proper Henry Beberman
@ 2018-07-14  0:11 ` Henry Beberman
  2018-07-14  0:11 ` [U-Boot] [PATCH 04/11] spl: imx: Add optional lds to keep SPL entirely in on-chip RAM Henry Beberman
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 33+ messages in thread
From: Henry Beberman @ 2018-07-14  0:11 UTC (permalink / raw)
  To: u-boot

From: Henry Beberman <henry.beberman@microsoft.com>

In order to minimize the surface area of secure world code, the i.MX
Windows 10 IoT Core boot flow uses SPL to jump into OP-TEE as soon as
possible. Once OP-TEE has locked down resources it returns into the
entry point U-Boot Proper in normal world.

The CONFIG_SYS_NORMAL_WORLD Kconfig option has been added so that
segments of code with a dependency on secure world are built into SPL
and selectively omitted from the U-Boot Proper built for normal world.
This is only enabled when the CONFIG_SPL_OPTEE_BOOT Kconfig option is
set. CONFIG_SPL_OPTEE_BOOT is added in the next patch in this series.

Signed-off-by: Henry Beberman <henry.beberman@microsoft.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Tom Rini <trini@konsulko.com>
---
 arch/arm/cpu/armv7/Kconfig     |  7 +++++++
 arch/arm/cpu/armv7/start.S     | 11 ++++++-----
 arch/arm/mach-imx/mx7/soc.c    |  7 +++++--
 arch/arm/mach-imx/syscounter.c |  2 ++
 include/configs/mx6_common.h   |  5 +++++
 include/configs/mx7_common.h   |  5 +++++
 6 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/arch/arm/cpu/armv7/Kconfig b/arch/arm/cpu/armv7/Kconfig
index 37a0be932e..21d68ccb67 100644
--- a/arch/arm/cpu/armv7/Kconfig
+++ b/arch/arm/cpu/armv7/Kconfig
@@ -58,4 +58,11 @@ config ARMV7_LPAE
 	Say Y here to use the long descriptor page table format. This is
 	required if U-Boot runs in HYP mode.
 
+config SYS_NORMAL_WORLD
+	bool "An internal build option that tells code that it is running in normal world"
+	default n
+	help
+	  This option is set internally by headers if the code being
+	  compiled must run in normal world.
+
 endif
diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S
index c996525f86..14612fd0fe 100644
--- a/arch/arm/cpu/armv7/start.S
+++ b/arch/arm/cpu/armv7/start.S
@@ -168,30 +168,31 @@ ENTRY(cpu_init_cp15)
 	mcr	p15, 0, r0, c1, c0, 0	@ write system control register
 #endif
 
-#if (defined(CONFIG_ARM_ERRATA_742230) || defined(CONFIG_ARM_ERRATA_794072))
+#if (defined(CONFIG_ARM_ERRATA_742230) || defined(CONFIG_ARM_ERRATA_794072)) \
+	&& !defined(CONFIG_SYS_NORMAL_WORLD)
 	mrc	p15, 0, r0, c15, c0, 1	@ read diagnostic register
 	orr	r0, r0, #1 << 4		@ set bit #4
 	mcr	p15, 0, r0, c15, c0, 1	@ write diagnostic register
 #endif
 
-#ifdef CONFIG_ARM_ERRATA_743622
+#if defined(CONFIG_ARM_ERRATA_743622) && !defined(CONFIG_SYS_NORMAL_WORLD)
 	mrc	p15, 0, r0, c15, c0, 1	@ read diagnostic register
 	orr	r0, r0, #1 << 6		@ set bit #6
 	mcr	p15, 0, r0, c15, c0, 1	@ write diagnostic register
 #endif
 
-#ifdef CONFIG_ARM_ERRATA_751472
+#if defined(CONFIG_ARM_ERRATA_751472) && !defined(CONFIG_SYS_NORMAL_WORLD)
 	mrc	p15, 0, r0, c15, c0, 1	@ read diagnostic register
 	orr	r0, r0, #1 << 11	@ set bit #11
 	mcr	p15, 0, r0, c15, c0, 1	@ write diagnostic register
 #endif
-#ifdef CONFIG_ARM_ERRATA_761320
+#if defined(CONFIG_ARM_ERRATA_761320) && !defined(CONFIG_SYS_NORMAL_WORLD)
 	mrc	p15, 0, r0, c15, c0, 1	@ read diagnostic register
 	orr	r0, r0, #1 << 21	@ set bit #21
 	mcr	p15, 0, r0, c15, c0, 1	@ write diagnostic register
 #endif
 
-#ifdef CONFIG_ARM_ERRATA_845369
+#if defined(CONFIG_ARM_ERRATA_845369) && !defined(CONFIG_SYS_NORMAL_WORLD)
 	mrc     p15, 0, r0, c15, c0, 1	@ read diagnostic register
 	orr     r0, r0, #1 << 22	@ set bit #22
 	mcr     p15, 0, r0, c15, c0, 1	@ write diagnostic register
diff --git a/arch/arm/mach-imx/mx7/soc.c b/arch/arm/mach-imx/mx7/soc.c
index 2aca24bbb0..cc987f2599 100644
--- a/arch/arm/mach-imx/mx7/soc.c
+++ b/arch/arm/mach-imx/mx7/soc.c
@@ -135,7 +135,7 @@ u32 __weak get_board_rev(void)
 #endif
 
 /* enable all periherial can be accessed in nosec mode */
-static void init_csu(void)
+static void __maybe_unused init_csu(void)
 {
 	int i = 0;
 	for (i = 0; i < CSU_NUM_REGS; i++)
@@ -164,7 +164,10 @@ int arch_cpu_init(void)
 {
 	init_aips();
 
+#ifndef CONFIG_SYS_NORMAL_WORLD
 	init_csu();
+#endif
+
 	/* Disable PDE bit of WMCR register */
 	imx_wdog_disable_powerdown();
 
@@ -194,7 +197,7 @@ int arch_misc_init(void)
 		env_set("soc", "imx7s");
 #endif
 
-#ifdef CONFIG_FSL_CAAM
+#if defined(CONFIG_FSL_CAAM) && !defined(CONFIG_SYS_NORMAL_WORLD)
 	sec_init();
 #endif
 
diff --git a/arch/arm/mach-imx/syscounter.c b/arch/arm/mach-imx/syscounter.c
index 676bb3caa9..cfd82236f8 100644
--- a/arch/arm/mach-imx/syscounter.c
+++ b/arch/arm/mach-imx/syscounter.c
@@ -57,6 +57,7 @@ static inline unsigned long long us_to_tick(unsigned long long usec)
 
 int timer_init(void)
 {
+#if !defined(CONFIG_SYS_NORMAL_WORLD)
 	struct sctr_regs *sctr = (struct sctr_regs *)SCTR_BASE_ADDR;
 	unsigned long val, freq;
 
@@ -70,6 +71,7 @@ int timer_init(void)
 	val &= ~(SC_CNTCR_FREQ0 | SC_CNTCR_FREQ1);
 	val |= SC_CNTCR_FREQ0 | SC_CNTCR_ENABLE | SC_CNTCR_HDBG;
 	writel(val, &sctr->cntcr);
+#endif
 
 	gd->arch.tbl = 0;
 	gd->arch.tbu = 0;
diff --git a/include/configs/mx6_common.h b/include/configs/mx6_common.h
index 1b2961f68e..756db4da61 100644
--- a/include/configs/mx6_common.h
+++ b/include/configs/mx6_common.h
@@ -69,4 +69,9 @@
 #endif
 #endif
 
+/* If OPTEE boot is enabled, u-boot proper runs in normal world */
+#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_OPTEE_BOOT)
+#define CONFIG_SYS_NORMAL_WORLD
+#endif
+
 #endif
diff --git a/include/configs/mx7_common.h b/include/configs/mx7_common.h
index b0b7e1edd4..4864df5108 100644
--- a/include/configs/mx7_common.h
+++ b/include/configs/mx7_common.h
@@ -58,4 +58,9 @@
 #endif
 #endif
 
+/* If OPTEE boot is enabled, u-boot proper runs in normal world */
+#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_OPTEE_BOOT)
+#define CONFIG_SYS_NORMAL_WORLD
+#endif
+
 #endif
-- 
2.16.2.gvfs.1.33.gf5370f1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 03/11] spl: Add FIT boot into OP-TEE then U-Boot proper
  2018-07-14  0:11 [U-Boot] [PATCH 00/11] Enable Windows 10 IoT Core on i.MX6 and i.MX7 Henry Beberman
  2018-07-14  0:11 ` [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc Henry Beberman
@ 2018-07-14  0:11 ` Henry Beberman
  2018-07-14  0:11 ` [U-Boot] [PATCH 02/11] arm: Allow U-Boot Proper to run in normal world Henry Beberman
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 33+ messages in thread
From: Henry Beberman @ 2018-07-14  0:11 UTC (permalink / raw)
  To: u-boot

From: Henry Beberman <henry.beberman@microsoft.com>

This patch is a part of the i.MX Windows 10 IoT Core boot flow.

It adds an entry path for OP-TEE when loaded from a FIT blob when
loadable has the OS type IH_OS_TEE. This booth path flushes and
disables caches, disables interrupts, and jumps into OP-TEE passing
the entry point for U-Boot Proper in one of the registers.

The CONFIG_SPL_OPTEE_BOOT option enables this boot path, and is also
used to automatically set the CONFIG_SYS_NORMAL_WORLD Kconfig option
while building U-Boot proper. This is because when OP-TEE returns to
U-Boot proper's entry point, it will be in normal mode, so several
secure world only initializations need to be omitted.

New Kconfig option:
CONFIG_SPL_OPTEE_BOOT - Enables SPL FIT to boot in to OP-TEE, and will
set the CONFIG_SYS_NORMAL_WORLD in U-Boot Proper to omit secure world
only code.

Signed-off-by: Henry Beberman <henry.beberman@microsoft.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Tom Rini <trini@konsulko.com>
---
 arch/arm/cpu/armv7/Makefile     |  1 +
 arch/arm/cpu/armv7/optee_jump.S | 31 +++++++++++++++++++++++++++++++
 arch/arm/lib/spl.c              | 16 ++++++++++++++++
 common/spl/Kconfig              |  9 +++++++++
 common/spl/spl.c                |  6 ++++++
 include/spl.h                   | 21 +++++++++++++++++++++
 6 files changed, 84 insertions(+)
 create mode 100644 arch/arm/cpu/armv7/optee_jump.S

diff --git a/arch/arm/cpu/armv7/Makefile b/arch/arm/cpu/armv7/Makefile
index 4f4647c90a..5bad36a8b8 100644
--- a/arch/arm/cpu/armv7/Makefile
+++ b/arch/arm/cpu/armv7/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_ARMV7_PSCI)	+= psci.o psci-common.o
 obj-$(CONFIG_IPROC) += iproc-common/
 obj-$(CONFIG_KONA) += kona-common/
 obj-$(CONFIG_SYS_ARCH_TIMER) += arch_timer.o
+obj-$(CONFIG_SPL_OPTEE_BOOT) += optee_jump.o
 
 ifneq (,$(filter s5pc1xx exynos,$(SOC)))
 obj-y += s5p-common/
diff --git a/arch/arm/cpu/armv7/optee_jump.S b/arch/arm/cpu/armv7/optee_jump.S
new file mode 100644
index 0000000000..2a1d994bcc
--- /dev/null
+++ b/arch/arm/cpu/armv7/optee_jump.S
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2018 Microsoft Corporation
+ */
+
+#include <asm-offsets.h>
+#include <config.h>
+#include <asm/system.h>
+#include <linux/linkage.h>
+
+#ifdef CONFIG_SPL_OPTEE_BOOT
+
+	.globl arch_jump_to_image_optee
+
+/*
+ void __noreturn arch_jump_to_image_optee(
+	u32 optee_entry_point,
+	u32 pageable_part,
+	u32 uboot_entry_point
+	);
+*/
+ENTRY(arch_jump_to_image_optee)
+
+	mov r3, r0
+	mov r0, r1
+	mov lr, r2
+
+	bx r3
+
+ENDPROC(arch_jump_to_image_optee)
+#endif
diff --git a/arch/arm/lib/spl.c b/arch/arm/lib/spl.c
index 33cc76ba3d..ee311d9fe8 100644
--- a/arch/arm/lib/spl.c
+++ b/arch/arm/lib/spl.c
@@ -73,3 +73,19 @@ void __noreturn jump_to_image_linux(struct spl_image_info *spl_image)
 }
 #endif	/* CONFIG_ARM64 */
 #endif
+
+#ifdef CONFIG_SPL_OPTEE_BOOT
+void __noreturn arch_jump_to_image_optee(u32 optee_entry_point,
+					 u32 pageable_part,
+					 u32 uboot_entry_point);
+
+void __noreturn jump_to_image_optee(struct spl_image_info *spl_image)
+{
+	/* flush and turn off caches before jumping to OPTEE */
+	cleanup_before_linux();
+
+	arch_jump_to_image_optee(spl_image->entry_point,
+				 0,
+				 CONFIG_SYS_TEXT_BASE);
+}
+#endif
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 0bbf8d5b02..643484a4a4 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -792,6 +792,15 @@ config SPL_ATF_NO_PLATFORM_PARAM
 
 	  If your ATF is affected, say Y.
 
+config SPL_OPTEE_BOOT
+	depends on SPL
+	bool "Enable support for loading OPTEE and jumping to it from SPL"
+	default n
+	help
+	  Configure SPL to boot OPTEE. SPL passes the U-Boot proper entry
+	  point as the return address when it jumps to OPTEE, allowing OPTEE
+	  to start U-Boot proper in normal mode when it returns.
+
 config SPL_AM33XX_ENABLE_RTC32K_OSC
 	bool "Enable the RTC32K OSC on AM33xx based platforms"
 	default y if AM33XX
diff --git a/common/spl/spl.c b/common/spl/spl.c
index a09ada37d7..237083b08d 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -519,6 +519,12 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 		spl_invoke_atf(&spl_image);
 		break;
 #endif
+#ifdef CONFIG_SPL_OPTEE_BOOT
+	case IH_OS_TEE:
+		debug("Jumping to OPTEE\n");
+		jump_to_image_optee(&spl_image);
+		break;
+#endif
 #ifdef CONFIG_SPL_OS_BOOT
 	case IH_OS_LINUX:
 		debug("Jumping to Linux\n");
diff --git a/include/spl.h b/include/spl.h
index 8454ea7ad4..338b4b573d 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -125,6 +125,19 @@ int spl_board_ubi_load_image(u32 boot_device);
  */
 void __noreturn jump_to_image_linux(struct spl_image_info *spl_image);
 
+#ifdef CONFIG_SPL_OPTEE_BOOT
+/**
+ * jump_to_image_optee() - Jump to OP-TEE from SPL
+ *
+ * This jumps into OP-TEE using the information in @spl_image, passing
+ *  it the entry point of U-Boot Proper so it can return there
+ *  in non-secure mode
+ *
+ * @spl_image: Image description to set up
+ */
+void __noreturn jump_to_image_optee(struct spl_image_info *spl_image);
+#endif
+
 /**
  * spl_start_uboot() - Check if SPL should start the kernel or U-Boot
  *
@@ -296,4 +309,12 @@ void spl_invoke_atf(struct spl_image_info *spl_image);
  * can implement 'board_return_to_bootrom'.
  */
 void board_return_to_bootrom(void);
+
+#ifdef CONFIG_SPL_OPTEE_BOOT
+#include <tee/optee.h>
+
+struct optee_image_info {
+	struct optee_header header;
+};
+#endif
 #endif
-- 
2.16.2.gvfs.1.33.gf5370f1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 04/11] spl: imx: Add optional lds to keep SPL entirely in on-chip RAM
  2018-07-14  0:11 [U-Boot] [PATCH 00/11] Enable Windows 10 IoT Core on i.MX6 and i.MX7 Henry Beberman
                   ` (2 preceding siblings ...)
  2018-07-14  0:11 ` [U-Boot] [PATCH 02/11] arm: Allow U-Boot Proper to run in normal world Henry Beberman
@ 2018-07-14  0:11 ` Henry Beberman
  2018-07-16 17:32   ` Trent Piepho
  2018-08-07 12:17   ` Stefano Babic
  2018-07-14  0:11 ` [U-Boot] [PATCH 05/11] mx6sabresd: Add Windows boot support for iMX6 Sabre Henry Beberman
                   ` (6 subsequent siblings)
  10 siblings, 2 replies; 33+ messages in thread
From: Henry Beberman @ 2018-07-14  0:11 UTC (permalink / raw)
  To: u-boot

From: Henry Beberman <henry.beberman@microsoft.com>

This patch is part of the i.MX Windows 10 IoT Core boot flow.

It adds a modified linker script for SPL to keep all segments in
on-chip ram. This is to harden the device against potential leaks of
device secrets by keeping them out of DRAM.

Additionally if CONFIG_SYS_SPL_MALLOC_START is defined, it will
override the CONFIG_SPL_SYS_MALLOC_SIMPLE and allocate space in DRAM
instead of on-chip ram. This patch prevents the definition of those
values for i.MX6 and i.MX7 SPL if CONFIG_OPTEE_SPL_BOOT is selected.

Signed-off-by: Henry Beberman <henry.beberman@microsoft.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
---
 arch/arm/mach-imx/u-boot-spl-sram.lds | 59 +++++++++++++++++++++++++++++++++++
 include/configs/imx6_spl.h            |  2 ++
 include/configs/imx7_spl.h            |  2 ++
 3 files changed, 63 insertions(+)
 create mode 100644 arch/arm/mach-imx/u-boot-spl-sram.lds

diff --git a/arch/arm/mach-imx/u-boot-spl-sram.lds b/arch/arm/mach-imx/u-boot-spl-sram.lds
new file mode 100644
index 0000000000..dfbb4aef5d
--- /dev/null
+++ b/arch/arm/mach-imx/u-boot-spl-sram.lds
@@ -0,0 +1,59 @@
+/*
+ * (C) Copyright 2002
+ * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
+ *
+ * (C) Copyright 2010
+ * Texas Instruments, <www.ti.com>
+ *	Aneesh V <aneesh@ti.com>
+ *
+ * (C) Copyright 2018 Microsoft Corporation
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE,\
+		LENGTH = CONFIG_SPL_MAX_SIZE }
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+	.text      :
+	{
+		__start = .;
+		*(.vectors)
+		arch/arm/cpu/armv7/start.o	(.text*)
+		*(.text*)
+	} >.sram
+
+	. = ALIGN(4);
+	.rodata : { *(SORT_BY_ALIGNMENT(.rodata*)) } >.sram
+
+	. = ALIGN(4);
+	.data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram
+
+	. = ALIGN(4);
+	.u_boot_list : {
+		KEEP(*(SORT(.u_boot_list*)));
+	} >.sram
+
+	. = ALIGN(4);
+	__image_copy_end = .;
+
+	.end :
+	{
+		*(.__end)
+	}
+
+	_image_binary_end = .;
+
+	.bss :
+	{
+		. = ALIGN(4);
+		__bss_start = .;
+		*(.bss*)
+		. = ALIGN(4);
+		__bss_end = .;
+	} >.sram
+}
diff --git a/include/configs/imx6_spl.h b/include/configs/imx6_spl.h
index 720ff045a7..4088e8a936 100644
--- a/include/configs/imx6_spl.h
+++ b/include/configs/imx6_spl.h
@@ -51,6 +51,7 @@
 # endif
 #endif
 
+#ifndef CONFIG_OPTEE_SPL_BOOT
 #if defined(CONFIG_MX6SX) || defined(CONFIG_MX6SL) || \
 	defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL)
 #define CONFIG_SPL_BSS_START_ADDR      0x88200000
@@ -63,6 +64,7 @@
 #define CONFIG_SYS_SPL_MALLOC_START	0x18300000
 #define CONFIG_SYS_SPL_MALLOC_SIZE	0x100000	/* 1 MB */
 #endif
+#endif /* !CONFIG_OPTEE_SPL_BOOT */
 #endif
 
 #endif
diff --git a/include/configs/imx7_spl.h b/include/configs/imx7_spl.h
index 1eb6cd894d..5dd4aed652 100644
--- a/include/configs/imx7_spl.h
+++ b/include/configs/imx7_spl.h
@@ -46,10 +46,12 @@
 # endif
 #endif
 
+#ifndef CONFIG_OPTEE_SPL_BOOT
 #define CONFIG_SPL_BSS_START_ADDR      0x88200000
 #define CONFIG_SPL_BSS_MAX_SIZE        0x100000		/* 1 MB */
 #define CONFIG_SYS_SPL_MALLOC_START    0x88300000
 #define CONFIG_SYS_SPL_MALLOC_SIZE     0x100000		/* 1 MB */
+#endif /* !CONFIG_OPTEE_SPL_BOOT */
 
 #endif /* CONFIG_SPL */
 
-- 
2.16.2.gvfs.1.33.gf5370f1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 05/11] mx6sabresd: Add Windows boot support for iMX6 Sabre
  2018-07-14  0:11 [U-Boot] [PATCH 00/11] Enable Windows 10 IoT Core on i.MX6 and i.MX7 Henry Beberman
                   ` (3 preceding siblings ...)
  2018-07-14  0:11 ` [U-Boot] [PATCH 04/11] spl: imx: Add optional lds to keep SPL entirely in on-chip RAM Henry Beberman
@ 2018-07-14  0:11 ` Henry Beberman
  2018-07-14  0:11 ` [U-Boot] [PATCH 07/11] mx6cuboxi: Add Windows boot support for mx6cuboxi Henry Beberman
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 33+ messages in thread
From: Henry Beberman @ 2018-07-14  0:11 UTC (permalink / raw)
  To: u-boot

From: Henry Beberman <henry.beberman@microsoft.com>

This patch adds a new bootable configuration for Windows 10 IoT Core on
the i.MX6 Quad Sabre board.

Add a new device tree sources file for imx6qdl-sdb. This is not
required by Windows or UEFI but the build system requires a device
tree when building SPL with flat image tree support.

Signed-off-by: Henry Beberman <henry.beberman@microsoft.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
---
 arch/arm/dts/Makefile                   |  1 +
 arch/arm/dts/imx6qdl-sdb.dts            |  8 +++++
 board/freescale/mx6sabresd/MAINTAINERS  |  2 ++
 board/freescale/mx6sabresd/mx6sabresd.c |  9 ++++-
 configs/mx6sabresd_nt_defconfig         | 58 +++++++++++++++++++++++++++++++++
 include/configs/mx6sabre_common.h       | 10 ++++++
 6 files changed, 87 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/imx6qdl-sdb.dts
 create mode 100644 configs/mx6sabresd_nt_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index baad87d4d7..7d90bd39f3 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -410,6 +410,7 @@ dtb-$(CONFIG_MX6QDL) += \
 	imx6dl-icore-mipi.dtb \
 	imx6dl-icore-rqs.dtb \
 	imx6dl-mamoj.dtb \
+	imx6qdl-sdb.dtb \
 	imx6q-cm-fx6.dtb \
 	imx6q-icore.dtb \
 	imx6q-icore-mipi.dtb \
diff --git a/arch/arm/dts/imx6qdl-sdb.dts b/arch/arm/dts/imx6qdl-sdb.dts
new file mode 100644
index 0000000000..907f44859f
--- /dev/null
+++ b/arch/arm/dts/imx6qdl-sdb.dts
@@ -0,0 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Microsoft Corporation
+ */
+
+/dts-v1/;
+
+#include "imx6q.dtsi"
diff --git a/board/freescale/mx6sabresd/MAINTAINERS b/board/freescale/mx6sabresd/MAINTAINERS
index 95752619e7..bc747e7d2a 100644
--- a/board/freescale/mx6sabresd/MAINTAINERS
+++ b/board/freescale/mx6sabresd/MAINTAINERS
@@ -4,3 +4,5 @@ S:	Maintained
 F:	board/freescale/mx6sabresd/
 F:	include/configs/mx6sabresd.h
 F:	configs/mx6sabresd_defconfig
+F:	configs/mx6sabresd_nt_defconfig
+F:	arch/arm/dts/imx6qdl-sdb.dts
diff --git a/board/freescale/mx6sabresd/mx6sabresd.c b/board/freescale/mx6sabresd/mx6sabresd.c
index 0183ede148..9eae7140cf 100644
--- a/board/freescale/mx6sabresd/mx6sabresd.c
+++ b/board/freescale/mx6sabresd/mx6sabresd.c
@@ -229,7 +229,14 @@ static struct i2c_pads_info mx6dl_i2c_pad_info1 = {
 	}
 };
 
-static void setup_spi(void)
+#if defined(CONFIG_MULTI_DTB_FIT) || defined(CONFIG_SPL_LOAD_FIT)
+int board_fit_config_name_match(const char *name)
+{
+	return 0;
+}
+#endif
+
+static void __maybe_unused setup_spi(void)
 {
 	SETUP_IOMUX_PADS(ecspi1_pads);
 }
diff --git a/configs/mx6sabresd_nt_defconfig b/configs/mx6sabresd_nt_defconfig
new file mode 100644
index 0000000000..9d858a4418
--- /dev/null
+++ b/configs/mx6sabresd_nt_defconfig
@@ -0,0 +1,58 @@
+CONFIG_ARCH_MX6=y
+CONFIG_ARM=y
+CONFIG_SYS_TEXT_BASE=0x17800000
+CONFIG_TARGET_MX6SABRESD=y
+CONFIG_DEFAULT_DEVICE_TREE="imx6qdl-sdb"
+CONFIG_OF_CONTROL=y
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_SPL_OPTEE_BOOT=y
+CONFIG_BOOTDELAY=-2
+CONFIG_UEFI_BOOT=y
+CONFIG_UEFI_LOAD_ADDR=0x10820000
+CONFIG_EFI_LOADER=n
+CONFIG_CMD_BOOTD=n
+CONFIG_CMD_BOOTM=n
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_FAT=y
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_GPIO=n
+CONFIG_CMD_I2C=y
+# CONFIG_CMD_IMLS is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_PART=y
+CONFIG_CMD_PCI=y
+CONFIG_CMD_SPL=n
+CONFIG_CMD_USB=y
+CONFIG_HUSH_PARSER=y
+CONFIG_CONS_INDEX=1
+CONFIG_SECURE_BOOT=y
+CONFIG_FSL_ESDHC=y
+CONFIG_SPI_FLASH=n
+CONFIG_SPI_FLASH_STMICRO=n
+CONFIG_SPL=y
+CONFIG_SPL_FIT=y
+CONFIG_SPL_LOAD_FIT=y
+CONFIG_SPL_LEGACY_IMAGE_SUPPORT=n
+CONFIG_SPL_OF_LIBFDT=y
+CONFIG_SPL_DM=n
+CONFIG_SPL_SYS_MALLOC_SIMPLE=y
+CONFIG_SPL_CRYPTO_SUPPORT=y
+CONFIG_SPL_GPIO_SUPPORT=y
+CONFIG_SPL_LIBCOMMON_SUPPORT=y
+CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_SPL_MMC_SUPPORT=y
+CONFIG_SPL_SERIAL_SUPPORT=y
+CONFIG_SPL_USE_ARCH_MEMCPY=n
+CONFIG_SPL_WATCHDOG_SUPPORT=y
+CONFIG_SPL_LDSCRIPT="arch/arm/mach-imx/u-boot-spl-sram.lds"
+CONFIG_SYS_DCACHE_OFF=n
+CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg"
+CONFIG_SYS_ICACHE_OFF=n
+CONFIG_SYS_L2CACHE_OFF=y
+CONFIG_SYS_MALLOC_F_LEN=0x800
+CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
+CONFIG_USB=y
+CONFIG_USE_TINY_PRINTF=y
+CONFIG_VIDEO=y
+CONFIG_OF_LIBFDT=y
\ No newline at end of file
diff --git a/include/configs/mx6sabre_common.h b/include/configs/mx6sabre_common.h
index 99ecc412a6..56186f323c 100644
--- a/include/configs/mx6sabre_common.h
+++ b/include/configs/mx6sabre_common.h
@@ -56,6 +56,15 @@
 #define EMMC_ENV ""
 #endif
 
+#ifdef CONFIG_UEFI_BOOT
+#include <config_uefi_bootcmd.h>
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	"mmcdev=1\0" \
+	BOOTENV
+
+#else
+
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	"script=boot.scr\0" \
 	"image=zImage\0" \
@@ -166,6 +175,7 @@
 			"fi; " \
 		"fi; " \
 	"else run netboot; fi"
+#endif /* CONFIG_UEFI_BOOT */
 
 #define CONFIG_ARP_TIMEOUT     200UL
 
-- 
2.16.2.gvfs.1.33.gf5370f1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 06/11] mx7dsabresd: Add Windows boot support for iMX7 Sabre
  2018-07-14  0:11 [U-Boot] [PATCH 00/11] Enable Windows 10 IoT Core on i.MX6 and i.MX7 Henry Beberman
                   ` (5 preceding siblings ...)
  2018-07-14  0:11 ` [U-Boot] [PATCH 07/11] mx6cuboxi: Add Windows boot support for mx6cuboxi Henry Beberman
@ 2018-07-14  0:11 ` Henry Beberman
  2018-07-16 18:22   ` Trent Piepho
  2018-07-14  0:11 ` [U-Boot] [PATCH 08/11] udoo_neo: Add Windows boot support for UDOO Neo Henry Beberman
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 33+ messages in thread
From: Henry Beberman @ 2018-07-14  0:11 UTC (permalink / raw)
  To: u-boot

From: Henry Beberman <henry.beberman@microsoft.com>

This patch adds a new bootable configuration for Windows 10 IoT Core on
the i.MX7 Dual Sabre board.

It enables SPL on the i.MX7 Sabre in order to support the FIT load of
OP-TEE and U-Boot proper.

Signed-off-by: Henry Beberman <henry.beberman@microsoft.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Adrian Alonso <adrian.alonso@nxp.com>
---
 arch/arm/mach-imx/mx7/Kconfig             |   1 +
 board/freescale/mx7dsabresd/MAINTAINERS   |   1 +
 board/freescale/mx7dsabresd/mx7dsabresd.c |  79 +++++++++++++++++++++++
 configs/mx7dsabresd_nt_defconfig          | 102 ++++++++++++++++++++++++++++++
 drivers/gpio/Makefile                     |   3 +
 drivers/pinctrl/nxp/pinctrl-imx7.c        |   4 +-
 include/configs/mx7dsabresd.h             |  10 +++
 7 files changed, 199 insertions(+), 1 deletion(-)
 create mode 100644 configs/mx7dsabresd_nt_defconfig

diff --git a/arch/arm/mach-imx/mx7/Kconfig b/arch/arm/mach-imx/mx7/Kconfig
index 2a3db860bb..0aaf246a79 100644
--- a/arch/arm/mach-imx/mx7/Kconfig
+++ b/arch/arm/mach-imx/mx7/Kconfig
@@ -33,6 +33,7 @@ config TARGET_MX7DSABRESD
 	select MX7D
 	select DM
 	select DM_THERMAL
+	select SUPPORT_SPL
 
 config TARGET_PICO_IMX7D
 	bool "pico-imx7d"
diff --git a/board/freescale/mx7dsabresd/MAINTAINERS b/board/freescale/mx7dsabresd/MAINTAINERS
index b96642a568..1fc9b2a491 100644
--- a/board/freescale/mx7dsabresd/MAINTAINERS
+++ b/board/freescale/mx7dsabresd/MAINTAINERS
@@ -4,3 +4,4 @@ S:	Maintained
 F:	board/freescale/mx7dsabresd
 F:	include/configs/mx7dsabresd.h
 F:	configs/mx7dsabresd_defconfig
+F:	configs/mx7dsabresd_nt_defconfig
\ No newline at end of file
diff --git a/board/freescale/mx7dsabresd/mx7dsabresd.c b/board/freescale/mx7dsabresd/mx7dsabresd.c
index 90e2d1a92a..db34609caf 100644
--- a/board/freescale/mx7dsabresd/mx7dsabresd.c
+++ b/board/freescale/mx7dsabresd/mx7dsabresd.c
@@ -46,6 +46,9 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #define NAND_PAD_READY0_CTRL (PAD_CTL_DSE_3P3V_49OHM | PAD_CTL_PUS_PU5KOHM)
 
+#define USDHC_PAD_CTRL (PAD_CTL_DSE_3P3V_32OHM | PAD_CTL_SRE_SLOW | \
+			PAD_CTL_HYS | PAD_CTL_PUE | PAD_CTL_PUS_PU47KOHM)
+
 #ifdef CONFIG_MXC_SPI
 static iomux_v3_cfg_t const ecspi3_pads[] = {
     MX7D_PAD_SAI2_RX_DATA__ECSPI3_SCLK | MUX_PAD_CTRL(SPI_PAD_CTRL),
@@ -363,6 +366,75 @@ int power_init_board(void)
 }
 #endif
 
+#ifdef CONFIG_SPL_BUILD
+#include <spl.h>
+
+#if !CONFIG_IS_ENABLED(DM_MMC)
+static iomux_v3_cfg_t const usdhc1_pads[] = {
+	MX7D_PAD_SD1_CLK__SD1_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+	MX7D_PAD_SD1_CMD__SD1_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+	MX7D_PAD_SD1_DATA0__SD1_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+	MX7D_PAD_SD1_DATA1__SD1_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+	MX7D_PAD_SD1_DATA2__SD1_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+	MX7D_PAD_SD1_DATA3__SD1_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+
+	MX7D_PAD_SD1_CD_B__GPIO5_IO0 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+	MX7D_PAD_SD1_WP__GPIO5_IO1 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+	MX7D_PAD_SD1_RESET_B__SD1_RESET_B | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+};
+
+#define USDHC1_CD IMX_GPIO_NR(5, 0)
+#define USDHC1_WP IMX_GPIO_NR(5, 1)
+
+int board_mmc_init(bd_t *bis)
+{
+	struct fsl_esdhc_cfg usdhc_cfg = {};
+
+	imx_iomux_v3_setup_multiple_pads(usdhc1_pads, ARRAY_SIZE(usdhc1_pads));
+	gpio_direction_input(USDHC1_CD);
+	gpio_direction_input(USDHC1_WP);
+
+	usdhc_cfg.esdhc_base = USDHC1_BASE_ADDR;
+	usdhc_cfg.sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
+	usdhc_cfg.max_bus_width = 4;
+
+	return fsl_esdhc_initialize(bis, &usdhc_cfg);
+}
+
+int board_mmc_getcd(struct mmc *mmc)
+{
+	struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
+	int ret = 0;
+
+	switch (cfg->esdhc_base) {
+	case USDHC1_BASE_ADDR:
+		ret = !gpio_get_value(USDHC1_CD);
+		break;
+	}
+
+	return ret;
+}
+#endif
+
+void board_init_f(ulong dummy)
+{
+	/* Clear the BSS. */
+	memset(__bss_start, 0, __bss_end - __bss_start);
+
+	setup_iomux_uart();
+
+	/* setup AIPS and disable watchdog */
+	arch_cpu_init();
+
+	/* setup GP timer */
+	timer_init();
+
+	preloader_console_init();
+
+	/* No need to initialize DRAM; handled by DCD script */
+}
+#endif
+
 int board_late_init(void)
 {
 	struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR;
@@ -393,3 +465,10 @@ int checkboard(void)
 
 	return 0;
 }
+
+#if defined(CONFIG_MULTI_DTB_FIT) || defined(CONFIG_SPL_LOAD_FIT)
+int board_fit_config_name_match(const char *name)
+{
+	return 0;
+}
+#endif
diff --git a/configs/mx7dsabresd_nt_defconfig b/configs/mx7dsabresd_nt_defconfig
new file mode 100644
index 0000000000..9bb0fe1b54
--- /dev/null
+++ b/configs/mx7dsabresd_nt_defconfig
@@ -0,0 +1,102 @@
+CONFIG_ARM=y
+CONFIG_ARCH_MX7=y
+CONFIG_SYS_THUMB_BUILD=y
+CONFIG_SYS_TEXT_BASE=0x87800000
+CONFIG_TARGET_MX7DSABRESD=y
+CONFIG_DEFAULT_DEVICE_TREE="imx7d-sdb"
+CONFIG_OF_CONTROL=y
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_SPL_OPTEE_BOOT=y
+CONFIG_ARMV7_BOOT_SEC_DEFAULT=y
+CONFIG_ARMV7_NONSEC=n
+# CONFIG_ARMV7_VIRT is not set
+CONFIG_BAUDRATE=115200
+CONFIG_BOOTDELAY=-2
+CONFIG_UEFI_BOOT=y
+CONFIG_UEFI_LOAD_ADDR=0x82004000
+# CONFIG_CMD_BMODE is not set
+# CONFIG_CMD_BOOTD is not set
+CONFIG_CMD_BOOTM=y
+CONFIG_CMD_BOOTZ=n
+# CONFIG_CMD_IMI is not set
+# CONFIG_CMD_XIMG is not set
+# CONFIG_CMD_EXPORTENV is not set
+# CONFIG_CMD_IMPORTENV is not set
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_BMP=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_PMIC=y
+CONFIG_CMD_REGULATOR=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_PART=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_CMD_SF=y
+# CONFIG_CONSOLE_MUX is not set
+CONFIG_SYS_CONSOLE_IS_IN_ENV=y
+CONFIG_DEBUG_UART_MXC=y
+CONFIG_DEBUG_UART_CLOCK=24000000
+CONFIG_DEBUG_UART_BASE=0x30860000
+CONFIG_SPI=y
+CONFIG_DM_74X164=y
+CONFIG_DM_GPIO=y
+CONFIG_DM_I2C=y
+CONFIG_DM_MMC=y
+CONFIG_DM_PMIC_PFUZE100=y
+CONFIG_DM_PMIC=y
+CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_REGULATOR_PFUZE100=y
+CONFIG_DM_REGULATOR=y
+CONFIG_DM_SERIAL=n
+CONFIG_DM_SPI=y
+CONFIG_DM_USB=y
+CONFIG_ERRNO_STR=y
+CONFIG_HUSH_PARSER=y
+CONFIG_IMX_BOOTAUX=y
+CONFIG_IMX_RDC=y
+CONFIG_MXC_USB_OTG_HACTIVE=y
+CONFIG_PHYLIB=y
+CONFIG_PINCTRL_IMX7=y
+CONFIG_PINCTRL=y
+CONFIG_SECURE_BOOT=y
+CONFIG_SPL_SYS_MALLOC_SIMPLE=y
+CONFIG_SOFT_SPI=y
+CONFIG_FSL_ESDHC=y
+CONFIG_SPI_FLASH_EON=y
+CONFIG_SPI_FLASH=y
+CONFIG_EFI_LOADER=n
+CONFIG_SPL=y
+CONFIG_SPL_LOAD_FIT=y
+CONFIG_SPL_LEGACY_IMAGE_SUPPORT=n
+CONFIG_SPL_DM=n
+CONFIG_SPL_FIT=y
+CONFIG_SPL_OF_LIBFDT=y
+CONFIG_SPL_DM_SERIAL=n
+CONFIG_SPL_GPIO_SUPPORT=y
+CONFIG_SPL_LIBCOMMON_SUPPORT=y
+CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_SPL_MMC_SUPPORT=y
+CONFIG_SPL_SERIAL_SUPPORT=y
+CONFIG_USE_TINY_PRINTF=y
+CONFIG_SPL_USE_ARCH_MEMCPY=n
+CONFIG_SPL_WATCHDOG_SUPPORT=y
+CONFIG_ENV_IS_IN_MMC=n
+CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx7dsabresd/imximage.cfg"
+CONFIG_SYS_MALLOC_F_LEN=0x0800
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x8A
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
+CONFIG_USB_FUNCTION_MASS_STORAGE=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_KEYBOARD=y
+CONFIG_USB_STORAGE=y
+CONFIG_USB=y
+CONFIG_VIDEO_MXS=y
+CONFIG_VIDEO=y
+CONFIG_GLOBAL_PAGE=y
+CONFIG_STORE_MAC_IN_GLOBAL=y
+CONFIG_ETH1ADDR_IN_GLOBAL=y
+CONFIG_OF_LIBFDT=y
\ No newline at end of file
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index f186120684..3fb9b72703 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -7,10 +7,13 @@ ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_DWAPB_GPIO)	+= dwapb_gpio.o
 obj-$(CONFIG_AXP_GPIO)		+= axp_gpio.o
 endif
+
+ifeq ($(CONFIG_$(SPL_TPL_)DM),y)
 obj-$(CONFIG_DM_GPIO)		+= gpio-uclass.o
 
 obj-$(CONFIG_DM_PCA953X)	+= pca953x_gpio.o
 obj-$(CONFIG_DM_74X164)		+= 74x164_gpio.o
+endif
 
 obj-$(CONFIG_AT91_GPIO)	+= at91_gpio.o
 obj-$(CONFIG_ATMEL_PIO4)	+= atmel_pio4.o
diff --git a/drivers/pinctrl/nxp/pinctrl-imx7.c b/drivers/pinctrl/nxp/pinctrl-imx7.c
index 769d428dda..7ba97bae0d 100644
--- a/drivers/pinctrl/nxp/pinctrl-imx7.c
+++ b/drivers/pinctrl/nxp/pinctrl-imx7.c
@@ -9,7 +9,9 @@
 
 #include "pinctrl-imx.h"
 
-static struct imx_pinctrl_soc_info imx7_pinctrl_soc_info;
+static struct imx_pinctrl_soc_info imx7_pinctrl_soc_info = {
+	.flags = ZERO_OFFSET_VALID,
+};
 
 static struct imx_pinctrl_soc_info imx7_lpsr_pinctrl_soc_info = {
 	.flags = ZERO_OFFSET_VALID,
diff --git a/include/configs/mx7dsabresd.h b/include/configs/mx7dsabresd.h
index 87d2b52ef1..a6793927ef 100644
--- a/include/configs/mx7dsabresd.h
+++ b/include/configs/mx7dsabresd.h
@@ -9,6 +9,7 @@
 #define __MX7D_SABRESD_CONFIG_H
 
 #include "mx7_common.h"
+#include "imx7_spl.h"
 
 #define CONFIG_DBG_MONITOR
 #define PHYS_SDRAM_SIZE			SZ_1G
@@ -65,6 +66,14 @@
 #define UPDATE_M4_ENV ""
 #endif
 
+#ifdef CONFIG_UEFI_BOOT
+#include <config_uefi_bootcmd.h>
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	"mmcdev=0\0" \
+	"console=ttymxc0\0" \
+	BOOTENV
+#else
 #define CONFIG_MFG_ENV_SETTINGS \
 	"mfgtool_args=setenv bootargs console=${console},${baudrate} " \
 		"rdinit=/linuxrc " \
@@ -161,6 +170,7 @@
 			   "fi; " \
 		   "fi; " \
 	   "else run netboot; fi"
+#endif /* CONFIG_UEFI_BOOT */
 
 #define CONFIG_SYS_MEMTEST_START	0x80000000
 #define CONFIG_SYS_MEMTEST_END		(CONFIG_SYS_MEMTEST_START + 0x20000000)
-- 
2.16.2.gvfs.1.33.gf5370f1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 07/11] mx6cuboxi: Add Windows boot support for mx6cuboxi
  2018-07-14  0:11 [U-Boot] [PATCH 00/11] Enable Windows 10 IoT Core on i.MX6 and i.MX7 Henry Beberman
                   ` (4 preceding siblings ...)
  2018-07-14  0:11 ` [U-Boot] [PATCH 05/11] mx6sabresd: Add Windows boot support for iMX6 Sabre Henry Beberman
@ 2018-07-14  0:11 ` Henry Beberman
  2018-07-14  0:11 ` [U-Boot] [PATCH 06/11] mx7dsabresd: Add Windows boot support for iMX7 Sabre Henry Beberman
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 33+ messages in thread
From: Henry Beberman @ 2018-07-14  0:11 UTC (permalink / raw)
  To: u-boot

From: Henry Beberman <henry.beberman@microsoft.com>

This patch adds a new bootable configuration for Windows 10 IoT Core on
the i.MX6 Quad HummingBoard.

It also adds a new device tree sources file for imx6qdl-mx6cuboxi.dts.
This is not required by Windows or UEFI but the build system requires a
device tree when building SPL with flat image tree support.

Signed-off-by: Henry Beberman <henry.beberman@microsoft.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Jon Nettleton <jon@solid-run.com>
---
 arch/arm/dts/Makefile                |  1 +
 arch/arm/dts/imx6qdl-mx6cuboxi.dts   |  8 +++++
 board/solidrun/mx6cuboxi/MAINTAINERS |  2 ++
 board/solidrun/mx6cuboxi/mx6cuboxi.c |  7 ++++
 configs/mx6cuboxi_nt_defconfig       | 62 ++++++++++++++++++++++++++++++++++++
 include/configs/mx6cuboxi.h          |  8 +++++
 6 files changed, 88 insertions(+)
 create mode 100644 arch/arm/dts/imx6qdl-mx6cuboxi.dts
 create mode 100644 configs/mx6cuboxi_nt_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 7d90bd39f3..109a00219d 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -411,6 +411,7 @@ dtb-$(CONFIG_MX6QDL) += \
 	imx6dl-icore-rqs.dtb \
 	imx6dl-mamoj.dtb \
 	imx6qdl-sdb.dtb \
+	imx6qdl-mx6cuboxi.dtb \
 	imx6q-cm-fx6.dtb \
 	imx6q-icore.dtb \
 	imx6q-icore-mipi.dtb \
diff --git a/arch/arm/dts/imx6qdl-mx6cuboxi.dts b/arch/arm/dts/imx6qdl-mx6cuboxi.dts
new file mode 100644
index 0000000000..907f44859f
--- /dev/null
+++ b/arch/arm/dts/imx6qdl-mx6cuboxi.dts
@@ -0,0 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Microsoft Corporation
+ */
+
+/dts-v1/;
+
+#include "imx6q.dtsi"
diff --git a/board/solidrun/mx6cuboxi/MAINTAINERS b/board/solidrun/mx6cuboxi/MAINTAINERS
index 81f82bc9b5..1e4ed35d36 100644
--- a/board/solidrun/mx6cuboxi/MAINTAINERS
+++ b/board/solidrun/mx6cuboxi/MAINTAINERS
@@ -4,3 +4,5 @@ S:	Maintained
 F:	board/solidrun/mx6cuboxi/
 F:	include/configs/mx6cuboxi.h
 F:	configs/mx6cuboxi_defconfig
+F:	configs/mx6cuboxi_nt_defconfig
+F:	arch/arm/dts/imx6qdl-mx6cuboxi.dts
diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
index 38d89f0130..bc423c3a86 100644
--- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
+++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
@@ -143,6 +143,13 @@ static iomux_v3_cfg_t const usb_pads[] = {
 	IOMUX_PADS(PAD_GPIO_0__GPIO1_IO00 | MUX_PAD_CTRL(NO_PAD_CTRL)),
 };
 
+#if defined(CONFIG_MULTI_DTB_FIT) || defined(CONFIG_SPL_LOAD_FIT)
+int board_fit_config_name_match(const char *name)
+{
+	return 0;
+}
+#endif
+
 static void setup_iomux_uart(void)
 {
 	SETUP_IOMUX_PADS(uart1_pads);
diff --git a/configs/mx6cuboxi_nt_defconfig b/configs/mx6cuboxi_nt_defconfig
new file mode 100644
index 0000000000..087569d2e9
--- /dev/null
+++ b/configs/mx6cuboxi_nt_defconfig
@@ -0,0 +1,62 @@
+CONFIG_ARCH_MX6=y
+CONFIG_ARM=y
+CONFIG_SYS_TEXT_BASE=0x17800000
+CONFIG_TARGET_MX6CUBOXI=y
+CONFIG_DEFAULT_DEVICE_TREE="imx6qdl-mx6cuboxi"
+CONFIG_OF_CONTROL=y
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_SPL_OPTEE_BOOT=y
+CONFIG_BOARD_EARLY_INIT_F=y
+CONFIG_BOOTDELAY=-2
+CONFIG_UEFI_BOOT=y
+CONFIG_UEFI_LOAD_ADDR=0x10820000
+CONFIG_EFI_LOADER=n
+CONFIG_CMD_BOOTD=n
+CONFIG_CMD_BOOTM=n
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_HDMIDETECT=y
+CONFIG_CMD_I2C=n
+CONFIG_CMD_MMC=y
+CONFIG_CMD_PART=y
+CONFIG_CMD_SPL=n
+CONFIG_CMD_USB=y
+CONFIG_DISTRO_DEFAULTS=n
+CONFIG_DM=y
+CONFIG_DM_THERMAL=y
+CONFIG_HUSH_PARSER=y
+CONFIG_CONS_INDEX=1
+CONFIG_PCI=n
+CONFIG_FSL_ESDHC=y
+CONFIG_PHYLIB=y
+CONFIG_SECURE_BOOT=y
+CONFIG_SPL=y
+CONFIG_SPL_LOAD_FIT=y
+CONFIG_SPL_LEGACY_IMAGE_SUPPORT=n
+CONFIG_SPL_OF_LIBFDT=y
+CONFIG_SPL_DM=n
+CONFIG_SPL_SYS_MALLOC_SIMPLE=y
+CONFIG_SPL_CRYPTO_SUPPORT=y
+CONFIG_SPL_EXT_SUPPORT=n
+CONFIG_SPL_GPIO_SUPPORT=y
+CONFIG_SPL_I2C_SUPPORT=n
+CONFIG_SPL_LIBCOMMON_SUPPORT=y
+CONFIG_SPL_LIBDISK_SUPPORT=n
+CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_SPL_MMC_SUPPORT=y
+CONFIG_SPL_SERIAL_SUPPORT=y
+CONFIG_SPL_SPI_SUPPORT=n
+CONFIG_SPL_USE_ARCH_MEMCPY=n
+CONFIG_SPL_WATCHDOG_SUPPORT=y
+CONFIG_SPL_LDSCRIPT="arch/arm/mach-imx/u-boot-spl-sram.lds"
+CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg"
+CONFIG_SYS_L2CACHE_OFF=y
+CONFIG_SYS_MALLOC_F_LEN=0x800
+CONFIG_USB_KEYBOARD=y
+CONFIG_USB_STORAGE=y
+CONFIG_USB=y
+CONFIG_USE_TINY_PRINTF=y
+CONFIG_VIDEO=y
+CONFIG_OF_LIBFDT=y
\ No newline at end of file
diff --git a/include/configs/mx6cuboxi.h b/include/configs/mx6cuboxi.h
index 803661cfa8..34fad495b1 100644
--- a/include/configs/mx6cuboxi.h
+++ b/include/configs/mx6cuboxi.h
@@ -71,6 +71,13 @@
 #define CONFIG_SYS_MMC_ENV_DEV		0	/* SDHC2 */
 
 #ifndef CONFIG_SPL_BUILD
+#ifdef CONFIG_UEFI_BOOT
+#include <config_uefi_bootcmd.h>
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	"mmcdev=0\0" \
+	BOOTENV
+#else
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	"fdtfile=undefined\0" \
 	"fdt_addr_r=0x18000000\0" \
@@ -125,6 +132,7 @@
 	func(DHCP, dhcp, na)
 
 #include <config_distro_bootcmd.h>
+#endif /* CONFIG_UEFI_BOOT */
 
 #else
 #define CONFIG_EXTRA_ENV_SETTINGS
-- 
2.16.2.gvfs.1.33.gf5370f1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 08/11] udoo_neo: Add Windows boot support for UDOO Neo
  2018-07-14  0:11 [U-Boot] [PATCH 00/11] Enable Windows 10 IoT Core on i.MX6 and i.MX7 Henry Beberman
                   ` (6 preceding siblings ...)
  2018-07-14  0:11 ` [U-Boot] [PATCH 06/11] mx7dsabresd: Add Windows boot support for iMX7 Sabre Henry Beberman
@ 2018-07-14  0:11 ` Henry Beberman
  2018-07-14  0:11 ` [U-Boot] [PATCH 09/11] cl-som-imx7: Add Windows boot support for cl-som-imx7 Henry Beberman
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 33+ messages in thread
From: Henry Beberman @ 2018-07-14  0:11 UTC (permalink / raw)
  To: u-boot

From: Henry Beberman <henry.beberman@microsoft.com>

This patch adds a new bootable configuration for Windows 10 IoT Core on
the i.MX6 SoloX UDOO Neo.

It also adds a new device tree sources file for imx6sx-udoo-neo.dts.
This is not required by Windows or UEFI but the build system requires a
device tree when building SPL with flat image tree support.

Signed-off-by: Henry Beberman <henry.beberman@microsoft.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Breno Lima <breno.lima@nxp.com>
Cc: Francesco Montefoschi <francesco.montefoschi@udoo.org>
---
 arch/arm/dts/Makefile            |  1 +
 arch/arm/dts/imx6sx-udoo-neo.dts |  8 ++++++
 board/udoo/neo/MAINTAINERS       |  2 ++
 board/udoo/neo/neo.c             |  7 +++++
 configs/udoo_neo_nt_defconfig    | 55 ++++++++++++++++++++++++++++++++++++++++
 include/configs/udoo_neo.h       |  8 ++++++
 6 files changed, 81 insertions(+)
 create mode 100644 arch/arm/dts/imx6sx-udoo-neo.dts
 create mode 100644 configs/udoo_neo_nt_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 109a00219d..1bbb9bf388 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -424,6 +424,7 @@ dtb-$(CONFIG_MX6SL) += imx6sll-evk.dtb
 
 dtb-$(CONFIG_MX6SX) += \
 	imx6sx-sabreauto.dtb \
+	imx6sx-udoo-neo.dtb \
 	imx6sx-sdb.dtb
 
 dtb-$(CONFIG_MX6UL) += \
diff --git a/arch/arm/dts/imx6sx-udoo-neo.dts b/arch/arm/dts/imx6sx-udoo-neo.dts
new file mode 100644
index 0000000000..f5b35a6175
--- /dev/null
+++ b/arch/arm/dts/imx6sx-udoo-neo.dts
@@ -0,0 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Microsoft Corporation
+ */
+
+/dts-v1/;
+
+#include "imx6sx.dtsi"
diff --git a/board/udoo/neo/MAINTAINERS b/board/udoo/neo/MAINTAINERS
index 743fe33d05..4ab862e3dc 100644
--- a/board/udoo/neo/MAINTAINERS
+++ b/board/udoo/neo/MAINTAINERS
@@ -5,3 +5,5 @@ S:	Maintained
 F:	board/udoo/neo/
 F:	include/configs/udoo_neo.h
 F:	configs/udoo_neo_defconfig
+F:	configs/udoo_neo_nt_defconfig
+F:	arch/arm/dts/imx6sx-udoo-neo.dts
diff --git a/board/udoo/neo/neo.c b/board/udoo/neo/neo.c
index 828161360c..8429063bb0 100644
--- a/board/udoo/neo/neo.c
+++ b/board/udoo/neo/neo.c
@@ -593,3 +593,10 @@ void board_init_f(ulong dummy)
 }
 
 #endif
+
+#if defined(CONFIG_MULTI_DTB_FIT) || defined(CONFIG_SPL_LOAD_FIT)
+int board_fit_config_name_match(const char *name)
+{
+	return 0;
+}
+#endif
diff --git a/configs/udoo_neo_nt_defconfig b/configs/udoo_neo_nt_defconfig
new file mode 100644
index 0000000000..d5123369ca
--- /dev/null
+++ b/configs/udoo_neo_nt_defconfig
@@ -0,0 +1,55 @@
+CONFIG_ARCH_MX6=y
+CONFIG_ARM=y
+CONFIG_SYS_TEXT_BASE=0x87800000
+CONFIG_TARGET_UDOO_NEO=y
+CONFIG_DEFAULT_DEVICE_TREE="imx6sx-udoo-neo"
+CONFIG_OF_CONTROL=y
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_SPL_OPTEE_BOOT=y
+CONFIG_BOARD_EARLY_INIT_F=y
+CONFIG_BOOTDELAY=-2
+CONFIG_UEFI_BOOT=y
+CONFIG_UEFI_LOAD_ADDR=0x82004000
+CONFIG_EFI_LOADER=n
+CONFIG_CMD_BOOTD=n
+CONFIG_CMD_BOOTM=n
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_I2C=n
+CONFIG_CMD_MMC=y
+CONFIG_CMD_PART=y
+CONFIG_CMD_SPL=n
+CONFIG_DISTRO_DEFAULTS=n
+CONFIG_ENV_IS_IN_MMC=n
+CONFIG_HUSH_PARSER=y
+CONFIG_PCI=n
+CONFIG_FSL_ESDHC=y
+CONFIG_PHYLIB=y
+CONFIG_SECURE_BOOT=y
+CONFIG_SPL=y
+CONFIG_SPL_FIT=y
+CONFIG_SPL_LOAD_FIT=y
+CONFIG_SPL_LEGACY_IMAGE_SUPPORT=n
+CONFIG_SPL_OF_LIBFDT=y
+CONFIG_SPL_SYS_MALLOC_SIMPLE=y
+CONFIG_SPL_CRYPTO_SUPPORT=y
+CONFIG_SPL_EXT_SUPPORT=n
+CONFIG_SPL_GPIO_SUPPORT=y
+CONFIG_SPL_I2C_SUPPORT=n
+CONFIG_SPL_LIBCOMMON_SUPPORT=y
+CONFIG_SPL_LIBDISK_SUPPORT=n
+CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_SPL_MMC_SUPPORT=y
+CONFIG_SPL_SERIAL_SUPPORT=y
+CONFIG_SPL_SPI_SUPPORT=n
+CONFIG_SPL_USE_ARCH_MEMCPY=n
+CONFIG_SPL_WATCHDOG_SUPPORT=y
+CONFIG_SPL_LDSCRIPT="arch/arm/mach-imx/u-boot-spl-sram.lds"
+CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg"
+CONFIG_SYS_L2CACHE_OFF=y
+CONFIG_SYS_MALLOC_F_LEN=0x800
+CONFIG_USE_TINY_PRINTF=y
+CONFIG_PHY_MICREL=y
+CONFIG_OF_LIBFDT=y
\ No newline at end of file
diff --git a/include/configs/udoo_neo.h b/include/configs/udoo_neo.h
index 2924e3143a..a71e9d64b2 100644
--- a/include/configs/udoo_neo.h
+++ b/include/configs/udoo_neo.h
@@ -25,6 +25,13 @@
 #define CONFIG_MXC_UART_BASE		UART1_BASE
 #define CONFIG_SYS_MMC_ENV_DEV		0  /*USDHC2*/
 
+#ifdef CONFIG_UEFI_BOOT
+#include <config_uefi_bootcmd.h>
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	"mmcdev=0\0" \
+	BOOTENV
+#else
 /* Linux only */
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	"console=ttymxc0,115200\0" \
@@ -58,6 +65,7 @@
 	func(DHCP, dhcp, na)
 
 #include <config_distro_bootcmd.h>
+#endif /* CONFIG_UEFI_BOOT */
 
 /* Miscellaneous configurable options */
 #define CONFIG_SYS_MEMTEST_START	0x80000000
-- 
2.16.2.gvfs.1.33.gf5370f1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 09/11] cl-som-imx7: Add Windows boot support for cl-som-imx7
  2018-07-14  0:11 [U-Boot] [PATCH 00/11] Enable Windows 10 IoT Core on i.MX6 and i.MX7 Henry Beberman
                   ` (7 preceding siblings ...)
  2018-07-14  0:11 ` [U-Boot] [PATCH 08/11] udoo_neo: Add Windows boot support for UDOO Neo Henry Beberman
@ 2018-07-14  0:11 ` Henry Beberman
  2018-07-14  0:11 ` [U-Boot] [PATCH 11/11] imx: Add MAC addresses to global page to pass MAC into UEFI Henry Beberman
  2018-07-14  0:11 ` [U-Boot] [PATCH 10/11] imx: Reserve a global page in memory to pass configuration to UEFI Henry Beberman
  10 siblings, 0 replies; 33+ messages in thread
From: Henry Beberman @ 2018-07-14  0:11 UTC (permalink / raw)
  To: u-boot

From: Henry Beberman <henry.beberman@microsoft.com>

This patch adds a new bootable configuration for Windows 10 IoT Core on
the Compulab CL-SOM-iMX7.

It also adds a new device tree sources file for imx7d-cl-som-imx7.dts.
This is not required by Windows or UEFI but the build system requires a
device tree when building SPL with flat image tree support.

Baseboard I2C is required for display initialization. This commit
patch doesn't use display during U-Boot, but it needs to setup and MUX
the baseboard I2C for use in UEFI when the GOP driver initializes.

Signed-off-by: Henry Beberman <henry.beberman@microsoft.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Uri Mashiach <uri.mashiach@compulab.co.il>
Cc: Igor Grinberg <grinberg@compulab.co.il>
---
 arch/arm/dts/Makefile                    |  1 +
 arch/arm/dts/imx7d-cl-som-imx7.dts       |  8 ++++
 board/compulab/cl-som-imx7/MAINTAINERS   |  2 +
 board/compulab/cl-som-imx7/cl-som-imx7.c | 47 +++++++++++++++++--
 board/compulab/cl-som-imx7/spl.c         |  7 +++
 configs/cl-som-imx7_nt_defconfig         | 80 ++++++++++++++++++++++++++++++++
 include/configs/cl-som-imx7.h            | 18 ++++++-
 7 files changed, 159 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/dts/imx7d-cl-som-imx7.dts
 create mode 100644 configs/cl-som-imx7_nt_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 1bbb9bf388..6fa7a78a2e 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -436,6 +436,7 @@ dtb-$(CONFIG_MX6UL) += \
 dtb-$(CONFIG_MX6ULL) += imx6ull-14x14-evk.dtb
 
 dtb-$(CONFIG_MX7) += imx7-colibri.dtb \
+	imx7d-cl-som-imx7.dtb \
 	imx7d-sdb.dtb
 
 dtb-$(CONFIG_ARCH_MX7ULP) += imx7ulp-evk.dtb
diff --git a/arch/arm/dts/imx7d-cl-som-imx7.dts b/arch/arm/dts/imx7d-cl-som-imx7.dts
new file mode 100644
index 0000000000..cbb31ec693
--- /dev/null
+++ b/arch/arm/dts/imx7d-cl-som-imx7.dts
@@ -0,0 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Microsoft Corporation
+ */
+
+/dts-v1/;
+
+#include "imx7d.dtsi"
diff --git a/board/compulab/cl-som-imx7/MAINTAINERS b/board/compulab/cl-som-imx7/MAINTAINERS
index 2b917a5c80..aeaa73a85a 100644
--- a/board/compulab/cl-som-imx7/MAINTAINERS
+++ b/board/compulab/cl-som-imx7/MAINTAINERS
@@ -4,3 +4,5 @@ S:	Maintained
 F:	board/compulab/cl-som-imx7
 F:	include/configs/cl-som-imx7.h
 F:	configs/cl-som-imx7_defconfig
+F:	configs/cl-som-imx7_nt_defconfig
+F:	arch/arm/dts/imx7d-cl-som-imx7.dts
diff --git a/board/compulab/cl-som-imx7/cl-som-imx7.c b/board/compulab/cl-som-imx7/cl-som-imx7.c
index 1bc33b0a7b..6a219b892a 100644
--- a/board/compulab/cl-som-imx7/cl-som-imx7.c
+++ b/board/compulab/cl-som-imx7/cl-som-imx7.c
@@ -50,15 +50,54 @@ static struct i2c_pads_info cl_som_imx7_i2c_pad_info2 = {
 	},
 };
 
+static struct i2c_pads_info cl_som_imx7_i2c_pad_info4 = {
+	.scl = {
+		.i2c_mode = MX7D_PAD_GPIO1_IO10__I2C4_SCL |
+			MUX_PAD_CTRL(I2C_PAD_CTRL),
+		.gpio_mode = MX7D_PAD_GPIO1_IO10__GPIO1_IO10 |
+			MUX_PAD_CTRL(I2C_PAD_CTRL),
+		.gp = IMX_GPIO_NR(1, 10),
+	},
+	.sda = {
+		.i2c_mode = MX7D_PAD_GPIO1_IO11__I2C4_SDA |
+			MUX_PAD_CTRL(I2C_PAD_CTRL),
+		.gpio_mode = MX7D_PAD_GPIO1_IO11__GPIO1_IO11 |
+			MUX_PAD_CTRL(I2C_PAD_CTRL),
+		.gp = IMX_GPIO_NR(1, 11),
+	},
+};
+
+/* Environment variable: base board I2C bus enable */
+#define CL_SOM_IMX7_ENV_BASE_I2C "baseboard_i2c_enable"
+
 /*
  * cl_som_imx7_setup_i2c() - I2C  pinmux configuration.
  */
-static void cl_som_imx7_setup_i2c(void)
+static void cl_som_imx7_setup_i2c0(void)
 {
 	setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &cl_som_imx7_i2c_pad_info2);
 }
+
+static int cl_som_imx7_setup_i2c1(void)
+{
+	int ret;
+	char *base_i2c = env_get(CL_SOM_IMX7_ENV_BASE_I2C);
+
+	if (base_i2c && (!strcmp(base_i2c, "yes") ||
+			 !strcmp(base_i2c, "true") ||
+			 !strcmp(base_i2c, "1"))) {
+		ret = setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f,
+				&cl_som_imx7_i2c_pad_info4);
+		if (ret)
+			return 0;
+		return 1;
+	}
+
+	return 0;
+}
 #else /* !CONFIG_SYS_I2C_MXC */
-static void cl_som_imx7_setup_i2c(void) {}
+static void cl_som_imx7_setup_i2c0(void) {}
+static int cl_som_imx7_setup_i2c1(void) { return 0; }
 #endif /* CONFIG_SYS_I2C_MXC */
 
 int dram_init(void)
@@ -256,7 +295,7 @@ int board_init(void)
 {
 	/* address of boot parameters */
 	gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
-	cl_som_imx7_setup_i2c();
+	cl_som_imx7_setup_i2c0();
 	cl_som_imx7_setup_fec();
 	cl_som_imx7_spi_init();
 
@@ -327,5 +366,7 @@ int checkboard(void)
 
 	printf("Board: CL-SOM-iMX7 in %s mode\n", mode);
 
+	cl_som_imx7_setup_i2c1();
+
 	return 0;
 }
diff --git a/board/compulab/cl-som-imx7/spl.c b/board/compulab/cl-som-imx7/spl.c
index 76a4c8beb0..23ea30a795 100644
--- a/board/compulab/cl-som-imx7/spl.c
+++ b/board/compulab/cl-som-imx7/spl.c
@@ -208,3 +208,10 @@ void board_boot_order(u32 *spl_boot_list)
 		break;
 	}
 }
+
+#if defined(CONFIG_MULTI_DTB_FIT) || defined(CONFIG_SPL_LOAD_FIT)
+int board_fit_config_name_match(const char *name)
+{
+	return 0;
+}
+#endif
diff --git a/configs/cl-som-imx7_nt_defconfig b/configs/cl-som-imx7_nt_defconfig
new file mode 100644
index 0000000000..4fe8233f0f
--- /dev/null
+++ b/configs/cl-som-imx7_nt_defconfig
@@ -0,0 +1,80 @@
+CONFIG_ARM=y
+CONFIG_ARCH_MX7=y
+CONFIG_SYS_THUMB_BUILD=y
+CONFIG_SYS_TEXT_BASE=0x87800000
+CONFIG_TARGET_CL_SOM_IMX7=y
+CONFIG_DEFAULT_DEVICE_TREE="imx7d-cl-som-imx7"
+CONFIG_OF_CONTROL=y
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_SPL_OPTEE_BOOT=y
+CONFIG_SPL=y
+CONFIG_SPL_LOAD_FIT=y
+CONFIG_SPL_LEGACY_IMAGE_SUPPORT=n
+CONFIG_SPL_FIT=y
+CONFIG_SPL_OF_LIBFDT=y
+CONFIG_SPL_BOARD_INIT=y
+CONFIG_SPL_DM=y
+CONFIG_SPL_CRYPTO_SUPPORT=y
+CONFIG_SPL_ENABLE_CACHES=y
+CONFIG_SPL_GPIO_SUPPORT=y
+CONFIG_SPL_LIBCOMMON_SUPPORT=y
+CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_SPL_MMC_SUPPORT=y
+CONFIG_SPL_SERIAL_SUPPORT=y
+CONFIG_USE_TINY_PRINTF=y
+CONFIG_SPL_USE_ARCH_MEMCPY=n
+CONFIG_SPL_WATCHDOG_SUPPORT=y
+CONFIG_ARMV7_BOOT_SEC_DEFAULT=y
+CONFIG_ARMV7_NONSEC=n
+CONFIG_BAUDRATE=115200
+CONFIG_BOOTDELAY=-2
+CONFIG_UEFI_BOOT=y
+CONFIG_UEFI_LOAD_ADDR=0x82004000
+CONFIG_EFI_LOADER=n
+CONFIG_IMX_RDC=y
+CONFIG_IMX_BOOTAUX=y
+CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg"
+CONFIG_SECURE_BOOT=y
+CONFIG_SPL_SYS_MALLOC_SIMPLE=y
+CONFIG_SPI_BOOT=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x8a
+CONFIG_SPL_I2C_SUPPORT=y
+CONFIG_SPL_SPI_LOAD=y
+CONFIG_HUSH_PARSER=y
+CONFIG_SYS_PROMPT="CL-SOM-iMX7 # "
+CONFIG_CMD_BOOTZ=n
+# CONFIG_CMD_IMI is not set
+# CONFIG_CMD_XIMG is not set
+# CONFIG_CMD_EXPORTENV is not set
+# CONFIG_CMD_IMPORTENV is not set
+CONFIG_CMD_GREPENV=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_PART=y
+CONFIG_CMD_SF=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_EXT2=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_EXT4_WRITE=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+# CONFIG_ENV_IS_IN_MMC is not set
+CONFIG_FSL_ESDHC=y
+CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_SPI=y
+CONFIG_MXC_SPI=y
+CONFIG_USB=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_MXC_USB_OTG_HACTIVE=y
+CONFIG_USB_STORAGE=y
+CONFIG_USB_GADGET=y
+CONFIG_CI_UDC=y
+CONFIG_OF_LIBFDT=y
diff --git a/include/configs/cl-som-imx7.h b/include/configs/cl-som-imx7.h
index faea6c6b93..14744ba0ca 100644
--- a/include/configs/cl-som-imx7.h
+++ b/include/configs/cl-som-imx7.h
@@ -19,9 +19,13 @@
 
 #define CONFIG_BOARD_LATE_INIT
 
+#ifndef CONFIG_SECURE_BOOT
+#ifndef CONFIG_CSF_SIZE
+#define CONFIG_CSF_SIZE			0x4000
+#endif
+#endif /* CONFIG_SECURE_BOOT */
 /* Uncomment to enable secure boot support */
 /* #define CONFIG_SECURE_BOOT */
-#define CONFIG_CSF_SIZE			0x4000
 
 /* Network */
 #define CONFIG_FEC_MXC
@@ -63,6 +67,16 @@
 
 #undef CONFIG_SYS_AUTOLOAD
 #undef CONFIG_EXTRA_ENV_SETTINGS
+
+#ifdef CONFIG_UEFI_BOOT
+#include <config_uefi_bootcmd.h>
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	"mmcdev=0\0" \
+	"displaytype=dvi\0" \
+	"baseboard_i2c_enable=true\0" \
+	BOOTENV
+#else
 #undef CONFIG_BOOTCOMMAND
 #undef CONFIG_BOOTDELAY
 
@@ -126,6 +140,8 @@
 	"echo eMMC boot attempt ...; run emmcbootscript; run emmcboot; " \
 	"echo USB boot attempt ...; run usbbootscript; "
 
+#endif /* CONFIG_UEFI_BOOT */
+
 #define CONFIG_SYS_MEMTEST_START	0x80000000
 #define CONFIG_SYS_MEMTEST_END		(CONFIG_SYS_MEMTEST_START + 0x20000000)
 
-- 
2.16.2.gvfs.1.33.gf5370f1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 10/11] imx: Reserve a global page in memory to pass configuration to UEFI
  2018-07-14  0:11 [U-Boot] [PATCH 00/11] Enable Windows 10 IoT Core on i.MX6 and i.MX7 Henry Beberman
                   ` (9 preceding siblings ...)
  2018-07-14  0:11 ` [U-Boot] [PATCH 11/11] imx: Add MAC addresses to global page to pass MAC into UEFI Henry Beberman
@ 2018-07-14  0:11 ` Henry Beberman
  10 siblings, 0 replies; 33+ messages in thread
From: Henry Beberman @ 2018-07-14  0:11 UTC (permalink / raw)
  To: u-boot

From: Henry Beberman <henry.beberman@microsoft.com>

This patch is to enable U-Boot to pass configuration information
available during U-Boot Proper into a subsequent OS. This is required
for Windows because it lacks device tree support.

When CONFIG_GLOBAL_PAGE and CONFIG_UEFI_BOOT are set on an i.MX6 or
i.MX7 platform the go command will initialize a 4k page at a hardcoded
offset to zero. Then it will set a signature and revision number at the
start of the page so the consumer of the configuration can verify that
the page has been initialized to the expected format.

Signed-off-by: Henry Beberman <henry.beberman@microsoft.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
---
 arch/arm/mach-imx/Kconfig       |  7 +++++++
 arch/arm/mach-imx/Makefile      |  1 +
 arch/arm/mach-imx/boot.c        |  6 ++++++
 arch/arm/mach-imx/global_page.c | 28 ++++++++++++++++++++++++++++
 include/configs/mx6_common.h    | 11 +++++++++++
 include/configs/mx7_common.h    |  5 +++++
 include/global_page.h           | 24 ++++++++++++++++++++++++
 7 files changed, 82 insertions(+)
 create mode 100644 arch/arm/mach-imx/global_page.c
 create mode 100644 include/global_page.h

diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 3aec89d440..c88fa2ca1b 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -78,3 +78,10 @@ config NXP_BOARD_REVISION
 	  NXP boards based on i.MX6/7 contain the board revision information
 	  stored in the fuses. Select this option if you want to be able to
 	  retrieve the board revision information.
+
+config GLOBAL_PAGE
+	bool "Enable global 4K page for configuration sharing"
+	default n
+	help
+	  This option creates a global 4K page to store U-Boot environment data
+	  to pass to another environment such as UEFI or Windows.
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index a81af51f03..be095d71a2 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -43,6 +43,7 @@ obj-$(CONFIG_SATA) += sata.o
 obj-$(CONFIG_SECURE_BOOT)    += hab.o
 obj-$(CONFIG_SYSCOUNTER_TIMER) += syscounter.o
 obj-$(CONFIG_UEFI_BOOT) += boot.o
+obj-$(CONFIG_GLOBAL_PAGE) += global_page.o
 endif
 ifeq ($(SOC),$(filter $(SOC),mx7ulp))
 obj-y  += cache.o
diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
index 457a323fa2..2dbde8d8ee 100644
--- a/arch/arm/mach-imx/boot.c
+++ b/arch/arm/mach-imx/boot.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <global_page.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -12,6 +13,11 @@ DECLARE_GLOBAL_DATA_PTR;
 unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
 			 char * const argv[])
 {
+#ifdef CONFIG_GLOBAL_PAGE
+	init_global_page();
+	publish_to_global_page();
+#endif
+
 	cleanup_before_linux();
 
 	return entry(argc, argv);
diff --git a/arch/arm/mach-imx/global_page.c b/arch/arm/mach-imx/global_page.c
new file mode 100644
index 0000000000..139e18f4bc
--- /dev/null
+++ b/arch/arm/mach-imx/global_page.c
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Microsoft Corporation
+ */
+
+#include <global_page.h>
+#include <environment.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct imx_global_page *global_page =
+	(struct imx_global_page *)GLOBAL_PAGE_BASE_ADDRESS;
+
+void init_global_page(void)
+{
+	/* Clear global page */
+	memset(global_page, 0, 0x1000);
+
+	/* Set signature to 'GLBL' */
+	global_page->header.signature = 0x474c424c;
+
+	/* Set revision */
+	global_page->header.revision = 0;
+}
+
+void publish_to_global_page(void)
+{
+}
diff --git a/include/configs/mx6_common.h b/include/configs/mx6_common.h
index 756db4da61..6571787e50 100644
--- a/include/configs/mx6_common.h
+++ b/include/configs/mx6_common.h
@@ -74,4 +74,15 @@
 #define CONFIG_SYS_NORMAL_WORLD
 #endif
 
+/* Define global page address */
+#if defined(CONFIG_GLOBAL_PAGE)
+#if defined(CONFIG_MX6SL) || defined(CONFIG_MX6SLL) || \
+	defined(CONFIG_MX6SX) || \
+	defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL)
+#define GLOBAL_PAGE_BASE_ADDRESS 0x82003000
+#else
+#define GLOBAL_PAGE_BASE_ADDRESS 0x10817000
+#endif
+#endif
+
 #endif
diff --git a/include/configs/mx7_common.h b/include/configs/mx7_common.h
index 4864df5108..a26805e93c 100644
--- a/include/configs/mx7_common.h
+++ b/include/configs/mx7_common.h
@@ -63,4 +63,9 @@
 #define CONFIG_SYS_NORMAL_WORLD
 #endif
 
+/* Define global page address */
+#if defined(CONFIG_GLOBAL_PAGE)
+#define GLOBAL_PAGE_BASE_ADDRESS 0x82003000
+#endif
+
 #endif
diff --git a/include/global_page.h b/include/global_page.h
new file mode 100644
index 0000000000..a9ee6b67ad
--- /dev/null
+++ b/include/global_page.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0+*/
+/*
+ * Copyright (C) 2018 Microsoft Corporation
+ */
+
+#ifndef _GLOBAL_PAGE_H
+#define _GLOBAL_PAGE_H
+
+#include <common.h>
+
+struct global_page_header {
+	u32 signature;
+	u8 revision;
+	u8 reserved[3];
+} __packed;
+
+struct imx_global_page {
+	struct global_page_header header;
+} __packed;
+
+void init_global_page(void);
+void publish_to_global_page(void);
+
+#endif
-- 
2.16.2.gvfs.1.33.gf5370f1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 11/11] imx: Add MAC addresses to global page to pass MAC into UEFI
  2018-07-14  0:11 [U-Boot] [PATCH 00/11] Enable Windows 10 IoT Core on i.MX6 and i.MX7 Henry Beberman
                   ` (8 preceding siblings ...)
  2018-07-14  0:11 ` [U-Boot] [PATCH 09/11] cl-som-imx7: Add Windows boot support for cl-som-imx7 Henry Beberman
@ 2018-07-14  0:11 ` Henry Beberman
  2018-07-14  0:11 ` [U-Boot] [PATCH 10/11] imx: Reserve a global page in memory to pass configuration to UEFI Henry Beberman
  10 siblings, 0 replies; 33+ messages in thread
From: Henry Beberman @ 2018-07-14  0:11 UTC (permalink / raw)
  To: u-boot

From: Henry Beberman <henry.beberman@microsoft.com>

U-Boot already has logic for determining the platform MAC address on
many i.MX platforms, such as pulling it from fuses or SPI flash. This
configuration option saves the MAC address from the ethaddr (and
potentially ethaddr1) into the global page and marks it as valid. This
value is then picked up in UEFI which will configure the LAN driver in
Windows with the correct MAC address.

Signed-off-by: Henry Beberman <henry.beberman@microsoft.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
---
 arch/arm/mach-imx/Kconfig        | 16 ++++++++++++++++
 arch/arm/mach-imx/global_page.c  | 26 +++++++++++++++++++++++++-
 configs/cl-som-imx7_nt_defconfig |  2 ++
 configs/mx6cuboxi_nt_defconfig   |  2 ++
 configs/mx6sabresd_nt_defconfig  |  2 ++
 configs/udoo_neo_nt_defconfig    |  2 ++
 include/global_page.h            |  8 ++++++++
 7 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index c88fa2ca1b..9bc0294d0c 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -85,3 +85,19 @@ config GLOBAL_PAGE
 	help
 	  This option creates a global 4K page to store U-Boot environment data
 	  to pass to another environment such as UEFI or Windows.
+
+config STORE_MAC_IN_GLOBAL
+	bool "Store MAC address information in global page"
+	depends on GLOBAL_PAGE
+	default n
+	help
+	  This option informs U-Boot to read the ethaddr environment
+	  variable and store it in the global page for UEFI to use.
+
+config ETH1ADDR_IN_GLOBAL
+	bool "Store MAC Address for 2nd ethernet in global page"
+	depends on STORE_MAC_IN_GLOBAL
+	default n
+	help
+	  This option informs U-Boot to read the eth1addr environment
+	  variable and store it in the global page for UEFI to use.
diff --git a/arch/arm/mach-imx/global_page.c b/arch/arm/mach-imx/global_page.c
index 139e18f4bc..c753452ad6 100644
--- a/arch/arm/mach-imx/global_page.c
+++ b/arch/arm/mach-imx/global_page.c
@@ -20,9 +20,33 @@ void init_global_page(void)
 	global_page->header.signature = 0x474c424c;
 
 	/* Set revision */
-	global_page->header.revision = 0;
+	global_page->header.revision = 1;
 }
 
 void publish_to_global_page(void)
 {
+#ifdef CONFIG_STORE_MAC_IN_GLOBAL
+	publish_mac_to_global_page("ethaddr", 0);
+#endif /* CONFIG_STORE_MAC_IN_GLOBAL */
+
+#ifdef CONFIG_ETH1ADDR_IN_GLOBAL
+	publish_mac_to_global_page("eth1addr", 1);
+#endif /* CONFIG_ETH1ADDR_IN_GLOBAL */
+}
+
+void publish_mac_to_global_page(const char *env_var, int mac)
+{
+	uchar mac_id[6];
+
+	if (mac > 1)
+		return;
+
+	if (!(strcmp(env_var, "ethaddr") || strcmp(env_var, "eth1addr")))
+		return;
+
+	eth_env_get_enetaddr(env_var, mac_id);
+
+	global_page->mac_entry[mac].enet_id = mac;
+	global_page->mac_entry[mac].valid = 1;
+	memcpy(global_page->mac_entry[mac].mac, mac_id, 6);
 }
diff --git a/configs/cl-som-imx7_nt_defconfig b/configs/cl-som-imx7_nt_defconfig
index 4fe8233f0f..048621874c 100644
--- a/configs/cl-som-imx7_nt_defconfig
+++ b/configs/cl-som-imx7_nt_defconfig
@@ -77,4 +77,6 @@ CONFIG_MXC_USB_OTG_HACTIVE=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_GADGET=y
 CONFIG_CI_UDC=y
+CONFIG_GLOBAL_PAGE=y
+CONFIG_STORE_MAC_IN_GLOBAL=y
 CONFIG_OF_LIBFDT=y
diff --git a/configs/mx6cuboxi_nt_defconfig b/configs/mx6cuboxi_nt_defconfig
index 087569d2e9..b29084012f 100644
--- a/configs/mx6cuboxi_nt_defconfig
+++ b/configs/mx6cuboxi_nt_defconfig
@@ -59,4 +59,6 @@ CONFIG_USB_STORAGE=y
 CONFIG_USB=y
 CONFIG_USE_TINY_PRINTF=y
 CONFIG_VIDEO=y
+CONFIG_GLOBAL_PAGE=y
+CONFIG_STORE_MAC_IN_GLOBAL=y
 CONFIG_OF_LIBFDT=y
\ No newline at end of file
diff --git a/configs/mx6sabresd_nt_defconfig b/configs/mx6sabresd_nt_defconfig
index 9d858a4418..47c6568e60 100644
--- a/configs/mx6sabresd_nt_defconfig
+++ b/configs/mx6sabresd_nt_defconfig
@@ -55,4 +55,6 @@ CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_USB=y
 CONFIG_USE_TINY_PRINTF=y
 CONFIG_VIDEO=y
+CONFIG_GLOBAL_PAGE=y
+CONFIG_STORE_MAC_IN_GLOBAL=y
 CONFIG_OF_LIBFDT=y
\ No newline at end of file
diff --git a/configs/udoo_neo_nt_defconfig b/configs/udoo_neo_nt_defconfig
index d5123369ca..1be3180382 100644
--- a/configs/udoo_neo_nt_defconfig
+++ b/configs/udoo_neo_nt_defconfig
@@ -52,4 +52,6 @@ CONFIG_SYS_L2CACHE_OFF=y
 CONFIG_SYS_MALLOC_F_LEN=0x800
 CONFIG_USE_TINY_PRINTF=y
 CONFIG_PHY_MICREL=y
+CONFIG_GLOBAL_PAGE=y
+CONFIG_STORE_MAC_IN_GLOBAL=y
 CONFIG_OF_LIBFDT=y
\ No newline at end of file
diff --git a/include/global_page.h b/include/global_page.h
index a9ee6b67ad..2ba291019a 100644
--- a/include/global_page.h
+++ b/include/global_page.h
@@ -14,11 +14,19 @@ struct global_page_header {
 	u8 reserved[3];
 } __packed;
 
+struct global_mac_entry {
+	u8 enet_id;
+	u8 valid;
+	u8 mac[6];
+} __packed;
+
 struct imx_global_page {
 	struct global_page_header header;
+	struct global_mac_entry mac_entry[2];
 } __packed;
 
 void init_global_page(void);
 void publish_to_global_page(void);
+void publish_mac_to_global_page(const char *env_var, int mac);
 
 #endif
-- 
2.16.2.gvfs.1.33.gf5370f1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc
  2018-07-14  0:11 ` [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc Henry Beberman
@ 2018-07-16 17:16   ` Trent Piepho
  2018-07-16 22:28     ` Henry Beberman
  2018-07-17 17:09     ` Fabio Estevam
  2018-08-07 11:11   ` Stefano Babic
  1 sibling, 2 replies; 33+ messages in thread
From: Trent Piepho @ 2018-07-16 17:16 UTC (permalink / raw)
  To: u-boot

On Sat, 2018-07-14 at 00:11 +0000, Henry Beberman wrote:
> From: Henry Beberman <henry.beberman@microsoft.com>
> 
> This patch enables i.MX platforms to easily add a boot script to their
> U-Boot Proper environment to automatically load and execute an EFI
> firmware from the first FAT partition of an MMC device.

Is there a reason to force the first partition instead of using the EFI
partition code to select which partition to boot?

I also wonder, on a Linux system, is there a reason the EFI partition
must use FAT?

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 04/11] spl: imx: Add optional lds to keep SPL entirely in on-chip RAM
  2018-07-14  0:11 ` [U-Boot] [PATCH 04/11] spl: imx: Add optional lds to keep SPL entirely in on-chip RAM Henry Beberman
@ 2018-07-16 17:32   ` Trent Piepho
  2018-07-16 22:48     ` Henry Beberman
  2018-08-07 12:17   ` Stefano Babic
  1 sibling, 1 reply; 33+ messages in thread
From: Trent Piepho @ 2018-07-16 17:32 UTC (permalink / raw)
  To: u-boot

On Sat, 2018-07-14 at 00:11 +0000, Henry Beberman wrote:
> From: Henry Beberman <henry.beberman@microsoft.com>
> 
> This patch is part of the i.MX Windows 10 IoT Core boot flow.
> 
> It adds a modified linker script for SPL to keep all segments in
> on-chip ram. This is to harden the device against potential leaks of
> device secrets by keeping them out of DRAM.
> 
> Additionally if CONFIG_SYS_SPL_MALLOC_START is defined, it will
> override the CONFIG_SPL_SYS_MALLOC_SIMPLE and allocate space in DRAM
> instead of on-chip ram. This patch prevents the definition of those
> values for i.MX6 and i.MX7 SPL if CONFIG_OPTEE_SPL_BOOT is selected.

Is booting SPL from entirely from SRAM only useful in concert with
OPTEE?

For instance, if I'm building a device that doesn't use OPTEE and yet
want it to be secure, would I want to keep the SPL entirely in SRAM?

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 06/11] mx7dsabresd: Add Windows boot support for iMX7 Sabre
  2018-07-14  0:11 ` [U-Boot] [PATCH 06/11] mx7dsabresd: Add Windows boot support for iMX7 Sabre Henry Beberman
@ 2018-07-16 18:22   ` Trent Piepho
  2018-07-17  1:41     ` Henry Beberman
  0 siblings, 1 reply; 33+ messages in thread
From: Trent Piepho @ 2018-07-16 18:22 UTC (permalink / raw)
  To: u-boot

On Sat, 2018-07-14 at 00:11 +0000, Henry Beberman wrote:
> From: Henry Beberman <henry.beberman@microsoft.com>
> 
> This patch adds a new bootable configuration for Windows 10 IoT Core on
> the i.MX7 Dual Sabre board.
> 
> It enables SPL on the i.MX7 Sabre in order to support the FIT load of
> OP-TEE and U-Boot proper.
> 

> diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
> index f186120684..3fb9b72703 100644
> --- a/drivers/gpio/Makefile
> +++ b/drivers/gpio/Makefile
> @@ -7,10 +7,13 @@ ifndef CONFIG_SPL_BUILD
>  obj-$(CONFIG_DWAPB_GPIO)	+= dwapb_gpio.o
>  obj-$(CONFIG_AXP_GPIO)		+= axp_gpio.o
>  endif
> +
> +ifeq ($(CONFIG_$(SPL_TPL_)DM),y)
>  obj-$(CONFIG_DM_GPIO)		+= gpio-uclass.o
>  
>  obj-$(CONFIG_DM_PCA953X)	+= pca953x_gpio.o
>  obj-$(CONFIG_DM_74X164)		+= 74x164_gpio.o
> +endif

It doesn't look like this patch is specific to mx7 or Windows.  Perhaps
it should be in a different commit?

Also, the help text for SPL_DM says it turns on basic DM support in
SPL.  But not any specific hardware drivers.  Those all have additional
config options to turn them on.  It doesn't seems right to bundle a
selection of GPIO drivers along with CONFIG_SPL_DM.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc
  2018-07-16 17:16   ` Trent Piepho
@ 2018-07-16 22:28     ` Henry Beberman
  2018-07-16 22:45       ` Trent Piepho
  2018-07-17 17:09     ` Fabio Estevam
  1 sibling, 1 reply; 33+ messages in thread
From: Henry Beberman @ 2018-07-16 22:28 UTC (permalink / raw)
  To: u-boot

Hi Trent,

> -----Original Message-----
> From: Trent Piepho <tpiepho@impinj.com>
> Sent: Monday, July 16, 2018 10:17 AM
> To: Henry Beberman <Henry.Beberman@microsoft.com>; u-
> boot at lists.denx.de
> Cc: trini at konsulko.com; fabio.estevam at nxp.com
> Subject: Re: [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI
> from mmc
> 
> On Sat, 2018-07-14 at 00:11 +0000, Henry Beberman wrote:
> > From: Henry Beberman <henry.beberman@microsoft.com>
> >
> > This patch enables i.MX platforms to easily add a boot script to their
> > U-Boot Proper environment to automatically load and execute an EFI
> > firmware from the first FAT partition of an MMC device.
> 
> Is there a reason to force the first partition instead of using the EFI partition
> code to select which partition to boot?
> 
> I also wonder, on a Linux system, is there a reason the EFI partition must use
> FAT?

I need to revise the commit message for this patch. The script is not fixed to the first partition of the selected MMC, it scans the disk for partitions marked bootable, then checks each one of those until it finds the imxboard_efi.fd binary.

We could switch over to using the generic load from CONFIG_CMD_FS_GENERIC if there's demand for non-FAT filesystems. We're currently using fatload because the EFI partitions in our Windows images are always FAT formatted.

Thanks,
Henry

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc
  2018-07-16 22:28     ` Henry Beberman
@ 2018-07-16 22:45       ` Trent Piepho
  2018-07-16 23:56         ` Henry Beberman
  0 siblings, 1 reply; 33+ messages in thread
From: Trent Piepho @ 2018-07-16 22:45 UTC (permalink / raw)
  To: u-boot

On Mon, 2018-07-16 at 22:28 +0000, Henry Beberman wrote:
> Hi Trent,
> 
> > -----Original Message-----
> > From: Trent Piepho <tpiepho@impinj.com>
> > Sent: Monday, July 16, 2018 10:17 AM
> > To: Henry Beberman <Henry.Beberman@microsoft.com>; u-
> > boot at lists.denx.de
> > Cc: trini at konsulko.com; fabio.estevam at nxp.com
> > Subject: Re: [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI
> > from mmc
> > 
> > On Sat, 2018-07-14 at 00:11 +0000, Henry Beberman wrote:
> > > From: Henry Beberman <henry.beberman@microsoft.com>
> > > 
> > > This patch enables i.MX platforms to easily add a boot script to their
> > > U-Boot Proper environment to automatically load and execute an EFI
> > > firmware from the first FAT partition of an MMC device.
> > 
> > Is there a reason to force the first partition instead of using the EFI partition
> > code to select which partition to boot?
> > 
> > I also wonder, on a Linux system, is there a reason the EFI partition must use
> > FAT?
> 
> I need to revise the commit message for this patch. The script is not fixed to the first partition of the selected MMC, it scans the disk for partitions marked bootable, then checks each one of those until it finds the imxboard_efi.fd binary.

That is indeed very different from first FAT partition.  Does bootable
only apply legacy MBR partition tables?  I didn't think bootable was
typically used with GPT tables.  There is a bit, but it's not used to
mark EFI partitions.

Which brings me back to the partition type.  Isn't that the right way
to find the EFI?

> We could switch over to using the generic load from CONFIG_CMD_FS_GENERIC if there's demand for non-FAT filesystems. We're currently using fatload because the EFI partitions in our Windows images are always FAT formatted.

You're original search method required the partition be FAT.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 04/11] spl: imx: Add optional lds to keep SPL entirely in on-chip RAM
  2018-07-16 17:32   ` Trent Piepho
@ 2018-07-16 22:48     ` Henry Beberman
  0 siblings, 0 replies; 33+ messages in thread
From: Henry Beberman @ 2018-07-16 22:48 UTC (permalink / raw)
  To: u-boot

Hi Trent,

> -----Original Message-----
> From: Trent Piepho <tpiepho@impinj.com>
> Sent: Monday, July 16, 2018 10:33 AM
> To: Henry Beberman <Henry.Beberman@microsoft.com>; u-
> boot at lists.denx.de
> Cc: fabio.estevam at nxp.com
> Subject: Re: [U-Boot] [PATCH 04/11] spl: imx: Add optional lds to keep SPL
> entirely in on-chip RAM
> 
> On Sat, 2018-07-14 at 00:11 +0000, Henry Beberman wrote:
> > From: Henry Beberman <henry.beberman@microsoft.com>
> >
> > This patch is part of the i.MX Windows 10 IoT Core boot flow.
> >
> > It adds a modified linker script for SPL to keep all segments in
> > on-chip ram. This is to harden the device against potential leaks of
> > device secrets by keeping them out of DRAM.
> >
> > Additionally if CONFIG_SYS_SPL_MALLOC_START is defined, it will
> > override the CONFIG_SPL_SYS_MALLOC_SIMPLE and allocate space in
> DRAM
> > instead of on-chip ram. This patch prevents the definition of those
> > values for i.MX6 and i.MX7 SPL if CONFIG_OPTEE_SPL_BOOT is selected.
> 
> Is booting SPL from entirely from SRAM only useful in concert with OPTEE?
> 
> For instance, if I'm building a device that doesn't use OPTEE and yet want it to
> be secure, would I want to keep the SPL entirely in SRAM?

We're adding this in anticipation of implementing the Trusted Computing Group's Device Identifier Composition Engine (DICE). The reason we're adding it now is to ensure that the SPL we're building fits within the size limitations imposed by SRAM.

The switch to SRAM is primarily to protect the Unique Device Secret (UDS), which is a device specific identifier that must only be readable by DICE. The UDS must not be visible in DRAM at any point. You can find more information on the DICE requirements in the "Hardware Requirements for a Device Identifier Composition Engine" specification. (https://trustedcomputinggroup.org/resource/hardware-requirements-for-a-device-identifier-composition-engine/)

There's value in other devices keeping SPL entirely in SDRAM as an additional layer of security, but it’s a tradeoff against image size and stack/malloc space.

Thanks,
Henry

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc
  2018-07-16 22:45       ` Trent Piepho
@ 2018-07-16 23:56         ` Henry Beberman
  2018-07-17 17:24           ` Trent Piepho
  0 siblings, 1 reply; 33+ messages in thread
From: Henry Beberman @ 2018-07-16 23:56 UTC (permalink / raw)
  To: u-boot

> -----Original Message-----
> From: Trent Piepho <tpiepho@impinj.com>
> Sent: Monday, July 16, 2018 3:45 PM
> To: Henry Beberman <Henry.Beberman@microsoft.com>; u-
> boot at lists.denx.de
> Cc: trini at konsulko.com; fabio.estevam at nxp.com
> Subject: Re: [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI
> from mmc
> 
> On Mon, 2018-07-16 at 22:28 +0000, Henry Beberman wrote:
> > Hi Trent,
> >
> > > -----Original Message-----
> > > From: Trent Piepho <tpiepho@impinj.com>
> > > Sent: Monday, July 16, 2018 10:17 AM
> > > To: Henry Beberman <Henry.Beberman@microsoft.com>; u-
> > > boot at lists.denx.de
> > > Cc: trini at konsulko.com; fabio.estevam at nxp.com
> > > Subject: Re: [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run
> > > UEFI from mmc
> > >
> > > On Sat, 2018-07-14 at 00:11 +0000, Henry Beberman wrote:
> > > > From: Henry Beberman <henry.beberman@microsoft.com>
> > > >
> > > > This patch enables i.MX platforms to easily add a boot script to
> > > > their U-Boot Proper environment to automatically load and execute
> > > > an EFI firmware from the first FAT partition of an MMC device.
> > >
> > > Is there a reason to force the first partition instead of using the
> > > EFI partition code to select which partition to boot?
> > >
> > > I also wonder, on a Linux system, is there a reason the EFI
> > > partition must use FAT?
> >
> > I need to revise the commit message for this patch. The script is not fixed
> to the first partition of the selected MMC, it scans the disk for partitions
> marked bootable, then checks each one of those until it finds the
> imxboard_efi.fd binary.
> 
> That is indeed very different from first FAT partition.  Does bootable only
> apply legacy MBR partition tables?  I didn't think bootable was typically used
> with GPT tables.  There is a bit, but it's not used to mark EFI partitions.
> 
> Which brings me back to the partition type.  Isn't that the right way to find
> the EFI?

The is_bootable function in disk/part_efi.c marks a partition as bootable if the partition_type_guid on disk matches the EFI PARTITION_SYSTEM_GUID.
The part command with the -bootable flag will return the EFI partition on both GPT and MBR partition schemes. This method is also used by config_distro_bootcmd.h

> 
> > We could switch over to using the generic load from
> CONFIG_CMD_FS_GENERIC if there's demand for non-FAT filesystems.
> We're currently using fatload because the EFI partitions in our Windows
> images are always FAT formatted.
> 
> You're original search method required the partition be FAT.

I'm happy to switch from the fatload command over to the load command if it will make CONFIG_UEFI_BOOT more widely useful.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 06/11] mx7dsabresd: Add Windows boot support for iMX7 Sabre
  2018-07-16 18:22   ` Trent Piepho
@ 2018-07-17  1:41     ` Henry Beberman
  2018-07-17 17:02       ` Trent Piepho
  0 siblings, 1 reply; 33+ messages in thread
From: Henry Beberman @ 2018-07-17  1:41 UTC (permalink / raw)
  To: u-boot

> -----Original Message-----
> From: Trent Piepho <tpiepho@impinj.com>
> Sent: Monday, July 16, 2018 11:22 AM
> To: Henry Beberman <Henry.Beberman@microsoft.com>; u-
> boot at lists.denx.de
> Cc: fabio.estevam at nxp.com; adrian.alonso at nxp.com
> Subject: Re: [U-Boot] [PATCH 06/11] mx7dsabresd: Add Windows boot
> support for iMX7 Sabre
> 
> On Sat, 2018-07-14 at 00:11 +0000, Henry Beberman wrote:
> > From: Henry Beberman <henry.beberman@microsoft.com>
> >
> > This patch adds a new bootable configuration for Windows 10 IoT Core
> > on the i.MX7 Dual Sabre board.
> >
> > It enables SPL on the i.MX7 Sabre in order to support the FIT load of
> > OP-TEE and U-Boot proper.
> >
> 
> > diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index
> > f186120684..3fb9b72703 100644
> > --- a/drivers/gpio/Makefile
> > +++ b/drivers/gpio/Makefile
> > @@ -7,10 +7,13 @@ ifndef CONFIG_SPL_BUILD
> >  obj-$(CONFIG_DWAPB_GPIO)	+= dwapb_gpio.o
> >  obj-$(CONFIG_AXP_GPIO)		+= axp_gpio.o
> >  endif
> > +
> > +ifeq ($(CONFIG_$(SPL_TPL_)DM),y)
> >  obj-$(CONFIG_DM_GPIO)		+= gpio-uclass.o
> >
> >  obj-$(CONFIG_DM_PCA953X)	+= pca953x_gpio.o
> >  obj-$(CONFIG_DM_74X164)		+= 74x164_gpio.o
> > +endif
> 
> It doesn't look like this patch is specific to mx7 or Windows.  Perhaps it should
> be in a different commit?

I agree that this change probably belongs in its own patch.
I've left it in this patch so far because it's required to build the new mx7dsabresd_nt_defconfig.

> Also, the help text for SPL_DM says it turns on basic DM support in SPL.  But
> not any specific hardware drivers.  Those all have additional config options to
> turn them on.  It doesn't seems right to bundle a selection of GPIO drivers
> along with CONFIG_SPL_DM.

This issue has cropped up because this patch adds SPL support to mx7dsabresd, but intentionally does not enable SPL_DM.
The defconfig contains CONFIG_DM_74X164 for use in U-Boot Proper, but because drivers/gpio/Makefile also runs during the SPL portion of the build that config still pulls in the 74X164 driver which fails to build due to missing dependencies.

Wrapping the DM objects in CONFIG_$(SPL_TPL_)DM ensures that DM is actually enabled for the current portion of the build when deciding to build the DM drivers. 

Thanks,
Henry

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 06/11] mx7dsabresd: Add Windows boot support for iMX7 Sabre
  2018-07-17  1:41     ` Henry Beberman
@ 2018-07-17 17:02       ` Trent Piepho
  2018-07-17 21:31         ` Henry Beberman
  0 siblings, 1 reply; 33+ messages in thread
From: Trent Piepho @ 2018-07-17 17:02 UTC (permalink / raw)
  To: u-boot

On Tue, 2018-07-17 at 01:41 +0000, Henry Beberman wrote:
> > -----Original Message-----
> > From: Trent Piepho <tpiepho@impinj.com>
> > Sent: Monday, July 16, 2018 11:22 AM
> > To: Henry Beberman <Henry.Beberman@microsoft.com>; u-
> > boot at lists.denx.de
> > Cc: fabio.estevam at nxp.com; adrian.alonso at nxp.com
> > Subject: Re: [U-Boot] [PATCH 06/11] mx7dsabresd: Add Windows boot
> > support for iMX7 Sabre
> > 
> > On Sat, 2018-07-14 at 00:11 +0000, Henry Beberman wrote:
> > > From: Henry Beberman <henry.beberman@microsoft.com>
> > > 
> > > This patch adds a new bootable configuration for Windows 10 IoT Core
> > > on the i.MX7 Dual Sabre board.
> > > 
> > > It enables SPL on the i.MX7 Sabre in order to support the FIT load of
> > > OP-TEE and U-Boot proper.
> > > 
> > > diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index
> > > f186120684..3fb9b72703 100644
> > > --- a/drivers/gpio/Makefile
> > > +++ b/drivers/gpio/Makefile
> > > @@ -7,10 +7,13 @@ ifndef CONFIG_SPL_BUILD
> > >  obj-$(CONFIG_DWAPB_GPIO)	+= dwapb_gpio.o
> > >  obj-$(CONFIG_AXP_GPIO)		+= axp_gpio.o
> > >  endif
> > > +
> > > +ifeq ($(CONFIG_$(SPL_TPL_)DM),y)
> > >  obj-$(CONFIG_DM_GPIO)		+= gpio-uclass.o
> > > 
> > >  obj-$(CONFIG_DM_PCA953X)	+= pca953x_gpio.o
> > >  obj-$(CONFIG_DM_74X164)		+= 74x164_gpio.o
> > > +endif
> > 
> > It doesn't look like this patch is specific to mx7 or Windows.  Perhaps it should
> > be in a different commit?
> 
> I agree that this change probably belongs in its own patch.
> I've left it in this patch so far because it's required to build the new mx7dsabresd_nt_defconfig.

Easy enough to split out and put first.  The person on different
hardware trying to figure out the u-boot build spaghetti it's helped
much knowing the person who added it was working on windows 10 support,
but nothing about the reason for this change.

> > Also, the help text for SPL_DM says it turns on basic DM support in SPL.  But
> > not any specific hardware drivers.  Those all have additional config options to
> > turn them on.  It doesn't seems right to bundle a selection of GPIO drivers
> > along with CONFIG_SPL_DM.
> 
> This issue has cropped up because this patch adds SPL support to mx7dsabresd, but intentionally does not enable SPL_DM.
> The defconfig contains CONFIG_DM_74X164 for use in U-Boot Proper, but because drivers/gpio/Makefile also runs during the SPL portion of the build that config still pulls in the 74X164 driver which fails to build due to missing dependencies.
> 
> Wrapping the DM objects in CONFIG_$(SPL_TPL_)DM ensures that DM is actually enabled for the current portion of the build when deciding to build the DM drivers. 

But isn't it odd that not a single other driver is wrapped this way? 
What's special here?

I think the underlying flaw is the the kbuild system doesn't support
the concept of building multiple times in different modes, e.g. main,
SPL, TPL.  And rather than design something, one gets layers of board
specific hacks.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc
  2018-07-16 17:16   ` Trent Piepho
  2018-07-16 22:28     ` Henry Beberman
@ 2018-07-17 17:09     ` Fabio Estevam
  2018-07-17 17:20       ` Henry Beberman
  1 sibling, 1 reply; 33+ messages in thread
From: Fabio Estevam @ 2018-07-17 17:09 UTC (permalink / raw)
  To: u-boot

Hi Henry,

On Mon, Jul 16, 2018 at 2:16 PM, Trent Piepho <tpiepho@impinj.com> wrote:
> On Sat, 2018-07-14 at 00:11 +0000, Henry Beberman wrote:
>> From: Henry Beberman <henry.beberman@microsoft.com>
>>
>> This patch enables i.MX platforms to easily add a boot script to their
>> U-Boot Proper environment to automatically load and execute an EFI
>> firmware from the first FAT partition of an MMC device.

Have you subscribed to the U-Boot list?

I don't see this series in the list archives, only on my NXP account.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc
  2018-07-17 17:09     ` Fabio Estevam
@ 2018-07-17 17:20       ` Henry Beberman
  0 siblings, 0 replies; 33+ messages in thread
From: Henry Beberman @ 2018-07-17 17:20 UTC (permalink / raw)
  To: u-boot

Hi Fabio,

> -----Original Message-----
> From: Fabio Estevam <festevam@gmail.com>
> Sent: Tuesday, July 17, 2018 10:09 AM
> To: Trent Piepho <tpiepho@impinj.com>
> Cc: Henry Beberman <Henry.Beberman@microsoft.com>; u-
> boot at lists.denx.de; fabio.estevam at nxp.com; trini at konsulko.com
> Subject: Re: [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI
> from mmc
> 
> Hi Henry,
> 
> On Mon, Jul 16, 2018 at 2:16 PM, Trent Piepho <tpiepho@impinj.com> wrote:
> > On Sat, 2018-07-14 at 00:11 +0000, Henry Beberman wrote:
> >> From: Henry Beberman <henry.beberman@microsoft.com>
> >>
> >> This patch enables i.MX platforms to easily add a boot script to
> >> their U-Boot Proper environment to automatically load and execute an
> >> EFI firmware from the first FAT partition of an MMC device.
> 
> Have you subscribed to the U-Boot list?
> 
> I don't see this series in the list archives, only on my NXP account.

I'm subscribed to the U-Boot list and I included the mailing list when sending out the series, but I got a notice that they were held until moderator approval.
I saw the patches in the archive here https://lists.denx.de/pipermail/u-boot/2018-July/thread.html#334680 and on the patch tracker so I assumed they went out successfully.

Thanks,
Henry

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc
  2018-07-16 23:56         ` Henry Beberman
@ 2018-07-17 17:24           ` Trent Piepho
  2018-07-18  0:52             ` Henry Beberman
  0 siblings, 1 reply; 33+ messages in thread
From: Trent Piepho @ 2018-07-17 17:24 UTC (permalink / raw)
  To: u-boot

On Mon, 2018-07-16 at 23:56 +0000, Henry Beberman wrote:
> > 
> > > 
> > > I need to revise the commit message for this patch. The script is not fixed
> > 
> > to the first partition of the selected MMC, it scans the disk for partitions
> > marked bootable, then checks each one of those until it finds the
> > imxboard_efi.fd binary.
> > 
> > That is indeed very different from first FAT partition.  Does bootable only
> > apply legacy MBR partition tables?  I didn't think bootable was typically used
> > with GPT tables.  There is a bit, but it's not used to mark EFI partitions.
> > 
> > Which brings me back to the partition type.  Isn't that the right way to find
> > the EFI?
> 
> The is_bootable function in disk/part_efi.c marks a partition as bootable if the partition_type_guid on disk matches the EFI PARTITION_SYSTEM_GUID.
> The part command with the -bootable flag will return the EFI partition on both GPT and MBR partition schemes. This method is also used by config_distro_bootcmd.h

But it also finds any partitions with the legacy bios bootable flag set
in a GPT table or the active partition bit set in a MBR table, or any
future reason a partition might be considered bootable.  Someone trying
to add a new type of bootable partition to distro bootcmd will be
forced to deal with your windows nt boot command as it tries to boot
any bootable partition, even ones it can't boot.

The distro boot command is designed to boot anything, so it searches
for partitions beyond EFI.  But what you've done is just for EFI. 
That's why it's different.

> > > We could switch over to using the generic load from
> > 
> > CONFIG_CMD_FS_GENERIC if there's demand for non-FAT filesystems.
> > We're currently using fatload because the EFI partitions in our Windows
> > images are always FAT formatted.
> > 
> > You're original search method required the partition be FAT.
> 
> I'm happy to switch from the fatload command over to the load command if it will make CONFIG_UEFI_BOOT more widely useful.

My comment was addressing the incorrect commit message that indicated
boot partition selection was linked to the FAT filesystem.  I don't
know if loading EFI from non-FAT partitions will be useful.  I'm not
planning on using EFI but I like to avoid FAT in my products.  If you
had linked the boot partition selection to FAT, it would cut off future
options.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 06/11] mx7dsabresd: Add Windows boot support for iMX7 Sabre
  2018-07-17 17:02       ` Trent Piepho
@ 2018-07-17 21:31         ` Henry Beberman
  0 siblings, 0 replies; 33+ messages in thread
From: Henry Beberman @ 2018-07-17 21:31 UTC (permalink / raw)
  To: u-boot

> -----Original Message-----
> From: Trent Piepho <tpiepho@impinj.com>
> Sent: Tuesday, July 17, 2018 10:03 AM
> To: Henry Beberman <Henry.Beberman@microsoft.com>; u-
> boot at lists.denx.de
> Cc: fabio.estevam at nxp.com; adrian.alonso at nxp.com
> Subject: Re: [U-Boot] [PATCH 06/11] mx7dsabresd: Add Windows boot
> support for iMX7 Sabre
> 
> On Tue, 2018-07-17 at 01:41 +0000, Henry Beberman wrote:
> > > -----Original Message-----
> > > From: Trent Piepho <tpiepho@impinj.com>
> > > Sent: Monday, July 16, 2018 11:22 AM
> > > To: Henry Beberman <Henry.Beberman@microsoft.com>; u-
> > > boot at lists.denx.de
> > > Cc: fabio.estevam at nxp.com; adrian.alonso at nxp.com
> > > Subject: Re: [U-Boot] [PATCH 06/11] mx7dsabresd: Add Windows boot
> > > support for iMX7 Sabre
> > >
> > > On Sat, 2018-07-14 at 00:11 +0000, Henry Beberman wrote:
> > > > From: Henry Beberman <henry.beberman@microsoft.com>
> > > >
> > > > This patch adds a new bootable configuration for Windows 10 IoT
> > > > Core on the i.MX7 Dual Sabre board.
> > > >
> > > > It enables SPL on the i.MX7 Sabre in order to support the FIT load
> > > > of OP-TEE and U-Boot proper.
> > > >
> > > > diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index
> > > > f186120684..3fb9b72703 100644
> > > > --- a/drivers/gpio/Makefile
> > > > +++ b/drivers/gpio/Makefile
> > > > @@ -7,10 +7,13 @@ ifndef CONFIG_SPL_BUILD
> > > >  obj-$(CONFIG_DWAPB_GPIO)	+= dwapb_gpio.o
> > > >  obj-$(CONFIG_AXP_GPIO)		+= axp_gpio.o
> > > >  endif
> > > > +
> > > > +ifeq ($(CONFIG_$(SPL_TPL_)DM),y)
> > > >  obj-$(CONFIG_DM_GPIO)		+= gpio-uclass.o
> > > >
> > > >  obj-$(CONFIG_DM_PCA953X)	+= pca953x_gpio.o
> > > >  obj-$(CONFIG_DM_74X164)		+= 74x164_gpio.o
> > > > +endif
> > >
> > > It doesn't look like this patch is specific to mx7 or Windows.
> > > Perhaps it should be in a different commit?
> >
> > I agree that this change probably belongs in its own patch.
> > I've left it in this patch so far because it's required to build the new
> mx7dsabresd_nt_defconfig.
> 
> Easy enough to split out and put first.  The person on different hardware
> trying to figure out the u-boot build spaghetti it's helped much knowing the
> person who added it was working on windows 10 support, but nothing about
> the reason for this change.
> 
> > > Also, the help text for SPL_DM says it turns on basic DM support in
> > > SPL.  But not any specific hardware drivers.  Those all have
> > > additional config options to turn them on.  It doesn't seems right
> > > to bundle a selection of GPIO drivers along with CONFIG_SPL_DM.
> >
> > This issue has cropped up because this patch adds SPL support to
> mx7dsabresd, but intentionally does not enable SPL_DM.
> > The defconfig contains CONFIG_DM_74X164 for use in U-Boot Proper, but
> because drivers/gpio/Makefile also runs during the SPL portion of the build
> that config still pulls in the 74X164 driver which fails to build due to missing
> dependencies.
> >
> > Wrapping the DM objects in CONFIG_$(SPL_TPL_)DM ensures that DM is
> actually enabled for the current portion of the build when deciding to build
> the DM drivers.
> 
> But isn't it odd that not a single other driver is wrapped this way?
> What's special here?
> 
> I think the underlying flaw is the the kbuild system doesn't support the
> concept of building multiple times in different modes, e.g. main, SPL, TPL.
> And rather than design something, one gets layers of board specific hacks.

There are a few other instances of omitting DM drivers from SPL due to size concerns, see drivers/power/regulator/Makefile (commit a35332f) and drivers/mmc/Makefile (commit c4d660d)

However instead of wrapping the block in CONFIG_$(SPL_TPL_)DM, the intended way is to include $(SPL_) in line with the driver you need to disable for SPL.
- obj-$(CONFIG_DM_74X164)  += 74x164_gpio.o
+ obj-$(CONFIG_$(SPL_)DM_74X164)  += 74x164_gpio.o

I'll switch to this in-line method and split out this change into a separate patch so the commit message explains it in isolation.

Thanks,
Henry

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc
  2018-07-17 17:24           ` Trent Piepho
@ 2018-07-18  0:52             ` Henry Beberman
  0 siblings, 0 replies; 33+ messages in thread
From: Henry Beberman @ 2018-07-18  0:52 UTC (permalink / raw)
  To: u-boot

> -----Original Message-----
> From: Trent Piepho <tpiepho@impinj.com>
> Sent: Tuesday, July 17, 2018 10:24 AM
> To: Henry Beberman <Henry.Beberman@microsoft.com>; u-
> boot at lists.denx.de
> Cc: trini at konsulko.com; fabio.estevam at nxp.com
> Subject: Re: [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI
> from mmc
> 
> On Mon, 2018-07-16 at 23:56 +0000, Henry Beberman wrote:
> > >
> > > >
> > > > I need to revise the commit message for this patch. The script is
> > > > not fixed
> > >
> > > to the first partition of the selected MMC, it scans the disk for
> > > partitions marked bootable, then checks each one of those until it
> > > finds the imxboard_efi.fd binary.
> > >
> > > That is indeed very different from first FAT partition.  Does
> > > bootable only apply legacy MBR partition tables?  I didn't think
> > > bootable was typically used with GPT tables.  There is a bit, but it's not
> used to mark EFI partitions.
> > >
> > > Which brings me back to the partition type.  Isn't that the right
> > > way to find the EFI?
> >
> > The is_bootable function in disk/part_efi.c marks a partition as bootable if
> the partition_type_guid on disk matches the EFI PARTITION_SYSTEM_GUID.
> > The part command with the -bootable flag will return the EFI partition
> > on both GPT and MBR partition schemes. This method is also used by
> > config_distro_bootcmd.h
> 
> But it also finds any partitions with the legacy bios bootable flag set in a GPT
> table or the active partition bit set in a MBR table, or any future reason a
> partition might be considered bootable.  Someone trying to add a new type
> of bootable partition to distro bootcmd will be forced to deal with your
> windows nt boot command as it tries to boot any bootable partition, even
> ones it can't boot.
> 
> The distro boot command is designed to boot anything, so it searches for
> partitions beyond EFI.  But what you've done is just for EFI.
> That's why it's different.

It doesn’t matter if someone adds a new type of bootable partition in the future, the UEFI boot command will fail to find the imxboard_efi.fd binary then move along to check the next bootable partition.

Adding this boot command will not increase maintenance on config_distro_bootcmd.h. The UEFI boot command is only used when the defconfig selects CONFIG_UEFI_BOOT, and the board's include/configs header has been modified to include config_uefi_bootcmd.h instead of config_distro_bootcmd.h when the config is set.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc
  2018-07-14  0:11 ` [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc Henry Beberman
  2018-07-16 17:16   ` Trent Piepho
@ 2018-08-07 11:11   ` Stefano Babic
  2018-08-07 11:16     ` Tom Rini
  1 sibling, 1 reply; 33+ messages in thread
From: Stefano Babic @ 2018-08-07 11:11 UTC (permalink / raw)
  To: u-boot

Hi Henry,

On 14/07/2018 02:11, Henry Beberman wrote:
> From: Henry Beberman <henry.beberman@microsoft.com>
> 
> This patch enables i.MX platforms to easily add a boot script to their
> U-Boot Proper environment to automatically load and execute an EFI
> firmware from the first FAT partition of an MMC device.
> 
> This is a portion of enabling the Windows 10 IoT Core boot path.
> 
> The go command is overridden when CONFIG_UEFI_BOOT is specified. This
> new go will perform a cache flush/disable, disable interrupts, then
> jump to the address where UEFI was loaded.
> 
> This patch adds two new Kconfig options:
> CONFIG_UEFI_BOOT: Selects the UEFI bootcmd and overrides go to flush
> caches and disable interrupts.
> CONFIG_UEFI_LOAD_ADDR: Specifies the load address for the UEFI image
> 
> Signed-off-by: Henry Beberman <henry.beberman@microsoft.com>
> Cc: Stefano Babic <sbabic@denx.de>
> Cc: Fabio Estevam <fabio.estevam@nxp.com>
> Cc: Tom Rini <trini@konsulko.com>
> ---
>  arch/arm/mach-imx/Makefile    |  1 +
>  arch/arm/mach-imx/boot.c      | 19 +++++++++++++++++++
>  common/Kconfig                | 17 +++++++++++++++++
>  include/config_uefi_bootcmd.h | 29 +++++++++++++++++++++++++++++
>  4 files changed, 66 insertions(+)
>  create mode 100644 arch/arm/mach-imx/boot.c
>  create mode 100644 include/config_uefi_bootcmd.h
> 

I am really missing why we need this specially for i.MX. There is
nothing special to i.MX, and if this command is necessary, we should put
it in common code.

Anyway, should we not try to merge it with the general support for UEFI
in U-Boot ? We have already a "bootefi" command (aarch64 and x86,
currently).

> diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
> index 733c308670..a81af51f03 100644
> --- a/arch/arm/mach-imx/Makefile
> +++ b/arch/arm/mach-imx/Makefile
> @@ -42,6 +42,7 @@ endif
>  obj-$(CONFIG_SATA) += sata.o
>  obj-$(CONFIG_SECURE_BOOT)    += hab.o
>  obj-$(CONFIG_SYSCOUNTER_TIMER) += syscounter.o
> +obj-$(CONFIG_UEFI_BOOT) += boot.o
>  endif
>  ifeq ($(SOC),$(filter $(SOC),mx7ulp))
>  obj-y  += cache.o
> diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
> new file mode 100644
> index 0000000000..457a323fa2
> --- /dev/null
> +++ b/arch/arm/mach-imx/boot.c
> @@ -0,0 +1,19 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2018 Microsoft Corporation
> + */
> +
> +#include <common.h>
> +#include <command.h>
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +#if defined(CONFIG_UEFI_BOOT)
> +unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
> +			 char * const argv[])
> +{
> +	cleanup_before_linux();
> +
> +	return entry(argc, argv);
> +}
> +#endif /* CONFIG_UEFI_BOOT */
> diff --git a/common/Kconfig b/common/Kconfig
> index 4c7a1a9af8..35362b629c 100644
> --- a/common/Kconfig
> +++ b/common/Kconfig
> @@ -217,6 +217,23 @@ config BOOTCOMMAND
>  	  This is the string of commands that will be used as bootcmd and if
>  	  AUTOBOOT is set, automatically run.
>  
> +config UEFI_BOOT
> +	bool "Boot a UEFI firmware loaded from the first FAT partition on the mmc"
> +	default n
> +	help
> +	  Override the CONFIG_BOOTCOMMAND to load a UEFI firmware image from the
> +	  first FAT partition on the mmc. Override the go command to make it disable
> +	  interrupts and flush the cache before jumping to the specified address.
> +
> +config UEFI_LOAD_ADDR
> +	hex "Load address for the UEFI image"
> +	depends on UEFI_BOOT
> +	help
> +	  CONFIG_UEFI_BOOT uses this as the address to load the UEFI image.
> +	  The uefi_bootcmd script in the environment will fatload efi from the mmc
> +	  to this location, then use an overridden go command to disable caches and
> +	  interrupts then jump to this location.
> +
>  menu "Console"
>  
>  config MENU
> diff --git a/include/config_uefi_bootcmd.h b/include/config_uefi_bootcmd.h
> new file mode 100644
> index 0000000000..03903abf8f
> --- /dev/null
> +++ b/include/config_uefi_bootcmd.h
> @@ -0,0 +1,29 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * Copyright (C) 2018 Microsoft Corporation
> + */
> +
> +#ifndef _CONFIG_UEFI_BOOTCMD_H
> +#define _CONFIG_UEFI_BOOTCMD_H
> +
> +#define BOOTENV \
> +	"uefi_image_name=imxboard_efi.fd\0" \
> +	"uefi_addr=" __stringify(CONFIG_UEFI_LOAD_ADDR) "\0" \
> +	"uefi_bootcmd=" \
> +		"part list mmc ${mmcdev} -bootable devplist; " \
> +		"env exists devplist || setenv devplist 1; " \
> +		"for bootpart in ${devplist}; do " \
> +			"if fatload mmc ${mmcdev}:${bootpart} " \
> +			"${uefi_addr} ${uefi_image_name}; then " \
> +				"echo \"Jumping to ${uefi_image_name} at " \
> +				"${uefi_addr}\"; " \
> +				"go ${uefi_addr}; " \
> +			"fi; " \
> +		"done; " \
> +		"echo \"Could not find ${uefi_image_name} on mmc ${mmcdev}\";\0"
> +
> +#ifdef CONFIG_UEFI_BOOT
> +#define CONFIG_BOOTCOMMAND "run uefi_bootcmd"
> +#endif
> +
> +#endif  /* _CONFIG_UEFI_BOOTCMD_H */
> 

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc
  2018-08-07 11:11   ` Stefano Babic
@ 2018-08-07 11:16     ` Tom Rini
  2018-08-07 13:45       ` Alexander Graf
  0 siblings, 1 reply; 33+ messages in thread
From: Tom Rini @ 2018-08-07 11:16 UTC (permalink / raw)
  To: u-boot

On Tue, Aug 07, 2018 at 01:11:11PM +0200, Stefano Babic wrote:
> Hi Henry,
> 
> On 14/07/2018 02:11, Henry Beberman wrote:
> > From: Henry Beberman <henry.beberman@microsoft.com>
> > 
> > This patch enables i.MX platforms to easily add a boot script to their
> > U-Boot Proper environment to automatically load and execute an EFI
> > firmware from the first FAT partition of an MMC device.
> > 
> > This is a portion of enabling the Windows 10 IoT Core boot path.
> > 
> > The go command is overridden when CONFIG_UEFI_BOOT is specified. This
> > new go will perform a cache flush/disable, disable interrupts, then
> > jump to the address where UEFI was loaded.
> > 
> > This patch adds two new Kconfig options:
> > CONFIG_UEFI_BOOT: Selects the UEFI bootcmd and overrides go to flush
> > caches and disable interrupts.
> > CONFIG_UEFI_LOAD_ADDR: Specifies the load address for the UEFI image
> > 
> > Signed-off-by: Henry Beberman <henry.beberman@microsoft.com>
> > Cc: Stefano Babic <sbabic@denx.de>
> > Cc: Fabio Estevam <fabio.estevam@nxp.com>
> > Cc: Tom Rini <trini@konsulko.com>
> > ---
> >  arch/arm/mach-imx/Makefile    |  1 +
> >  arch/arm/mach-imx/boot.c      | 19 +++++++++++++++++++
> >  common/Kconfig                | 17 +++++++++++++++++
> >  include/config_uefi_bootcmd.h | 29 +++++++++++++++++++++++++++++
> >  4 files changed, 66 insertions(+)
> >  create mode 100644 arch/arm/mach-imx/boot.c
> >  create mode 100644 include/config_uefi_bootcmd.h
> > 
> 
> I am really missing why we need this specially for i.MX. There is
> nothing special to i.MX, and if this command is necessary, we should put
> it in common code.
> 
> Anyway, should we not try to merge it with the general support for UEFI
> in U-Boot ? We have already a "bootefi" command (aarch64 and x86,
> currently).

Agreed, this should be folded in with our existing UEFI support, thanks!

> 
> > diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
> > index 733c308670..a81af51f03 100644
> > --- a/arch/arm/mach-imx/Makefile
> > +++ b/arch/arm/mach-imx/Makefile
> > @@ -42,6 +42,7 @@ endif
> >  obj-$(CONFIG_SATA) += sata.o
> >  obj-$(CONFIG_SECURE_BOOT)    += hab.o
> >  obj-$(CONFIG_SYSCOUNTER_TIMER) += syscounter.o
> > +obj-$(CONFIG_UEFI_BOOT) += boot.o
> >  endif
> >  ifeq ($(SOC),$(filter $(SOC),mx7ulp))
> >  obj-y  += cache.o
> > diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
> > new file mode 100644
> > index 0000000000..457a323fa2
> > --- /dev/null
> > +++ b/arch/arm/mach-imx/boot.c
> > @@ -0,0 +1,19 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * Copyright (C) 2018 Microsoft Corporation
> > + */
> > +
> > +#include <common.h>
> > +#include <command.h>
> > +
> > +DECLARE_GLOBAL_DATA_PTR;
> > +
> > +#if defined(CONFIG_UEFI_BOOT)
> > +unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
> > +			 char * const argv[])
> > +{
> > +	cleanup_before_linux();
> > +
> > +	return entry(argc, argv);
> > +}
> > +#endif /* CONFIG_UEFI_BOOT */
> > diff --git a/common/Kconfig b/common/Kconfig
> > index 4c7a1a9af8..35362b629c 100644
> > --- a/common/Kconfig
> > +++ b/common/Kconfig
> > @@ -217,6 +217,23 @@ config BOOTCOMMAND
> >  	  This is the string of commands that will be used as bootcmd and if
> >  	  AUTOBOOT is set, automatically run.
> >  
> > +config UEFI_BOOT
> > +	bool "Boot a UEFI firmware loaded from the first FAT partition on the mmc"
> > +	default n
> > +	help
> > +	  Override the CONFIG_BOOTCOMMAND to load a UEFI firmware image from the
> > +	  first FAT partition on the mmc. Override the go command to make it disable
> > +	  interrupts and flush the cache before jumping to the specified address.
> > +
> > +config UEFI_LOAD_ADDR
> > +	hex "Load address for the UEFI image"
> > +	depends on UEFI_BOOT
> > +	help
> > +	  CONFIG_UEFI_BOOT uses this as the address to load the UEFI image.
> > +	  The uefi_bootcmd script in the environment will fatload efi from the mmc
> > +	  to this location, then use an overridden go command to disable caches and
> > +	  interrupts then jump to this location.
> > +
> >  menu "Console"
> >  
> >  config MENU
> > diff --git a/include/config_uefi_bootcmd.h b/include/config_uefi_bootcmd.h
> > new file mode 100644
> > index 0000000000..03903abf8f
> > --- /dev/null
> > +++ b/include/config_uefi_bootcmd.h
> > @@ -0,0 +1,29 @@
> > +/* SPDX-License-Identifier: GPL-2.0+ */
> > +/*
> > + * Copyright (C) 2018 Microsoft Corporation
> > + */
> > +
> > +#ifndef _CONFIG_UEFI_BOOTCMD_H
> > +#define _CONFIG_UEFI_BOOTCMD_H
> > +
> > +#define BOOTENV \
> > +	"uefi_image_name=imxboard_efi.fd\0" \
> > +	"uefi_addr=" __stringify(CONFIG_UEFI_LOAD_ADDR) "\0" \
> > +	"uefi_bootcmd=" \
> > +		"part list mmc ${mmcdev} -bootable devplist; " \
> > +		"env exists devplist || setenv devplist 1; " \
> > +		"for bootpart in ${devplist}; do " \
> > +			"if fatload mmc ${mmcdev}:${bootpart} " \
> > +			"${uefi_addr} ${uefi_image_name}; then " \
> > +				"echo \"Jumping to ${uefi_image_name} at " \
> > +				"${uefi_addr}\"; " \
> > +				"go ${uefi_addr}; " \
> > +			"fi; " \
> > +		"done; " \
> > +		"echo \"Could not find ${uefi_image_name} on mmc ${mmcdev}\";\0"
> > +
> > +#ifdef CONFIG_UEFI_BOOT
> > +#define CONFIG_BOOTCOMMAND "run uefi_bootcmd"
> > +#endif
> > +
> > +#endif  /* _CONFIG_UEFI_BOOTCMD_H */
> > 
> 
> Best regards,
> Stefano Babic
> 
> -- 
> =====================================================================
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
> =====================================================================

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180807/0fe1d02b/attachment.sig>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 04/11] spl: imx: Add optional lds to keep SPL entirely in on-chip RAM
  2018-07-14  0:11 ` [U-Boot] [PATCH 04/11] spl: imx: Add optional lds to keep SPL entirely in on-chip RAM Henry Beberman
  2018-07-16 17:32   ` Trent Piepho
@ 2018-08-07 12:17   ` Stefano Babic
  2018-08-08  3:22     ` Henry Beberman
  1 sibling, 1 reply; 33+ messages in thread
From: Stefano Babic @ 2018-08-07 12:17 UTC (permalink / raw)
  To: u-boot

Hi Henry,

On 14/07/2018 02:11, Henry Beberman wrote:
> From: Henry Beberman <henry.beberman@microsoft.com>
> 
> This patch is part of the i.MX Windows 10 IoT Core boot flow.
> 
> It adds a modified linker script for SPL to keep all segments in
> on-chip ram. This is to harden the device against potential leaks of
> device secrets by keeping them out of DRAM.
> 
> Additionally if CONFIG_SYS_SPL_MALLOC_START is defined, it will
> override the CONFIG_SPL_SYS_MALLOC_SIMPLE and allocate space in DRAM
> instead of on-chip ram. This patch prevents the definition of those
> values for i.MX6 and i.MX7 SPL if CONFIG_OPTEE_SPL_BOOT is selected.
> 

I guess there should be some kind of restrictions to be set according to
the i.MX6 variant. I have already had some projects where I get rid of
all space available on OCRAM. The smaller i.MX6 has just 64KB of RAM -
have you tested also on them ? I wonder if there is enough space for all
i.MX variants, specially if some other options are enabled.

> Signed-off-by: Henry Beberman <henry.beberman@microsoft.com>
> Cc: Stefano Babic <sbabic@denx.de>
> Cc: Fabio Estevam <fabio.estevam@nxp.com>
> ---
>  arch/arm/mach-imx/u-boot-spl-sram.lds | 59 +++++++++++++++++++++++++++++++++++
>  include/configs/imx6_spl.h            |  2 ++
>  include/configs/imx7_spl.h            |  2 ++
>  3 files changed, 63 insertions(+)
>  create mode 100644 arch/arm/mach-imx/u-boot-spl-sram.lds
> 
> diff --git a/arch/arm/mach-imx/u-boot-spl-sram.lds b/arch/arm/mach-imx/u-boot-spl-sram.lds
> new file mode 100644
> index 0000000000..dfbb4aef5d
> --- /dev/null
> +++ b/arch/arm/mach-imx/u-boot-spl-sram.lds
> @@ -0,0 +1,59 @@
> +/*
> + * (C) Copyright 2002
> + * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
> + *
> + * (C) Copyright 2010
> + * Texas Instruments, <www.ti.com>
> + *	Aneesh V <aneesh@ti.com>
> + *
> + * (C) Copyright 2018 Microsoft Corporation
> + *
> + * SPDX-License-Identifier:	GPL-2.0+
> + */
> +
> +MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE,\
> +		LENGTH = CONFIG_SPL_MAX_SIZE }
> +
> +OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
> +OUTPUT_ARCH(arm)
> +ENTRY(_start)
> +SECTIONS
> +{
> +	.text      :
> +	{
> +		__start = .;
> +		*(.vectors)
> +		arch/arm/cpu/armv7/start.o	(.text*)
> +		*(.text*)
> +	} >.sram
> +
> +	. = ALIGN(4);
> +	.rodata : { *(SORT_BY_ALIGNMENT(.rodata*)) } >.sram
> +
> +	. = ALIGN(4);
> +	.data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram
> +
> +	. = ALIGN(4);
> +	.u_boot_list : {
> +		KEEP(*(SORT(.u_boot_list*)));
> +	} >.sram
> +
> +	. = ALIGN(4);
> +	__image_copy_end = .;
> +
> +	.end :
> +	{
> +		*(.__end)
> +	}
> +
> +	_image_binary_end = .;
> +
> +	.bss :
> +	{
> +		. = ALIGN(4);
> +		__bss_start = .;
> +		*(.bss*)
> +		. = ALIGN(4);
> +		__bss_end = .;
> +	} >.sram
> +}

This is more or less a copy of the armv8 version + bss in sram instead
of sdram. In any case, mach-imx is not the right place because it is
quite SOC independent. The whole i.MX do not use own lds but they are
using the general scripts from ARM 32bit.

> diff --git a/include/configs/imx6_spl.h b/include/configs/imx6_spl.h
> index 720ff045a7..4088e8a936 100644
> --- a/include/configs/imx6_spl.h
> +++ b/include/configs/imx6_spl.h
> @@ -51,6 +51,7 @@
>  # endif
>  #endif
>  
> +#ifndef CONFIG_OPTEE_SPL_BOOT
>  #if defined(CONFIG_MX6SX) || defined(CONFIG_MX6SL) || \
>  	defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL)
>  #define CONFIG_SPL_BSS_START_ADDR      0x88200000
> @@ -63,6 +64,7 @@
>  #define CONFIG_SYS_SPL_MALLOC_START	0x18300000
>  #define CONFIG_SYS_SPL_MALLOC_SIZE	0x100000	/* 1 MB */
>  #endif
> +#endif /* !CONFIG_OPTEE_SPL_BOOT */
>  #endif
>  
>  #endif
> diff --git a/include/configs/imx7_spl.h b/include/configs/imx7_spl.h
> index 1eb6cd894d..5dd4aed652 100644
> --- a/include/configs/imx7_spl.h
> +++ b/include/configs/imx7_spl.h
> @@ -46,10 +46,12 @@
>  # endif
>  #endif
>  
> +#ifndef CONFIG_OPTEE_SPL_BOOT
>  #define CONFIG_SPL_BSS_START_ADDR      0x88200000
>  #define CONFIG_SPL_BSS_MAX_SIZE        0x100000		/* 1 MB */
>  #define CONFIG_SYS_SPL_MALLOC_START    0x88300000
>  #define CONFIG_SYS_SPL_MALLOC_SIZE     0x100000		/* 1 MB */
> +#endif /* !CONFIG_OPTEE_SPL_BOOT */
>  
>  #endif /* CONFIG_SPL */

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc
  2018-08-07 11:16     ` Tom Rini
@ 2018-08-07 13:45       ` Alexander Graf
  2018-08-08  2:24         ` Henry Beberman
  0 siblings, 1 reply; 33+ messages in thread
From: Alexander Graf @ 2018-08-07 13:45 UTC (permalink / raw)
  To: u-boot



> Am 07.08.2018 um 12:16 schrieb Tom Rini <trini@konsulko.com>:
> 
>> On Tue, Aug 07, 2018 at 01:11:11PM +0200, Stefano Babic wrote:
>> Hi Henry,
>> 
>>> On 14/07/2018 02:11, Henry Beberman wrote:
>>> From: Henry Beberman <henry.beberman@microsoft.com>
>>> 
>>> This patch enables i.MX platforms to easily add a boot script to their
>>> U-Boot Proper environment to automatically load and execute an EFI
>>> firmware from the first FAT partition of an MMC device.
>>> 
>>> This is a portion of enabling the Windows 10 IoT Core boot path.
>>> 
>>> The go command is overridden when CONFIG_UEFI_BOOT is specified. This
>>> new go will perform a cache flush/disable, disable interrupts, then
>>> jump to the address where UEFI was loaded.
>>> 
>>> This patch adds two new Kconfig options:
>>> CONFIG_UEFI_BOOT: Selects the UEFI bootcmd and overrides go to flush
>>> caches and disable interrupts.
>>> CONFIG_UEFI_LOAD_ADDR: Specifies the load address for the UEFI image
>>> 
>>> Signed-off-by: Henry Beberman <henry.beberman@microsoft.com>
>>> Cc: Stefano Babic <sbabic@denx.de>
>>> Cc: Fabio Estevam <fabio.estevam@nxp.com>
>>> Cc: Tom Rini <trini@konsulko.com>
>>> ---
>>> arch/arm/mach-imx/Makefile    |  1 +
>>> arch/arm/mach-imx/boot.c      | 19 +++++++++++++++++++
>>> common/Kconfig                | 17 +++++++++++++++++
>>> include/config_uefi_bootcmd.h | 29 +++++++++++++++++++++++++++++
>>> 4 files changed, 66 insertions(+)
>>> create mode 100644 arch/arm/mach-imx/boot.c
>>> create mode 100644 include/config_uefi_bootcmd.h
>>> 
>> 
>> I am really missing why we need this specially for i.MX. There is
>> nothing special to i.MX, and if this command is necessary, we should put
>> it in common code.
>> 
>> Anyway, should we not try to merge it with the general support for UEFI
>> in U-Boot ? We have already a "bootefi" command (aarch64 and x86,
>> currently).
> 
> Agreed, this should be folded in with our existing UEFI support, thanks!

Yes, please just use distro boot. Bootefi (which distro boot calls) already supports running UEFI binaries for real even on armv7.


Alex

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc
  2018-08-07 13:45       ` Alexander Graf
@ 2018-08-08  2:24         ` Henry Beberman
  2018-08-15 14:46           ` Alexander Graf
  0 siblings, 1 reply; 33+ messages in thread
From: Henry Beberman @ 2018-08-08  2:24 UTC (permalink / raw)
  To: u-boot



> -----Original Message-----
> From: Alexander Graf <agraf@suse.de>
> Sent: Tuesday, August 7, 2018 6:46 AM
> To: Tom Rini <trini@konsulko.com>
> Cc: Stefano Babic <sbabic@denx.de>; Henry Beberman
> <Henry.Beberman@microsoft.com>; u-boot at lists.denx.de; Fabio Estevam
> <fabio.estevam@nxp.com>
> Subject: Re: [PATCH 01/11] imx: Add bootcmd to load and run UEFI from
> mmc
> 
> 
> 
> > Am 07.08.2018 um 12:16 schrieb Tom Rini <trini@konsulko.com>:
> >
> >> On Tue, Aug 07, 2018 at 01:11:11PM +0200, Stefano Babic wrote:
> >> Hi Henry,
> >>
> >>> On 14/07/2018 02:11, Henry Beberman wrote:
> >>> From: Henry Beberman <henry.beberman@microsoft.com>
> >>>
> >>> This patch enables i.MX platforms to easily add a boot script to
> >>> their U-Boot Proper environment to automatically load and execute an
> >>> EFI firmware from the first FAT partition of an MMC device.
> >>>
> >>> This is a portion of enabling the Windows 10 IoT Core boot path.
> >>>
> >>> The go command is overridden when CONFIG_UEFI_BOOT is specified.
> >>> This new go will perform a cache flush/disable, disable interrupts,
> >>> then jump to the address where UEFI was loaded.
> >>>
> >>> This patch adds two new Kconfig options:
> >>> CONFIG_UEFI_BOOT: Selects the UEFI bootcmd and overrides go to
> flush
> >>> caches and disable interrupts.
> >>> CONFIG_UEFI_LOAD_ADDR: Specifies the load address for the UEFI
> image
> >>>
> >>> Signed-off-by: Henry Beberman <henry.beberman@microsoft.com>
> >>> Cc: Stefano Babic <sbabic@denx.de>
> >>> Cc: Fabio Estevam <fabio.estevam@nxp.com>
> >>> Cc: Tom Rini <trini@konsulko.com>
> >>> ---
> >>> arch/arm/mach-imx/Makefile    |  1 +
> >>> arch/arm/mach-imx/boot.c      | 19 +++++++++++++++++++
> >>> common/Kconfig                | 17 +++++++++++++++++
> >>> include/config_uefi_bootcmd.h | 29
> +++++++++++++++++++++++++++++
> >>> 4 files changed, 66 insertions(+)
> >>> create mode 100644 arch/arm/mach-imx/boot.c create mode 100644
> >>> include/config_uefi_bootcmd.h
> >>>
> >>
> >> I am really missing why we need this specially for i.MX. There is
> >> nothing special to i.MX, and if this command is necessary, we should
> >> put it in common code.
> >>
> >> Anyway, should we not try to merge it with the general support for
> >> UEFI in U-Boot ? We have already a "bootefi" command (aarch64 and
> >> x86, currently).
> >
> > Agreed, this should be folded in with our existing UEFI support, thanks!
> 
> Yes, please just use distro boot. Bootefi (which distro boot calls) already
> supports running UEFI binaries for real even on armv7.
> 
> 
> Alex
> 

Running Windows directly on U-Boot through bootefi is definitely appealing, but
we're dependent on a number of features provided by our full UEFI firmware.

* Several ACPI tables that are unimplemented in U-Boot: CSRT, DBG2, SPCR, TPM2, GTDT
* Some DSDT elements that require the Microsoft ASL compiler (for now)
* UEFI Authenticated Variables that are writeable at runtime.
* UEFI Secure Boot
* Launching and communicating with a Firmware TPM running as an OP-TEE Trusted Application

I'd be happy to break down this patch's changes into more generic steps rather than
creating confusion by adding CONFIG_UEFI_BOOT.

I can move the UEFI binary into our FIT to eliminate the custom binary load script. 
How should I cleanly add an alternate CONFIG_BOOTCOMMAND to an existing board.h file?
Where is the best place to define an alternate do_go_exec that calls
cleanup_before_linux() before jumping?

Thanks,
Henry

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 04/11] spl: imx: Add optional lds to keep SPL entirely in on-chip RAM
  2018-08-07 12:17   ` Stefano Babic
@ 2018-08-08  3:22     ` Henry Beberman
  0 siblings, 0 replies; 33+ messages in thread
From: Henry Beberman @ 2018-08-08  3:22 UTC (permalink / raw)
  To: u-boot

Hi Stefano,

> -----Original Message-----
> From: Stefano Babic <sbabic@denx.de>
> Sent: Tuesday, August 7, 2018 5:17 AM
> To: Henry Beberman <Henry.Beberman@microsoft.com>; u-
> boot at lists.denx.de
> Cc: Stefano Babic <sbabic@denx.de>; Fabio Estevam
> <fabio.estevam@nxp.com>
> Subject: Re: [PATCH 04/11] spl: imx: Add optional lds to keep SPL entirely in
> on-chip RAM
> 
> Hi Henry,
> 
> On 14/07/2018 02:11, Henry Beberman wrote:
> > From: Henry Beberman <henry.beberman@microsoft.com>
> >
> > This patch is part of the i.MX Windows 10 IoT Core boot flow.
> >
> > It adds a modified linker script for SPL to keep all segments in
> > on-chip ram. This is to harden the device against potential leaks of
> > device secrets by keeping them out of DRAM.
> >
> > Additionally if CONFIG_SYS_SPL_MALLOC_START is defined, it will
> > override the CONFIG_SPL_SYS_MALLOC_SIMPLE and allocate space in
> DRAM
> > instead of on-chip ram. This patch prevents the definition of those
> > values for i.MX6 and i.MX7 SPL if CONFIG_OPTEE_SPL_BOOT is selected.
> >
> 
> I guess there should be some kind of restrictions to be set according to the
> i.MX6 variant. I have already had some projects where I get rid of all space
> available on OCRAM. The smaller i.MX6 has just 64KB of RAM - have you
> tested also on them ? I wonder if there is enough space for all i.MX variants,
> specially if some other options are enabled.

As configured now our SPL binary is only about 32KB. We haven’t run it on
any i.MX6 platforms with 64KB of OCRAM, so I'm not sure if we're bypassing
64KB at runtime.

Which i.MX6 configurations have 64KB of OCRAM?

> 
> > Signed-off-by: Henry Beberman <henry.beberman@microsoft.com>
> > Cc: Stefano Babic <sbabic@denx.de>
> > Cc: Fabio Estevam <fabio.estevam@nxp.com>
> > ---
> >  arch/arm/mach-imx/u-boot-spl-sram.lds | 59
> +++++++++++++++++++++++++++++++++++
> >  include/configs/imx6_spl.h            |  2 ++
> >  include/configs/imx7_spl.h            |  2 ++
> >  3 files changed, 63 insertions(+)
> >  create mode 100644 arch/arm/mach-imx/u-boot-spl-sram.lds
> >
> > diff --git a/arch/arm/mach-imx/u-boot-spl-sram.lds
> > b/arch/arm/mach-imx/u-boot-spl-sram.lds
> > new file mode 100644
> > index 0000000000..dfbb4aef5d
> > --- /dev/null
> > +++ b/arch/arm/mach-imx/u-boot-spl-sram.lds
> > @@ -0,0 +1,59 @@
> > +/*
> > + * (C) Copyright 2002
> > + * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
> > + *
> > + * (C) Copyright 2010
> > + * Texas Instruments,
> <https://na01.safelinks.protection.outlook.com/?url=www.ti.com&amp;dat
> a=02%7C01%7CHenry.Beberman%40microsoft.com%7Cd96d8086ca0a4fd87d
> 5308d5fc5fb1db%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C6366
> 92410300862003&amp;sdata=RFzlv9uQ5%2BBDtudKWw4aacKgE4B%2Bn1ENE
> xvM9v2ANew%3D&amp;reserved=0>
> > + *	Aneesh V <aneesh@ti.com>
> > + *
> > + * (C) Copyright 2018 Microsoft Corporation
> > + *
> > + * SPDX-License-Identifier:	GPL-2.0+
> > + */
> > +
> > +MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE,\
> > +		LENGTH = CONFIG_SPL_MAX_SIZE }
> > +
> > +OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm",
> > +"elf32-littlearm")
> > +OUTPUT_ARCH(arm)
> > +ENTRY(_start)
> > +SECTIONS
> > +{
> > +	.text      :
> > +	{
> > +		__start = .;
> > +		*(.vectors)
> > +		arch/arm/cpu/armv7/start.o	(.text*)
> > +		*(.text*)
> > +	} >.sram
> > +
> > +	. = ALIGN(4);
> > +	.rodata : { *(SORT_BY_ALIGNMENT(.rodata*)) } >.sram
> > +
> > +	. = ALIGN(4);
> > +	.data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram
> > +
> > +	. = ALIGN(4);
> > +	.u_boot_list : {
> > +		KEEP(*(SORT(.u_boot_list*)));
> > +	} >.sram
> > +
> > +	. = ALIGN(4);
> > +	__image_copy_end = .;
> > +
> > +	.end :
> > +	{
> > +		*(.__end)
> > +	}
> > +
> > +	_image_binary_end = .;
> > +
> > +	.bss :
> > +	{
> > +		. = ALIGN(4);
> > +		__bss_start = .;
> > +		*(.bss*)
> > +		. = ALIGN(4);
> > +		__bss_end = .;
> > +	} >.sram
> > +}
> 
> This is more or less a copy of the armv8 version + bss in sram instead of
> sdram. In any case, mach-imx is not the right place because it is quite SOC
> independent. The whole i.MX do not use own lds but they are using the
> general scripts from ARM 32bit.

I agree that this isn’t i.MX specific. I took a look at the general ARM32 lds
and since it's not splitting the bss into a different region it looks like I just need
to set CONFIG_SPL_TEXT_BASE correctly. I'll check with my team to see why
we added this lds in the first place, but hopefully I can just get rid of it. 

Thanks,
Henry

> 
> > diff --git a/include/configs/imx6_spl.h b/include/configs/imx6_spl.h
> > index 720ff045a7..4088e8a936 100644
> > --- a/include/configs/imx6_spl.h
> > +++ b/include/configs/imx6_spl.h
> > @@ -51,6 +51,7 @@
> >  # endif
> >  #endif
> >
> > +#ifndef CONFIG_OPTEE_SPL_BOOT
> >  #if defined(CONFIG_MX6SX) || defined(CONFIG_MX6SL) || \
> >  	defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL)
> >  #define CONFIG_SPL_BSS_START_ADDR      0x88200000
> > @@ -63,6 +64,7 @@
> >  #define CONFIG_SYS_SPL_MALLOC_START	0x18300000
> >  #define CONFIG_SYS_SPL_MALLOC_SIZE	0x100000	/* 1 MB */
> >  #endif
> > +#endif /* !CONFIG_OPTEE_SPL_BOOT */
> >  #endif
> >
> >  #endif
> > diff --git a/include/configs/imx7_spl.h b/include/configs/imx7_spl.h
> > index 1eb6cd894d..5dd4aed652 100644
> > --- a/include/configs/imx7_spl.h
> > +++ b/include/configs/imx7_spl.h
> > @@ -46,10 +46,12 @@
> >  # endif
> >  #endif
> >
> > +#ifndef CONFIG_OPTEE_SPL_BOOT
> >  #define CONFIG_SPL_BSS_START_ADDR      0x88200000
> >  #define CONFIG_SPL_BSS_MAX_SIZE        0x100000		/* 1 MB */
> >  #define CONFIG_SYS_SPL_MALLOC_START    0x88300000
> >  #define CONFIG_SYS_SPL_MALLOC_SIZE     0x100000		/* 1
> MB */
> > +#endif /* !CONFIG_OPTEE_SPL_BOOT */
> >
> >  #endif /* CONFIG_SPL */
> 
> Best regards,
> Stefano Babic
> 
> --
> ==========================================================
> ===========
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
> ==========================================================
> ===========

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc
  2018-08-08  2:24         ` Henry Beberman
@ 2018-08-15 14:46           ` Alexander Graf
  0 siblings, 0 replies; 33+ messages in thread
From: Alexander Graf @ 2018-08-15 14:46 UTC (permalink / raw)
  To: u-boot

On 08/08/2018 04:24 AM, Henry Beberman wrote:
>
>> -----Original Message-----
>> From: Alexander Graf <agraf@suse.de>
>> Sent: Tuesday, August 7, 2018 6:46 AM
>> To: Tom Rini <trini@konsulko.com>
>> Cc: Stefano Babic <sbabic@denx.de>; Henry Beberman
>> <Henry.Beberman@microsoft.com>; u-boot at lists.denx.de; Fabio Estevam
>> <fabio.estevam@nxp.com>
>> Subject: Re: [PATCH 01/11] imx: Add bootcmd to load and run UEFI from
>> mmc
>>
>>
>>
>>> Am 07.08.2018 um 12:16 schrieb Tom Rini <trini@konsulko.com>:
>>>
>>>> On Tue, Aug 07, 2018 at 01:11:11PM +0200, Stefano Babic wrote:
>>>> Hi Henry,
>>>>
>>>>> On 14/07/2018 02:11, Henry Beberman wrote:
>>>>> From: Henry Beberman <henry.beberman@microsoft.com>
>>>>>
>>>>> This patch enables i.MX platforms to easily add a boot script to
>>>>> their U-Boot Proper environment to automatically load and execute an
>>>>> EFI firmware from the first FAT partition of an MMC device.
>>>>>
>>>>> This is a portion of enabling the Windows 10 IoT Core boot path.
>>>>>
>>>>> The go command is overridden when CONFIG_UEFI_BOOT is specified.
>>>>> This new go will perform a cache flush/disable, disable interrupts,
>>>>> then jump to the address where UEFI was loaded.
>>>>>
>>>>> This patch adds two new Kconfig options:
>>>>> CONFIG_UEFI_BOOT: Selects the UEFI bootcmd and overrides go to
>> flush
>>>>> caches and disable interrupts.
>>>>> CONFIG_UEFI_LOAD_ADDR: Specifies the load address for the UEFI
>> image
>>>>> Signed-off-by: Henry Beberman <henry.beberman@microsoft.com>
>>>>> Cc: Stefano Babic <sbabic@denx.de>
>>>>> Cc: Fabio Estevam <fabio.estevam@nxp.com>
>>>>> Cc: Tom Rini <trini@konsulko.com>
>>>>> ---
>>>>> arch/arm/mach-imx/Makefile    |  1 +
>>>>> arch/arm/mach-imx/boot.c      | 19 +++++++++++++++++++
>>>>> common/Kconfig                | 17 +++++++++++++++++
>>>>> include/config_uefi_bootcmd.h | 29
>> +++++++++++++++++++++++++++++
>>>>> 4 files changed, 66 insertions(+)
>>>>> create mode 100644 arch/arm/mach-imx/boot.c create mode 100644
>>>>> include/config_uefi_bootcmd.h
>>>>>
>>>> I am really missing why we need this specially for i.MX. There is
>>>> nothing special to i.MX, and if this command is necessary, we should
>>>> put it in common code.
>>>>
>>>> Anyway, should we not try to merge it with the general support for
>>>> UEFI in U-Boot ? We have already a "bootefi" command (aarch64 and
>>>> x86, currently).
>>> Agreed, this should be folded in with our existing UEFI support, thanks!
>> Yes, please just use distro boot. Bootefi (which distro boot calls) already
>> supports running UEFI binaries for real even on armv7.
>>
>>
>> Alex
>>
> Running Windows directly on U-Boot through bootefi is definitely appealing, but
> we're dependent on a number of features provided by our full UEFI firmware.
>
> * Several ACPI tables that are unimplemented in U-Boot: CSRT, DBG2, SPCR, TPM2, GTDT
> * Some DSDT elements that require the Microsoft ASL compiler (for now)
> * UEFI Authenticated Variables that are writeable at runtime.
> * UEFI Secure Boot
> * Launching and communicating with a Firmware TPM running as an OP-TEE Trusted Application
>
> I'd be happy to break down this patch's changes into more generic steps rather than
> creating confusion by adding CONFIG_UEFI_BOOT.
>
> I can move the UEFI binary into our FIT to eliminate the custom binary load script.
> How should I cleanly add an alternate CONFIG_BOOTCOMMAND to an existing board.h file?

I think ideally you just integrate into whatever distro boot supports. 
It already gives you plenty options such as extboot, boot.scr and real 
generic bootefi support. I'm sure your specially crafted FIT image can 
by loaded by at least one of the existing mechanisms.

> Where is the best place to define an alternate do_go_exec that calls
> cleanup_before_linux() before jumping?

Do you really really need that? The ARM calling convention for bootz is 
trivial and sounds like pretty much what you need already, no?


Alex

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2018-08-15 14:46 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-14  0:11 [U-Boot] [PATCH 00/11] Enable Windows 10 IoT Core on i.MX6 and i.MX7 Henry Beberman
2018-07-14  0:11 ` [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc Henry Beberman
2018-07-16 17:16   ` Trent Piepho
2018-07-16 22:28     ` Henry Beberman
2018-07-16 22:45       ` Trent Piepho
2018-07-16 23:56         ` Henry Beberman
2018-07-17 17:24           ` Trent Piepho
2018-07-18  0:52             ` Henry Beberman
2018-07-17 17:09     ` Fabio Estevam
2018-07-17 17:20       ` Henry Beberman
2018-08-07 11:11   ` Stefano Babic
2018-08-07 11:16     ` Tom Rini
2018-08-07 13:45       ` Alexander Graf
2018-08-08  2:24         ` Henry Beberman
2018-08-15 14:46           ` Alexander Graf
2018-07-14  0:11 ` [U-Boot] [PATCH 03/11] spl: Add FIT boot into OP-TEE then U-Boot proper Henry Beberman
2018-07-14  0:11 ` [U-Boot] [PATCH 02/11] arm: Allow U-Boot Proper to run in normal world Henry Beberman
2018-07-14  0:11 ` [U-Boot] [PATCH 04/11] spl: imx: Add optional lds to keep SPL entirely in on-chip RAM Henry Beberman
2018-07-16 17:32   ` Trent Piepho
2018-07-16 22:48     ` Henry Beberman
2018-08-07 12:17   ` Stefano Babic
2018-08-08  3:22     ` Henry Beberman
2018-07-14  0:11 ` [U-Boot] [PATCH 05/11] mx6sabresd: Add Windows boot support for iMX6 Sabre Henry Beberman
2018-07-14  0:11 ` [U-Boot] [PATCH 07/11] mx6cuboxi: Add Windows boot support for mx6cuboxi Henry Beberman
2018-07-14  0:11 ` [U-Boot] [PATCH 06/11] mx7dsabresd: Add Windows boot support for iMX7 Sabre Henry Beberman
2018-07-16 18:22   ` Trent Piepho
2018-07-17  1:41     ` Henry Beberman
2018-07-17 17:02       ` Trent Piepho
2018-07-17 21:31         ` Henry Beberman
2018-07-14  0:11 ` [U-Boot] [PATCH 08/11] udoo_neo: Add Windows boot support for UDOO Neo Henry Beberman
2018-07-14  0:11 ` [U-Boot] [PATCH 09/11] cl-som-imx7: Add Windows boot support for cl-som-imx7 Henry Beberman
2018-07-14  0:11 ` [U-Boot] [PATCH 11/11] imx: Add MAC addresses to global page to pass MAC into UEFI Henry Beberman
2018-07-14  0:11 ` [U-Boot] [PATCH 10/11] imx: Reserve a global page in memory to pass configuration to UEFI Henry Beberman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.