Re: [U-Boot] [PATCH 04/11] spl: imx: Add optional lds to keep SPL entirely in on-chip RAM

2018-08-07 Thread Henry Beberman
Hi Stefano,

> -Original Message-
> From: Stefano Babic 
> Sent: Tuesday, August 7, 2018 5:17 AM
> To: Henry Beberman ; u-
> b...@lists.denx.de
> Cc: Stefano Babic ; Fabio Estevam
> 
> 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 
> >
> > 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 
> > Cc: Stefano Babic 
> > Cc: Fabio Estevam 
> > ---
> >  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 00..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, 
> > + *
> > + * (C) Copyright 2010
> > + * Texas Instruments,
> <https://na01.safelinks.protection.outlook.com/?url=www.ti.comdat
> a=02%7C01%7CHenry.Beberman%40microsoft.com%7Cd96d8086ca0a4fd87d
> 5308d5fc5fb1db%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C6366
> 92410300862003sdata=RFzlv9uQ5%2BBDtudKWw4aacKgE4B%2Bn1ENE
> xvM9v2ANew%3Dreserved=0>
> > + * Aneesh V 
> > + *
> > + * (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 t

Re: [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc

2018-08-07 Thread Henry Beberman


> -Original Message-
> From: Alexander Graf 
> Sent: Tuesday, August 7, 2018 6:46 AM
> To: Tom Rini 
> Cc: Stefano Babic ; Henry Beberman
> ; u-boot@lists.denx.de; Fabio Estevam
> 
> 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 :
> >
> >> 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 
> >>>
> >>> 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 
> >>> Cc: Stefano Babic 
> >>> Cc: Fabio Estevam 
> >>> Cc: Tom Rini 
> >>> ---
> >>> 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
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc

2018-07-17 Thread Henry Beberman
> -Original Message-
> From: Trent Piepho 
> Sent: Tuesday, July 17, 2018 10:24 AM
> To: Henry Beberman ; u-
> b...@lists.denx.de
> Cc: tr...@konsulko.com; fabio.este...@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 +, 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.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 06/11] mx7dsabresd: Add Windows boot support for iMX7 Sabre

2018-07-17 Thread Henry Beberman
> -Original Message-
> From: Trent Piepho 
> Sent: Tuesday, July 17, 2018 10:03 AM
> To: Henry Beberman ; u-
> b...@lists.denx.de
> Cc: fabio.este...@nxp.com; adrian.alo...@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 +, Henry Beberman wrote:
> > > -Original Message-
> > > From: Trent Piepho 
> > > Sent: Monday, July 16, 2018 11:22 AM
> > > To: Henry Beberman ; u-
> > > b...@lists.denx.de
> > > Cc: fabio.este...@nxp.com; adrian.alo...@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 +, Henry Beberman wrote:
> > > > From: Henry Beberman 
> > > >
> > > > 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
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc

2018-07-17 Thread Henry Beberman
Hi Fabio,

> -Original Message-
> From: Fabio Estevam 
> Sent: Tuesday, July 17, 2018 10:09 AM
> To: Trent Piepho 
> Cc: Henry Beberman ; u-
> b...@lists.denx.de; fabio.este...@nxp.com; tr...@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  wrote:
> > On Sat, 2018-07-14 at 00:11 +0000, Henry Beberman wrote:
> >> From: Henry Beberman 
> >>
> >> 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

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 06/11] mx7dsabresd: Add Windows boot support for iMX7 Sabre

2018-07-16 Thread Henry Beberman
> -Original Message-
> From: Trent Piepho 
> Sent: Monday, July 16, 2018 11:22 AM
> To: Henry Beberman ; u-
> b...@lists.denx.de
> Cc: fabio.este...@nxp.com; adrian.alo...@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 +, Henry Beberman wrote:
> > From: Henry Beberman 
> >
> > 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
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc

2018-07-16 Thread Henry Beberman
> -Original Message-
> From: Trent Piepho 
> Sent: Monday, July 16, 2018 3:45 PM
> To: Henry Beberman ; u-
> b...@lists.denx.de
> Cc: tr...@konsulko.com; fabio.este...@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 +, Henry Beberman wrote:
> > Hi Trent,
> >
> > > -Original Message-
> > > From: Trent Piepho 
> > > Sent: Monday, July 16, 2018 10:17 AM
> > > To: Henry Beberman ; u-
> > > b...@lists.denx.de
> > > Cc: tr...@konsulko.com; fabio.este...@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 +, Henry Beberman wrote:
> > > > From: Henry Beberman 
> > > >
> > > > 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.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 04/11] spl: imx: Add optional lds to keep SPL entirely in on-chip RAM

2018-07-16 Thread Henry Beberman
Hi Trent,

> -Original Message-
> From: Trent Piepho 
> Sent: Monday, July 16, 2018 10:33 AM
> To: Henry Beberman ; u-
> b...@lists.denx.de
> Cc: fabio.este...@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 +, Henry Beberman wrote:
> > From: Henry Beberman 
> >
> > 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
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc

2018-07-16 Thread Henry Beberman
Hi Trent,

> -Original Message-
> From: Trent Piepho 
> Sent: Monday, July 16, 2018 10:17 AM
> To: Henry Beberman ; u-
> b...@lists.denx.de
> Cc: tr...@konsulko.com; fabio.este...@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 +, Henry Beberman wrote:
> > From: Henry Beberman 
> >
> > 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
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 08/11] udoo_neo: Add Windows boot support for UDOO Neo

2018-07-13 Thread Henry Beberman
From: Henry Beberman 

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 
Cc: Stefano Babic 
Cc: Fabio Estevam 
Cc: Breno Lima 
Cc: Francesco Montefoschi 
---
 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 00..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 00..d5123369ca
--- /dev/null
+++ b/configs/udoo_neo_nt_defconfig
@@ -0,0 +1,55 @@
+CONFIG_ARCH_MX6=y
+CONFIG_ARM=y
+CONFIG_SYS_TEXT_BASE=0x8780
+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 
+
+#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 
+#endif /* CONFIG_UEFI_BOOT */
 
 /* Miscellaneous configurable options */
 #define CONFIG_SYS_MEMTEST_START   0x8000
-- 
2.16.2.gvfs.1.33.gf5370f1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 07/11] mx6cuboxi: Add Windows boot support for mx6cuboxi

2018-07-13 Thread Henry Beberman
From: Henry Beberman 

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 
Cc: Stefano Babic 
Cc: Fabio Estevam 
Cc: Jon Nettleton 
---
 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 00..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 00..087569d2e9
--- /dev/null
+++ b/configs/mx6cuboxi_nt_defconfig
@@ -0,0 +1,62 @@
+CONFIG_ARCH_MX6=y
+CONFIG_ARM=y
+CONFIG_SYS_TEXT_BASE=0x1780
+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=0x1082
+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 
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+   "mmcdev=0\0" \
+   BOOTENV
+#else
 #define CONFIG_EXTRA_ENV_SETTINGS \
"fdtfile=undefined\0" \
"fdt_addr_r=0x1800\0" \
@@ -125,6 +132,7 @@
fun

[U-Boot] [PATCH 09/11] cl-som-imx7: Add Windows boot support for cl-som-imx7

2018-07-13 Thread Henry Beberman
From: Henry Beberman 

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 
Cc: Stefano Babic 
Cc: Fabio Estevam 
Cc: Uri Mashiach 
Cc: Igor Grinberg 
---
 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 00..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, _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,
+   _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/comp

[U-Boot] [PATCH 03/11] spl: Add FIT boot into OP-TEE then U-Boot proper

2018-07-13 Thread Henry Beberman
From: Henry Beberman 

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 
Cc: Stefano Babic 
Cc: Fabio Estevam 
Cc: Tom Rini 
---
 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 00..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 
+#include 
+#include 
+#include 
+
+#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(_image);
break;
 #endif
+#ifdef CONFIG_SPL_OPTEE_BOOT
+   case IH_OS_TEE:
+   debug("Jumping to OPTEE\n");
+   jump_to_image_optee(_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

[U-Boot] [PATCH 11/11] imx: Add MAC addresses to global page to pass MAC into UEFI

2018-07-13 Thread Henry Beberman
From: Henry Beberman 

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 
Cc: Stefano Babic 
Cc: Fabio Estevam 
---
 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 {

[U-Boot] [PATCH 10/11] imx: Reserve a global page in memory to pass configuration to UEFI

2018-07-13 Thread Henry Beberman
From: Henry Beberman 

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 
Cc: Stefano Babic 
Cc: Fabio Estevam 
---
 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 
 #include 
+#include 
 
 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 00..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 
+#include 
+
+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 00..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 
+
+struct global_page_header {
+   u32 signature;
+   u8 revision;
+   u8 reserved[3];
+} __packed;
+
+struct imx_global_page 

[U-Boot] [PATCH 02/11] arm: Allow U-Boot Proper to run in normal world

2018-07-13 Thread Henry Beberman
From: Henry Beberman 

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 
Cc: Stefano Babic 
Cc: Fabio Estevam 
Cc: Tom Rini 
---
 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 time

[U-Boot] [PATCH 05/11] mx6sabresd: Add Windows boot support for iMX6 Sabre

2018-07-13 Thread Henry Beberman
From: Henry Beberman 

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 
Cc: Stefano Babic 
Cc: Fabio Estevam 
---
 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 00..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 00..9d858a4418
--- /dev/null
+++ b/configs/mx6sabresd_nt_defconfig
@@ -0,0 +1,58 @@
+CONFIG_ARCH_MX6=y
+CONFIG_ARM=y
+CONFIG_SYS_TEXT_BASE=0x1780
+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=0x1082
+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 
+
+#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; f

[U-Boot] [PATCH 06/11] mx7dsabresd: Add Windows boot support for iMX7 Sabre

2018-07-13 Thread Henry Beberman
From: Henry Beberman 

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 
Cc: Stefano Babic 
Cc: Fabio Estevam 
Cc: Adrian Alonso 
---
 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 
+
+#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, _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 00..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=0x8780
+CONFIG_TARGET_MX7DSABRESD=y
+CONFIG_DEFAULT_DE

[U-Boot] [PATCH 04/11] spl: imx: Add optional lds to keep SPL entirely in on-chip RAM

2018-07-13 Thread Henry Beberman
From: Henry Beberman 

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 
Cc: Stefano Babic 
Cc: Fabio Estevam 
---
 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 00..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, 
+ *
+ * (C) Copyright 2010
+ * Texas Instruments, 
+ * Aneesh V 
+ *
+ * (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  0x8820
@@ -63,6 +64,7 @@
 #define CONFIG_SYS_SPL_MALLOC_START0x1830
 #define CONFIG_SYS_SPL_MALLOC_SIZE 0x10/* 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  0x8820
 #define CONFIG_SPL_BSS_MAX_SIZE0x10/* 1 MB */
 #define CONFIG_SYS_SPL_MALLOC_START0x8830
 #define CONFIG_SYS_SPL_MALLOC_SIZE 0x10/* 1 MB */
+#endif /* !CONFIG_OPTEE_SPL_BOOT */
 
 #endif /* CONFIG_SPL */
 
-- 
2.16.2.gvfs.1.33.gf5370f1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc

2018-07-13 Thread Henry Beberman
From: Henry Beberman 

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 
Cc: Stefano Babic 
Cc: Fabio Estevam 
Cc: Tom Rini 
---
 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 00..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 
+#include 
+
+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 00..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

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 00/11] Enable Windows 10 IoT Core on i.MX6 and i.MX7

2018-07-13 Thread Henry Beberman
From: Henry Beberman 

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 
Cc:  Fabio Estevam 
Cc:  Tom Rini 
Cc:  Robert Solomon 
Cc:  Chirag Shah 
Cc:  Robert Oshana 
Cc:  Patrick Stilwell 

 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