[U-Boot] [PATCH 0/4] Add WaRP7 ATF chainloaded setup

This set of patches makes a version of u-boot that is bootable as BL33 in a chainloded set of images in the following sequence.
BootROM -> ATF (loads a FIP) -> OPTEE -> u-boot -> Linux.
Since the OPTEE image enables TrustZone u-boot no longer has access to certain low-level functions. In order to differentiate between the full-fat WaRP7 u-boot which is usually run by the BootROM directly a second defconfig is introduced along with some minimal skipping of low-level bit twiddling.
For those motivated to try a description of how to set up the WaRP7 in ATF mode is here:
https://github.com/bryanodonoghue/arm-trusted-firmware/blob/atf-master%2Blin...
Rui Miguel Silva (4): imx: mx7: avoid some initialization if low level is skipped optee: adjust dependencies and default values for dram warp7: include: configs: set skip low level init warp7: configs: add bl33 defconfig
arch/arm/mach-imx/mx7/soc.c | 2 ++ arch/arm/mach-imx/syscounter.c | 2 ++ configs/warp7_bl33_defconfig | 42 ++++++++++++++++++++++++++++++++++ configs/warp7_defconfig | 2 ++ include/configs/warp7.h | 11 +++++++++ lib/optee/Kconfig | 8 +++---- 6 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 configs/warp7_bl33_defconfig

From: Rui Miguel Silva rui.silva@linaro.org
We can have the case where u-boot is launched after some other low level enabler, like for example when u-boot runs after arm-trusted-firmware and/or optee. So, because of that we may need to jump the initialization of some IP blocks even because we may no longer have the permission for that.
So, if the config option to skip low level init is set disable also timer, board and csu initialization.
Signed-off-by: Rui Miguel Silva rui.silva@linaro.org Signed-off-by: Bryan O'Donoghue bryan.odonoghue@linaro.org Cc: Stefano Babic sbabic@denx.de Cc: Fabio Estevam fabio.estevam@nxp.com Cc: Albert Aribaud albert.u.boot@aribaud.net Cc: Peng Fan peng.fan@nxp.com Cc: u-boot@lists.denx.de --- arch/arm/mach-imx/mx7/soc.c | 2 ++ arch/arm/mach-imx/syscounter.c | 2 ++ 2 files changed, 4 insertions(+)
diff --git a/arch/arm/mach-imx/mx7/soc.c b/arch/arm/mach-imx/mx7/soc.c index 7334ca9eb8..c38bd1ce46 100644 --- a/arch/arm/mach-imx/mx7/soc.c +++ b/arch/arm/mach-imx/mx7/soc.c @@ -133,6 +133,7 @@ u32 __weak get_board_rev(void) } #endif
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT /* enable all periherial can be accessed in nosec mode */ static void init_csu(void) { @@ -182,6 +183,7 @@ int arch_cpu_init(void)
return 0; } +#endif
#ifdef CONFIG_ARCH_MISC_INIT int arch_misc_init(void) diff --git a/arch/arm/mach-imx/syscounter.c b/arch/arm/mach-imx/syscounter.c index 676bb3caa9..2c319681fc 100644 --- a/arch/arm/mach-imx/syscounter.c +++ b/arch/arm/mach-imx/syscounter.c @@ -55,6 +55,7 @@ static inline unsigned long long us_to_tick(unsigned long long usec) return usec; }
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT int timer_init(void) { struct sctr_regs *sctr = (struct sctr_regs *)SCTR_BASE_ADDR; @@ -76,6 +77,7 @@ int timer_init(void)
return 0; } +#endif
unsigned long long get_ticks(void) {

-----Original Message----- From: Bryan O'Donoghue [mailto:bryan.odonoghue@linaro.org] Sent: 2018年9月5日 18:56 To: u-boot@lists.denx.de; Fabio Estevam fabio.estevam@nxp.com Cc: ryan.harkin@linaro.org; Rui Miguel Silva rui.silva@linaro.org; Bryan O'Donoghue bryan.odonoghue@linaro.org; Stefano Babic sbabic@denx.de; Albert Aribaud albert.u.boot@aribaud.net; Peng Fan peng.fan@nxp.com Subject: [PATCH 1/4] imx: mx7: avoid some initialization if low level is skipped
From: Rui Miguel Silva rui.silva@linaro.org
We can have the case where u-boot is launched after some other low level enabler, like for example when u-boot runs after arm-trusted-firmware and/or optee. So, because of that we may need to jump the initialization of some IP blocks even because we may no longer have the permission for that.
So, if the config option to skip low level init is set disable also timer, board and csu initialization.
Signed-off-by: Rui Miguel Silva rui.silva@linaro.org Signed-off-by: Bryan O'Donoghue bryan.odonoghue@linaro.org Cc: Stefano Babic sbabic@denx.de Cc: Fabio Estevam fabio.estevam@nxp.com Cc: Albert Aribaud albert.u.boot@aribaud.net Cc: Peng Fan peng.fan@nxp.com Cc: u-boot@lists.denx.de
arch/arm/mach-imx/mx7/soc.c | 2 ++ arch/arm/mach-imx/syscounter.c | 2 ++ 2 files changed, 4 insertions(+)
diff --git a/arch/arm/mach-imx/mx7/soc.c b/arch/arm/mach-imx/mx7/soc.c index 7334ca9eb8..c38bd1ce46 100644 --- a/arch/arm/mach-imx/mx7/soc.c +++ b/arch/arm/mach-imx/mx7/soc.c @@ -133,6 +133,7 @@ u32 __weak get_board_rev(void) } #endif
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT /* enable all periherial can be accessed in nosec mode */ static void init_csu(void) { @@ -182,6 +183,7 @@ int arch_cpu_init(void)
return 0; } +#endif
#ifdef CONFIG_ARCH_MISC_INIT int arch_misc_init(void) diff --git a/arch/arm/mach-imx/syscounter.c b/arch/arm/mach-imx/syscounter.c index 676bb3caa9..2c319681fc 100644 --- a/arch/arm/mach-imx/syscounter.c +++ b/arch/arm/mach-imx/syscounter.c @@ -55,6 +55,7 @@ static inline unsigned long long us_to_tick(unsigned long long usec) return usec; }
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT int timer_init(void) { struct sctr_regs *sctr = (struct sctr_regs *)SCTR_BASE_ADDR; @@ -76,6 +77,7 @@ int timer_init(void)
return 0; } +#endif
unsigned long long get_ticks(void) {
Reviewed-by: Peng Fan peng.fan@nxp.com
-- 2.18.0

From: Rui Miguel Silva rui.silva@linaro.org
We may have, the not yet considered, scenario where OPTEE is loaded before u-boot and *not* by u-boot, e.g, the boot flow using the ARM Trusted Firmware (ATF), where in the 32bit flow is: BootRom->ATF(BL2)->Optee(BL32)->u-boot(BL33)
In this case we need still to reserve the memory used by optee, to avoid for example to realocate ourself to the same address at the end of DRAM. So, we change here the dependencies on the OPTEE lib and we set the default size and base of TZRAM to zero.
Signed-off-by: Rui Miguel Silva rui.silva@linaro.org Signed-off-by: Bryan O'Donoghue bryan.odonoghue@linaro.org Cc: Fabio Estevam fabio.estevam@nxp.com Cc: Ryan Harkin ryan.harkin@linaro.org Cc: u-boot@lists.denx.de --- configs/warp7_defconfig | 2 ++ lib/optee/Kconfig | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/configs/warp7_defconfig b/configs/warp7_defconfig index 15a66739f8..a1c0b69ea8 100644 --- a/configs/warp7_defconfig +++ b/configs/warp7_defconfig @@ -46,5 +46,7 @@ CONFIG_USB_ETH_CDC=y CONFIG_USBNET_HOST_ADDR="de:ad:be:af:00:00" CONFIG_OF_LIBFDT=y CONFIG_OPTEE=y +CONFIG_OPTEE_TZDRAM_SIZE=0x3000000 +CONFIG_OPTEE_TZDRAM_BASE=0x9d000000 CONFIG_OPTEE_LOAD_ADDR=0x84000000 CONFIG_BOOTM_OPTEE=y diff --git a/lib/optee/Kconfig b/lib/optee/Kconfig index 1e5ab45c3d..3773d89c31 100644 --- a/lib/optee/Kconfig +++ b/lib/optee/Kconfig @@ -10,21 +10,20 @@ config OPTEE config OPTEE_LOAD_ADDR hex "OPTEE load address" default 0x00000000 + depends on OPTEE help The load address of the bootable OPTEE binary.
config OPTEE_TZDRAM_SIZE hex "Amount of Trust-Zone RAM for the OPTEE image" - depends on OPTEE - default 0x3000000 + default 0x0000000 help The size of pre-allocated Trust Zone DRAM to allocate for the OPTEE runtime.
config OPTEE_TZDRAM_BASE hex "Base address of Trust-Zone RAM for the OPTEE image" - depends on OPTEE - default 0x9d000000 + default 0x00000000 help The base address of pre-allocated Trust Zone DRAM for the OPTEE runtime. @@ -32,6 +31,7 @@ config OPTEE_TZDRAM_BASE config BOOTM_OPTEE bool "Support OPTEE bootm command" select BOOTM_LINUX + depends on OPTEE default n help Select this command to enable chain-loading of a Linux kernel

From: Rui Miguel Silva rui.silva@linaro.org
If we have defined the OPTEE ram size and not OPTEE means that we are in the case where OPTEE is loaded already (maybe by ARM Trusted Firmware) and that most of the low level initialization is already done and that we may/should skip it doing them here.
Signed-off-by: Rui Miguel Silva rui.silva@linaro.org Signed-off-by: Bryan O'Donoghue bryan.odonoghue@linaro.org Cc: Fabio Estevam fabio.estevam@nxp.com Cc: u-boot@lists.denx.de --- include/configs/warp7.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/include/configs/warp7.h b/include/configs/warp7.h index 1b656a5aaf..a391dfb5c1 100644 --- a/include/configs/warp7.h +++ b/include/configs/warp7.h @@ -13,6 +13,17 @@
#define PHYS_SDRAM_SIZE SZ_512M
+/* + * If we have defined the OPTEE ram size and not OPTEE it means that we were + * launched by OPTEE, because of that we shall skip all the low level + * initialization since it was already done by ATF or OPTEE + */ +#ifdef CONFIG_OPTEE_TZDRAM_SIZE +#ifndef CONFIG_OPTEE +#define CONFIG_SKIP_LOWLEVEL_INIT +#endif +#endif + #define CONFIG_MXC_UART_BASE UART1_IPS_BASE_ADDR
/* Size of malloc() pool */

From: Rui Miguel Silva rui.silva@linaro.org
Add default configuration to run u-boot as BL33 in the ARM Trusted Firmware boot flow for AArch32 case.
Signed-off-by: Rui Miguel Silva rui.silva@linaro.org Signed-off-by: Bryan O'Donoghue bryan.odonoghue@linaro.org Cc: Fabio Estevam fabio.estevam@nxp.com Cc: Simon Glass sjg@chromium.org Cc: Maxime Ripard maxime.ripard@free-electrons.com Cc: Lukasz Majewski lukma@denx.de Cc: Tuomas Tynkkynen tuomas.tynkkynen@iki.fi Cc: u-boot@lists.denx.de --- configs/warp7_bl33_defconfig | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 configs/warp7_bl33_defconfig
diff --git a/configs/warp7_bl33_defconfig b/configs/warp7_bl33_defconfig new file mode 100644 index 0000000000..bed970b014 --- /dev/null +++ b/configs/warp7_bl33_defconfig @@ -0,0 +1,42 @@ +CONFIG_ARM=y +CONFIG_ARCH_MX7=y +CONFIG_SECURE_BOOT=y +CONFIG_SYS_TEXT_BASE=0x87800000 +CONFIG_TARGET_WARP7=y +CONFIG_ARMV7_BOOT_SEC_DEFAULT=y +CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/warp7/imximage.cfg" +CONFIG_HUSH_PARSER=y +CONFIG_CMD_BOOTZ=y +CONFIG_CMD_MEMTEST=y +CONFIG_CMD_DFU=y +CONFIG_CMD_GPIO=y +CONFIG_CMD_MMC=y +CONFIG_CMD_PART=y +CONFIG_CMD_USB=y +CONFIG_CMD_USB_MASS_STORAGE=y +CONFIG_CMD_SETEXPR=y +CONFIG_CMD_DHCP=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_NET_RANDOM_ETHADDR=y +CONFIG_DFU_MMC=y +CONFIG_FSL_ESDHC=y +CONFIG_USB=y +CONFIG_USB_EHCI_HCD=y +CONFIG_MXC_USB_OTG_HACTIVE=y +CONFIG_USB_STORAGE=y +CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_MANUFACTURER="FSL" +CONFIG_USB_GADGET_VENDOR_NUM=0x0525 +CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5 +CONFIG_CI_UDC=y +CONFIG_USB_GADGET_DOWNLOAD=y +CONFIG_USB_ETHER=y +CONFIG_USB_ETH_CDC=y +CONFIG_USBNET_HOST_ADDR="de:ad:be:af:00:00" +CONFIG_OF_LIBFDT=y +CONFIG_OPTEE_TZDRAM_SIZE=0x2000000
participants (2)
-
Bryan O'Donoghue
-
Peng Fan