Add WaRP7 ATF chainloaded setup
Subsystems (3)
cover 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:
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
Signature · 1 line
2.18.0
PATCH 1/4 imx: mx7: avoid some initialization if low level is skipped
From: Rui Miguel Silva <[email protected]>
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.
--- arch/arm/mach-imx/mx7/soc.c | 2 ++ arch/arm/mach-imx/syscounter.c | 2 ++ 2 files changed, 4 insertions(+)
arch/arm/mach-imx/mx7/soc.c +2 -0
@@ -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 )
arch/arm/mach-imx/syscounter.c +2 -0
@@ -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 ) {
Signature · 1 line
2.18.0
PATCH 1/4 imx: mx7: avoid some initialization if low level is skipped
Quoted 61 lines
-----Original Message-----
From: Bryan O'Donoghue [mailto:bryan.odonoghue at linaro.org]
Sent: 2018年9月5日 18:56
To: u-boot at lists.denx.de; Fabio Estevam <[email protected]>
Cc: ryan.harkin at linaro.org; Rui Miguel Silva <[email protected]>; Bryan O'Donoghue <[email protected]>; Stefano Babic <[email protected]>; Albert Aribaud <[email protected]>; Peng Fan <[email protected]>
Subject: [PATCH 1/4] imx: mx7: avoid some initialization if low level is skippedFrom: Rui Miguel Silva <[email protected]>
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 <[email protected]>Signed-off-by Bryan O'Donoghue <[email protected]>Cc Stefano Babic <[email protected]>Cc Fabio Estevam <[email protected]>Cc Albert Aribaud <[email protected]>Cc Peng Fan <[email protected]>Cc u-boot at lists.denx.de--- arch/arm/mach-imx/mx7/soc.c | 2 ++ arch/arm/mach-imx/syscounter.c | 2 ++ 2 files changed, 4 insertions(+)arch/arm/mach-imx/mx7/soc.c +2
-0@@ -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 )arch/arm/mach-imx/syscounter.c +1
-0@@ -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 ) {
arch/arm/mach-imx/syscounter.c int timer_init(void) · line 83
Quoted 9 lines
arch/arm/mach-imx/syscounter.c +2
-0struct 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 ) {
Quoted 2 lines
--
2.18.0
PATCH 2/4 optee: adjust dependencies and default values for dram
In reply to Bryan O'DonoghueFrom: Rui Miguel Silva <[email protected]>
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.
--- configs/warp7_defconfig | 2 ++ lib/optee/Kconfig | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-)
configs/warp7_defconfig +2 -0
@@ -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
lib/optee/Kconfig +4 -4
@@ -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
Signature · 1 line
2.18.0
PATCH 3/4 warp7: include: configs: set skip low level init
In reply to Bryan O'DonoghueFrom: Rui Miguel Silva <[email protected]>
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.
--- include/configs/warp7.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
include/configs/warp7.h +11 -0
@@ -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 */
Signature · 1 line
2.18.0
PATCH 4/4 warp7: configs: add bl33 defconfig
In reply to Bryan O'DonoghueFrom: Rui Miguel Silva <[email protected]>
Add default configuration to run u-boot as BL33 in the ARM Trusted Firmware boot flow for AArch32 case.
--- configs/warp7_bl33_defconfig | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 configs/warp7_bl33_defconfig
configs/warp7_bl33_defconfig new file +42 -0
@@ -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
Signature · 1 line
2.18.0