From 206426aa0b636446bfe874f8a5cd3fc0a8a95119 Mon Sep 17 00:00:00 2001 From: Pierre-Jean TEXIER Date: Sun, 1 Apr 2018 00:49:04 +0200 Subject: [PATCH 01/34] warp7: include/configs: use generic fs commands in CONFIG_EXTRA_ENV_SETTINGS use the generic filesystem command 'load' rather than 'fatload' to avoid per-fs specific commands. Signed-off-by: Pierre-Jean TEXIER Reviewed-by: Fabio Estevam Acked-by: Bryan O'Donoghue --- include/configs/warp7.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/configs/warp7.h b/include/configs/warp7.h index 0c3b605..98fedb8 100644 --- a/include/configs/warp7.h +++ b/include/configs/warp7.h @@ -48,11 +48,11 @@ "mmcargs=setenv bootargs console=${console},${baudrate} " \ "root=PARTUUID=${uuid} rootwait rw\0" \ "loadbootscript=" \ - "fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \ + "load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \ "bootscript=echo Running bootscript from mmc ...; " \ "source\0" \ - "loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0" \ - "loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}\0" \ + "loadimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0" \ + "loadfdt=load mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}\0" \ "mmcboot=echo Booting from mmc ...; " \ "run finduuid; " \ "run mmcargs; " \ From 0803bcf8a974fb242175c26dd61b4158d02d24cb Mon Sep 17 00:00:00 2001 From: Pierre-Jean TEXIER Date: Sun, 1 Apr 2018 00:49:05 +0200 Subject: [PATCH 02/34] warp7: configs: enable CONFIG_CMD_FS_GENERIC This enable generic file system commands (load, ls). Signed-off-by: Pierre-Jean TEXIER Reviewed-by: Fabio Estevam Acked-by: Bryan O'Donoghue --- configs/warp7_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/warp7_defconfig b/configs/warp7_defconfig index 3901a27..b048148 100644 --- a/configs/warp7_defconfig +++ b/configs/warp7_defconfig @@ -26,6 +26,7 @@ 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 From af1b492dfafc033e06da49ba05fce98504221d6c Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Tue, 24 Apr 2018 18:46:30 +0100 Subject: [PATCH 03/34] tools/imximage: Fix fruity lack of 0x prefix in DCD Blocks commit 8519c9c98ad6 ("tools/imximage: use 0x prefix in HAB Blocks line") adds an 0x prefix to each HAB Block number to make it easier for host tools to process the HAB Block output, however it neglects to apply the same prefix to the DCD Blocks directive. You need the DCD Blocks directive if you are making a u-boot recovery image which the BootROM will accept via the USB upload utility. This disparity results in a fruity output like this with HAB Blocks prefixed but DCD Blocks not prefixed - which is pretty inconsistent. This patch fixes the difference assuming the original commit was a legitimate change. Old: Image Type: Freescale IMX Boot Image Image Ver: 2 (i.MX53/6/7 compatible) Mode: DCD Data Size: 430080 Bytes = 420.00 KiB = 0.41 MiB Load Address: 877ff420 Entry Point: 87800000 HAB Blocks: 0x877ff400 0x00000000 0x00066c00 DCD Blocks: 00910000 0000002c 000001d4 New: Image Type: Freescale IMX Boot Image Image Ver: 2 (i.MX53/6/7 compatible) Mode: DCD Data Size: 430080 Bytes = 420.00 KiB = 0.41 MiB Load Address: 877ff420 Entry Point: 87800000 HAB Blocks: 0x877ff400 0x00000000 0x00066c00 DCD Blocks: 0x00910000 0x0000002c 0x000001d4 Signed-off-by: Bryan O'Donoghue Cc: Rasmus Villemoes Cc: Fabio Estevam Cc: Breno Lima Cc: Stefano Babic Reviewed-by: Fabio Estevam --- tools/imximage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/imximage.c b/tools/imximage.c index 6dabb13..6f16d45 100644 --- a/tools/imximage.c +++ b/tools/imximage.c @@ -520,7 +520,7 @@ static void print_hdr_v2(struct imx_header *imx_hdr) (uint32_t)fhdr_v2->self, 0, hdr_v2->boot_data.size - imximage_ivt_offset - imximage_csf_size); - printf("DCD Blocks: 00910000 %08x %08x\n", + printf("DCD Blocks: 0x00910000 0x%08x 0x%08x\n", offs, be16_to_cpu(dcdlen)); } } else { From 69f0695067a1938946a3b3e492e0c9cb6e79132d Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Tue, 24 Apr 2018 18:46:31 +0100 Subject: [PATCH 04/34] imximage: Specify default IVT offset in IMX image This patch adds BOOTROM_IVT_HDR_OFFSET at 0xC00. The BootROM expects to find the IVT header at a particular offset in an i.MX image. Defining the expected offset of the IVT header in the first-stage BootROM image format is of use of later stage authentication routines where those routines continue to follow the first-stage authentication layout. This patch defines the first stage offset which later patch make use of. Signed-off-by: Bryan O'Donoghue Cc: Utkarsh Gupta Cc: Breno Lima Cc: Fabio Estevam Tested-by: Breno Lima Reviewed-by: Fabio Estevam --- include/imximage.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/imximage.h b/include/imximage.h index 553b852..800fd63 100644 --- a/include/imximage.h +++ b/include/imximage.h @@ -14,6 +14,9 @@ #define APP_CODE_BARKER 0xB1 #define DCD_BARKER 0xB17219E9 +/* Specify the offset of the IVT in the IMX header as expected by BootROM */ +#define BOOTROM_IVT_HDR_OFFSET 0xC00 + /* * NOTE: This file must be kept in sync with arch/arm/include/asm/\ * mach-imx/imximage.cfg because tools/imximage.c can not From 9c260e862f8f93390f22b0cfc1a3a6b94888d549 Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Tue, 24 Apr 2018 18:46:32 +0100 Subject: [PATCH 05/34] warp7: hab: Add a CSF location definition In order to correctly produce an image with a IVT/DCD header we need to define a CSF in imximage.cfg. We just use the mx7 default here. All we have to do with this option switched on is "make u-boot.imx" and we then will get - u-boot.imx - u-boot.imx.log The log file is really important because it gives the addresses for the HAB that we will require to sign the u-boot image using the CST. Since the addresses can change this logfile is a critical output. Signed-off-by: Bryan O'Donoghue Tested-by: Breno Lima Reviewed-by: Fabio Estevam --- board/warp7/imximage.cfg | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/board/warp7/imximage.cfg b/board/warp7/imximage.cfg index 5b42793..51a5bff 100644 --- a/board/warp7/imximage.cfg +++ b/board/warp7/imximage.cfg @@ -13,6 +13,10 @@ #include IMAGE_VERSION 2 +#ifdef CONFIG_SECURE_BOOT +CSF CONFIG_CSF_SIZE +#endif + BOOT_FROM sd /* From a2accd843b8171ff60e5684214a19bba94c655e4 Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Tue, 24 Apr 2018 18:46:33 +0100 Subject: [PATCH 06/34] warp7: hab: Set environment variable indicating HAB enable This patch adds an environment variable called "hab_enabled" which gets set to a boolean status indicating whether HAB is enabled or not. Subsequent patches can use this environment variable to determine if its necessary to run a given binary through the hab_auth_img console command. Signed-off-by: Bryan O'Donoghue Tested-by: Breno Lima Reviewed-by: Fabio Estevam --- board/warp7/warp7.c | 8 ++++++++ include/configs/warp7.h | 3 +++ 2 files changed, 11 insertions(+) diff --git a/board/warp7/warp7.c b/board/warp7/warp7.c index 327f656..0d3d324 100644 --- a/board/warp7/warp7.c +++ b/board/warp7/warp7.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -203,6 +204,13 @@ int board_late_init(void) */ clrsetbits_le16(&wdog->wcr, 0, 0x10); +#ifdef CONFIG_SECURE_BOOT + /* Determine HAB state */ + env_set_ulong(HAB_ENABLED_ENVNAME, imx_hab_is_enabled()); +#else + env_set_ulong(HAB_ENABLED_ENVNAME, 0); +#endif + #ifdef CONFIG_SERIAL_TAG /* Set serial# standard environment variable based on OTP settings */ get_board_serial(&serialnr); diff --git a/include/configs/warp7.h b/include/configs/warp7.h index 98fedb8..10db716 100644 --- a/include/configs/warp7.h +++ b/include/configs/warp7.h @@ -139,4 +139,7 @@ #define CONFIG_USBNET_DEV_ADDR "de:ad:be:af:00:01" +/* Environment variable name to represent HAB enable state */ +#define HAB_ENABLED_ENVNAME "hab_enabled" + #endif From c727bba74a44dd49d71fa3fab9f57ed1e0c277d3 Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Tue, 24 Apr 2018 18:46:34 +0100 Subject: [PATCH 07/34] warp7: defconfig: Enable OPTEE for WaRP7 Requires setting CONFIG_OPTEE=y and setting an OPTEE TrustZone DRAM base in include/configs/warp7.h. Signed-off-by: Bryan O'Donoghue Tested-by: Breno Lima Reviewed-by: Fabio Estevam --- configs/warp7_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/warp7_defconfig b/configs/warp7_defconfig index b048148..c72e6b3 100644 --- a/configs/warp7_defconfig +++ b/configs/warp7_defconfig @@ -44,3 +44,4 @@ 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=y From 7175ef4a71e01fe416845a7ecb9af2dfa201cc87 Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Tue, 24 Apr 2018 18:46:35 +0100 Subject: [PATCH 08/34] warp7: Allocate specific region of memory to OPTEE Subtracts CONFIG_OPTEE_TZDRAM_SIZE from the available DRAM size. On WaRP7 we simply define the OPTEE region as from the maximum DRAM address minus CONFIG_OPTEE_TZDRAM_SIZE bytes. Note the OPTEE boot process will itself subtract the DRAM region it lives in from the memory map passed to Linux. Signed-off-by: Bryan O'Donoghue Tested-by: Breno Lima Reviewed-by: Fabio Estevam --- board/warp7/warp7.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/board/warp7/warp7.c b/board/warp7/warp7.c index 0d3d324..56f0cdd 100644 --- a/board/warp7/warp7.c +++ b/board/warp7/warp7.c @@ -58,6 +58,11 @@ int dram_init(void) { gd->ram_size = PHYS_SDRAM_SIZE; + /* Subtract the defined OPTEE runtime firmware length */ +#ifdef CONFIG_OPTEE_TZDRAM_SIZE + gd->ram_size -= CONFIG_OPTEE_TZDRAM_SIZE; +#endif + return 0; } From fbbf44af318b20b61658d2461ff858d5134aa3f5 Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Tue, 24 Apr 2018 18:46:36 +0100 Subject: [PATCH 09/34] warp7: Print out the OPTEE DRAM region Right now a region of 0x300000 bytes is allocated at the end of DRAM for the purposes of loading an OPTEE firmware inside of it. This patch adds the printout of the relevant address ranges. Signed-off-by: Bryan O'Donoghue Tested-by: Breno Lima Reviewed-by: Fabio Estevam --- board/warp7/warp7.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/board/warp7/warp7.c b/board/warp7/warp7.c index 56f0cdd..da52b18 100644 --- a/board/warp7/warp7.c +++ b/board/warp7/warp7.c @@ -181,7 +181,17 @@ int checkboard(void) else mode = "non-secure"; +#ifdef CONFIG_OPTEE_TZDRAM_SIZE + unsigned long optee_start, optee_end; + + optee_end = PHYS_SDRAM + PHYS_SDRAM_SIZE; + optee_start = optee_end - CONFIG_OPTEE_TZDRAM_SIZE; + + printf("Board: WARP7 in %s mode OPTEE DRAM 0x%08lx-0x%08lx\n", + mode, optee_start, optee_end); +#else printf("Board: WARP7 in %s mode\n", mode); +#endif return 0; } From 4bcbfcf458744a84bd82bd7239593f371574bd2c Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Tue, 24 Apr 2018 18:46:37 +0100 Subject: [PATCH 10/34] warp7: Specify CONFIG_OPTEE_LOAD_ADDR In order to sign images with the IMX code-signing-tool (CST) we need to know the load address of a given image. The best way to derive this load address is to make it into a define - so that u-boot.cfg contains the address - which we can then parse when generating the IMX CST headers. This patch makes the OPTEE_LOAD_ADDR available via u-boot.cfg for further parsing by external tools. Signed-off-by: Bryan O'Donoghue Reviewed-by: Ryan Harkin Tested-by: Breno Lima Reviewed-by: Fabio Estevam --- configs/warp7_defconfig | 1 + include/configs/warp7.h | 1 + 2 files changed, 2 insertions(+) diff --git a/configs/warp7_defconfig b/configs/warp7_defconfig index c72e6b3..8152e8e 100644 --- a/configs/warp7_defconfig +++ b/configs/warp7_defconfig @@ -45,3 +45,4 @@ CONFIG_USB_ETH_CDC=y CONFIG_USBNET_HOST_ADDR="de:ad:be:af:00:00" CONFIG_OF_LIBFDT=y CONFIG_OPTEE=y +CONFIG_OPTEE_LOAD_ADDR=0x84000000 diff --git a/include/configs/warp7.h b/include/configs/warp7.h index 10db716..e12b90b 100644 --- a/include/configs/warp7.h +++ b/include/configs/warp7.h @@ -40,6 +40,7 @@ "initrd_high=0xffffffff\0" \ "fdt_file=imx7s-warp.dtb\0" \ "fdt_addr=0x83000000\0" \ + "optee_addr=" __stringify(CONFIG_OPTEE_LOAD_ADDR)"\0" \ "boot_fdt=try\0" \ "ip_dyn=yes\0" \ "mmcdev="__stringify(CONFIG_SYS_MMC_ENV_DEV)"\0" \ From 9fb2c1faa18201ab1fb7efed4140eff97b453870 Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Tue, 24 Apr 2018 18:46:38 +0100 Subject: [PATCH 11/34] warp7: defconfig: Enable CONFIG_SECURE_BOOT Various function associated with booting the WaRP7 in High Assurance Boot (HAB) mode are enabled by switching on CONFIG_SECURE_BOOT. This patch enables CONFIG_SECURE_BOOT for the WaRP7 defconfig. Signed-off-by: Bryan O'Donoghue Tested-by: Breno Lima Reviewed-by: Fabio Estevam --- configs/warp7_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/warp7_defconfig b/configs/warp7_defconfig index 8152e8e..2e65b8d 100644 --- a/configs/warp7_defconfig +++ b/configs/warp7_defconfig @@ -1,5 +1,6 @@ CONFIG_ARM=y CONFIG_ARCH_MX7=y +CONFIG_SECURE_BOOT=y CONFIG_SYS_TEXT_BASE=0x87800000 CONFIG_TARGET_WARP7=y # CONFIG_ARMV7_VIRT is not set From 42fcabdb26ca009db7cda97b3199fc57105377b3 Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Tue, 24 Apr 2018 18:46:39 +0100 Subject: [PATCH 12/34] warp7: defconfig: Enable CONFIG_BOOTM_TEE This patch enables CONFIG_BOOTM_TEE. Once enabled its possible to chain-load Linux through OPTEE. Loading kernel to 0x80800000 => run loadimage Load FDT to 0x83000000 => run loadfdt Load OPTEE to 0x84000000 => fatload mmc 0:5 0x84000000 /lib/firmware/uTee.optee Then chain-load to the kernel via OPTEE => bootm 0x84000000 - 0x83000000 Image Name: Image Type: ARM Trusted Execution Environment Kernel Image (uncompressed) Data Size: 249844 Bytes = 244 KiB Load Address: 9dffffe4 Entry Point: 9e000000 Verifying Checksum ... OK Loading Kernel Image ... OK Signed-off-by: Bryan O'Donoghue Tested-by: Breno Lima Reviewed-by: Fabio Estevam --- configs/warp7_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/warp7_defconfig b/configs/warp7_defconfig index 2e65b8d..8a8dfc0 100644 --- a/configs/warp7_defconfig +++ b/configs/warp7_defconfig @@ -47,3 +47,4 @@ CONFIG_USBNET_HOST_ADDR="de:ad:be:af:00:00" CONFIG_OF_LIBFDT=y CONFIG_OPTEE=y CONFIG_OPTEE_LOAD_ADDR=0x84000000 +CONFIG_BOOTM_OPTEE=y From 56eca404e1dc7aed65fb5268826eba1c548434ae Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Tue, 24 Apr 2018 18:46:40 +0100 Subject: [PATCH 13/34] warp7: Make CONFIG_SYS_FDT_ADDR a define In order to sign images with the IMX code-signing-tool (CST) we need to know the load address of a given image. The best way to derive this load address is to make it into a define - so that u-boot.cfg contains the address - which we can then parse when generating the IMX CST headers. Signed-off-by: Bryan O'Donoghue Reviewed-by: Ryan Harkin Tested-by: Breno Lima Reviewed-by: Fabio Estevam --- board/warp7/Kconfig | 6 ++++++ include/configs/warp7.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/board/warp7/Kconfig b/board/warp7/Kconfig index 61c33fb..00df19d 100644 --- a/board/warp7/Kconfig +++ b/board/warp7/Kconfig @@ -6,4 +6,10 @@ config SYS_BOARD config SYS_CONFIG_NAME default "warp7" +config SYS_FDT_ADDR + hex "FDT load address" + default 0x83000000 + help + The address the FDT file should be loaded to. + endif diff --git a/include/configs/warp7.h b/include/configs/warp7.h index e12b90b..344042c 100644 --- a/include/configs/warp7.h +++ b/include/configs/warp7.h @@ -39,7 +39,7 @@ "fdt_high=0xffffffff\0" \ "initrd_high=0xffffffff\0" \ "fdt_file=imx7s-warp.dtb\0" \ - "fdt_addr=0x83000000\0" \ + "fdt_addr=" __stringify(CONFIG_SYS_FDT_ADDR)"\0" \ "optee_addr=" __stringify(CONFIG_OPTEE_LOAD_ADDR)"\0" \ "boot_fdt=try\0" \ "ip_dyn=yes\0" \ From 95b649f27d7e399825782ab51688a4f2cb24c47f Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Tue, 24 Apr 2018 18:46:41 +0100 Subject: [PATCH 14/34] warp7: Add Kconfig WARP7_ROOT_PART Adding CONFIG_WARP7_ROOT_PART allows a defconfig to specify which partition is use as the root partition on WaRP7, this is a desirable change in order to support a different partitioning schemes. The default is the current partition #2. Signed-off-by: Bryan O'Donoghue Tested-by: Breno Lima Reviewed-by: Fabio Estevam --- board/warp7/Kconfig | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/board/warp7/Kconfig b/board/warp7/Kconfig index 00df19d..c089bca 100644 --- a/board/warp7/Kconfig +++ b/board/warp7/Kconfig @@ -6,6 +6,14 @@ config SYS_BOARD config SYS_CONFIG_NAME default "warp7" +config WARP7_ROOT_PART + int "Partition number to use for root filesystem" + default 2 + help + The partition number to use for root filesystem this is the + partition that is typically specified with root=/dev/sdaX or + which gets converted into a root=PARTUUID=some_uuid. + config SYS_FDT_ADDR hex "FDT load address" default 0x83000000 From 2948089815437232aab9eff54d0abdc2949a22ae Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Tue, 24 Apr 2018 18:46:42 +0100 Subject: [PATCH 15/34] warp7: select uuid partition based on rootpart Assigning the UUID discovery path to a tweakable environment variable means that later steps in the boot process - particularly a boot script can change the target root partition of a particular Linux boot. Retargeting the rootfs is an important feature when doing ping/pong upgrades allowing a boot script to select ping or pong as necessary without reprogramming the bootloader. Signed-off-by: Bryan O'Donoghue Tested-by: Breno Lima Reviewed-by: Fabio Estevam --- include/configs/warp7.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/configs/warp7.h b/include/configs/warp7.h index 344042c..54b3b31 100644 --- a/include/configs/warp7.h +++ b/include/configs/warp7.h @@ -45,7 +45,8 @@ "ip_dyn=yes\0" \ "mmcdev="__stringify(CONFIG_SYS_MMC_ENV_DEV)"\0" \ "mmcpart=" __stringify(CONFIG_SYS_MMC_IMG_LOAD_PART) "\0" \ - "finduuid=part uuid mmc 0:2 uuid\0" \ + "rootpart=" __stringify(CONFIG_WARP7_ROOT_PART) "\0" \ + "finduuid=part uuid mmc 0:${rootpart} uuid\0" \ "mmcargs=setenv bootargs console=${console},${baudrate} " \ "root=PARTUUID=${uuid} rootwait rw\0" \ "loadbootscript=" \ From e4514051fca3a89850d7e62c29dff4e1194d225d Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Tue, 24 Apr 2018 18:46:43 +0100 Subject: [PATCH 16/34] warp7: Define the name of a signed boot-script file We need to know the name of a signed boot-script, its better to have a separate variable for this then to simply append some fixed string to an existing image name. Signed-off-by: Bryan O'Donoghue Tested-by: Breno Lima Reviewed-by: Fabio Estevam --- include/configs/warp7.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/configs/warp7.h b/include/configs/warp7.h index 54b3b31..0ed95d8 100644 --- a/include/configs/warp7.h +++ b/include/configs/warp7.h @@ -33,6 +33,7 @@ #define CONFIG_EXTRA_ENV_SETTINGS \ CONFIG_DFU_ENV_SETTINGS \ "script=boot.scr\0" \ + "script_signed=boot.scr.imx-signed\0" \ "image=zImage\0" \ "console=ttymxc0\0" \ "ethact=usb_ether\0" \ From c0df0caeb8d6722cc61e3a8f777f8a47e0167fb9 Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Tue, 24 Apr 2018 18:46:44 +0100 Subject: [PATCH 17/34] warp7: add warp7_auth_or_fail Doing secure boot on the WaRP7 using a common image format and the same variable to represent the base address for each call means we can reduce down the command to a single environment command. This patch adds warp7_auth_or_fail as a wrapper around "hab_auth_img_or_fail ${hab_ivt_addr} ${filesize} 0". Signed-off-by: Bryan O'Donoghue Tested-by: Breno Lima Reviewed-by: Fabio Estevam --- include/configs/warp7.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/configs/warp7.h b/include/configs/warp7.h index 0ed95d8..454bc1c 100644 --- a/include/configs/warp7.h +++ b/include/configs/warp7.h @@ -50,6 +50,7 @@ "finduuid=part uuid mmc 0:${rootpart} uuid\0" \ "mmcargs=setenv bootargs console=${console},${baudrate} " \ "root=PARTUUID=${uuid} rootwait rw\0" \ + "warp7_auth_or_fail=hab_auth_img_or_fail ${hab_ivt_addr} ${filesize} 0;\0" \ "loadbootscript=" \ "load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \ "bootscript=echo Running bootscript from mmc ...; " \ From d9cb9aec743265b56a57e89ec20dde6f38d5e554 Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Tue, 24 Apr 2018 18:46:45 +0100 Subject: [PATCH 18/34] warp7: hab: Set environment variable indicating IVT offset This patch introduces the environment variable ivt_offset. When we define a load address for Linux or DTB or any file the IVT associated with that file is prepended. We extract the actual load addresses from u-boot.cfg and feed these values into the code-signing process - hence we want u-boot to have the real load addresses exported in uboot.cfg. ivt_offset represents the addition or subtraction from the load address that must happen to find an IVT header. Signed-off-by: Bryan O'Donoghue Tested-by: Breno Lima Reviewed-by: Fabio Estevam --- include/configs/warp7.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/configs/warp7.h b/include/configs/warp7.h index 454bc1c..fe9b7d5 100644 --- a/include/configs/warp7.h +++ b/include/configs/warp7.h @@ -10,6 +10,7 @@ #define __WARP7_CONFIG_H #include "mx7_common.h" +#include #define PHYS_SDRAM_SIZE SZ_512M @@ -50,6 +51,7 @@ "finduuid=part uuid mmc 0:${rootpart} uuid\0" \ "mmcargs=setenv bootargs console=${console},${baudrate} " \ "root=PARTUUID=${uuid} rootwait rw\0" \ + "ivt_offset=" __stringify(BOOTROM_IVT_HDR_OFFSET)"\0"\ "warp7_auth_or_fail=hab_auth_img_or_fail ${hab_ivt_addr} ${filesize} 0;\0" \ "loadbootscript=" \ "load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \ From baea5ecd26888263bd614ff86f93df89302b3627 Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Tue, 24 Apr 2018 18:46:46 +0100 Subject: [PATCH 19/34] warp7: defconfig: Enable CMD_SETEXPR setexpr allows us to do arithmetic for env variables - something that is both useful and required when doing HAB authentication without hard-coding HAB load addresses. This patch enables CMD_SETEXPR for the WaRP7 defconfig. Signed-off-by: Bryan O'Donoghue Tested-by: Breno Lima Reviewed-by: Fabio Estevam --- configs/warp7_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/warp7_defconfig b/configs/warp7_defconfig index 8a8dfc0..16631a4 100644 --- a/configs/warp7_defconfig +++ b/configs/warp7_defconfig @@ -20,7 +20,7 @@ CONFIG_CMD_MMC=y CONFIG_CMD_PART=y CONFIG_CMD_USB=y CONFIG_CMD_USB_MASS_STORAGE=y -# CONFIG_CMD_SETEXPR is not set +CONFIG_CMD_SETEXPR=y CONFIG_CMD_DHCP=y CONFIG_CMD_CACHE=y CONFIG_CMD_EXT2=y From bb96a08d5b48f0ee3415619c2119d7153de1d0c2 Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Tue, 24 Apr 2018 18:46:47 +0100 Subject: [PATCH 20/34] warp7: Add support for automated secure boot.scr verification This patch adds support for verifying a signed boot.scr. With this in place it's possible for run-time Linux to update boot.scr to set different variables such as switching between different boot partitions, pointing to different kernels etc and for u-boot to verify these changes via the HAB prior to executing the commands contained in boot.scr. Signed-off-by: Bryan O'Donoghue Tested-by: Breno Lima Reviewed-by: Fabio Estevam --- include/configs/warp7.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/configs/warp7.h b/include/configs/warp7.h index fe9b7d5..f340bff 100644 --- a/include/configs/warp7.h +++ b/include/configs/warp7.h @@ -53,6 +53,14 @@ "root=PARTUUID=${uuid} rootwait rw\0" \ "ivt_offset=" __stringify(BOOTROM_IVT_HDR_OFFSET)"\0"\ "warp7_auth_or_fail=hab_auth_img_or_fail ${hab_ivt_addr} ${filesize} 0;\0" \ + "do_bootscript_hab=" \ + "if test ${hab_enabled} -eq 1; then " \ + "setexpr hab_ivt_addr ${loadaddr} - ${ivt_offset}; " \ + "setenv script ${script_signed}; " \ + "load mmc ${mmcdev}:${mmcpart} ${hab_ivt_addr} ${script}; " \ + "run warp7_auth_or_fail; " \ + "run bootscript; "\ + "fi;\0" \ "loadbootscript=" \ "load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \ "bootscript=echo Running bootscript from mmc ...; " \ @@ -79,6 +87,7 @@ #define CONFIG_BOOTCOMMAND \ "mmc dev ${mmcdev};" \ "mmc dev ${mmcdev}; if mmc rescan; then " \ + "run do_bootscript_hab;" \ "if run loadbootscript; then " \ "run bootscript; " \ "else " \ From 5ebf9ad96c31d88b6dedc6dd1efa043fd882d044 Mon Sep 17 00:00:00 2001 From: Mark Jonas Date: Mon, 16 Apr 2018 18:11:50 +0200 Subject: [PATCH 21/34] arm,imx6: fix PAD_CTL_SPEED_LOW constant For most i.MX6 processors the PAD_CTL_SPEED_LOW constant is the same. Only the i.MX6 SoloLite is an exemption. So far the code did not consider that. Additionally, for a few i.MX6 processors the code used the wrong value for the constant. This patch fixes the PAD_CTL_SPEED_LOW constant for: - i.MX6 Solo [1] - i.MX6 DualLite [1] - i.MX6 Dual [2] - i.MX6 Quad [2] - i.MX6 DualPlus [3] - i.MX6 QuadPlus [3] Before, it was already correct for: - i.MX6 SoloLite [4] - i.MX6 SoloX [5] - i.MX6 UtraLite [6] - i.MX6 ULL [7] [1] https://www.nxp.com/docs/en/reference-manual/IMX6SDLRM.pdf [2] https://www.nxp.com/docs/en/reference-manual/IMX6DQRM.pdf [3] https://www.nxp.com/docs/en/reference-manual/iMX6DQPRM.pdf [4] https://www.nxp.com/docs/en/reference-manual/IMX6SLRM.pdf [5] https://www.nxp.com/docs/en/reference-manual/IMX6SXRM.pdf [6] https://www.nxp.com/docs/en/reference-manual/IMX6ULRM.pdf [7] https://www.nxp.com/docs/en/reference-manual/IMX6ULLRM.pdf Signed-off-by: Mark Jonas Reviewed-by: Heiko Schocher --- arch/arm/include/asm/mach-imx/iomux-v3.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/include/asm/mach-imx/iomux-v3.h b/arch/arm/include/asm/mach-imx/iomux-v3.h index 0c0ccf44..09094c9 100644 --- a/arch/arm/include/asm/mach-imx/iomux-v3.h +++ b/arch/arm/include/asm/mach-imx/iomux-v3.h @@ -147,10 +147,10 @@ typedef u64 iomux_v3_cfg_t; #define PAD_CTL_ODE (1 << 11) -#if defined(CONFIG_MX6SX) || defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL) -#define PAD_CTL_SPEED_LOW (0 << 6) -#else +#if defined(CONFIG_MX6SL) #define PAD_CTL_SPEED_LOW (1 << 6) +#else +#define PAD_CTL_SPEED_LOW (0 << 6) #endif #define PAD_CTL_SPEED_MED (2 << 6) #define PAD_CTL_SPEED_HIGH (3 << 6) From feb14c6348caadfd7bbb1e972f0c484faffa5a72 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Thu, 19 Apr 2018 17:34:10 -0300 Subject: [PATCH 22/34] mx7dsabresd: Remove the mx7dsabresd_secure_defconfig target mx7dsabresd_secure_defconfig was introduced to allow booting NXP kernel that has CAAM support and needs to boot in secure mode. Instead of keeping two different config targets for the same board, remove mx7dsabresd_secure_defconfig and select CONFIG_ARMV7_BOOT_SEC_DEFAULT inside mx7dsabresd_defconfig so that this target could be used to boot both mainline and the vendor kernel. This makes maintenance task easier and avoid potentially confusion for the end user. Signed-off-by: Fabio Estevam Acked-by: Bryan O'Donoghue --- board/freescale/mx7dsabresd/MAINTAINERS | 1 - configs/mx7dsabresd_defconfig | 1 + configs/mx7dsabresd_secure_defconfig | 78 --------------------------------- 3 files changed, 1 insertion(+), 79 deletions(-) delete mode 100644 configs/mx7dsabresd_secure_defconfig diff --git a/board/freescale/mx7dsabresd/MAINTAINERS b/board/freescale/mx7dsabresd/MAINTAINERS index c7a22fc..b96642a 100644 --- a/board/freescale/mx7dsabresd/MAINTAINERS +++ b/board/freescale/mx7dsabresd/MAINTAINERS @@ -4,4 +4,3 @@ S: Maintained F: board/freescale/mx7dsabresd F: include/configs/mx7dsabresd.h F: configs/mx7dsabresd_defconfig -F: configs/mx7dsabresd_secure_defconfig diff --git a/configs/mx7dsabresd_defconfig b/configs/mx7dsabresd_defconfig index da881d9..33851c1 100644 --- a/configs/mx7dsabresd_defconfig +++ b/configs/mx7dsabresd_defconfig @@ -2,6 +2,7 @@ CONFIG_ARM=y CONFIG_ARCH_MX7=y CONFIG_SYS_TEXT_BASE=0x87800000 CONFIG_TARGET_MX7DSABRESD=y +CONFIG_ARMV7_BOOT_SEC_DEFAULT=y # CONFIG_ARMV7_VIRT is not set CONFIG_IMX_RDC=y CONFIG_IMX_BOOTAUX=y diff --git a/configs/mx7dsabresd_secure_defconfig b/configs/mx7dsabresd_secure_defconfig deleted file mode 100644 index 58e60ed..0000000 --- a/configs/mx7dsabresd_secure_defconfig +++ /dev/null @@ -1,78 +0,0 @@ -CONFIG_ARM=y -CONFIG_ARCH_MX7=y -CONFIG_SYS_TEXT_BASE=0x87800000 -CONFIG_TARGET_MX7DSABRESD=y -CONFIG_ARMV7_BOOT_SEC_DEFAULT=y -# CONFIG_ARMV7_VIRT is not set -CONFIG_IMX_RDC=y -CONFIG_IMX_BOOTAUX=y -# CONFIG_CMD_BMODE is not set -CONFIG_DEFAULT_DEVICE_TREE="imx7d-sdb" -CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx7dsabresd/imximage.cfg" -# CONFIG_CONSOLE_MUX is not set -CONFIG_SYS_CONSOLE_IS_IN_ENV=y -CONFIG_HUSH_PARSER=y -# CONFIG_CMD_BOOTD is not set -CONFIG_CMD_BOOTZ=y -# CONFIG_CMD_IMI is not set -# CONFIG_CMD_XIMG is not set -# CONFIG_CMD_EXPORTENV is not set -# CONFIG_CMD_IMPORTENV is not set -CONFIG_CMD_MEMTEST=y -CONFIG_CMD_DFU=y -CONFIG_CMD_GPIO=y -CONFIG_CMD_I2C=y -CONFIG_CMD_MMC=y -CONFIG_CMD_SF=y -CONFIG_CMD_USB=y -CONFIG_CMD_USB_MASS_STORAGE=y -CONFIG_CMD_DHCP=y -CONFIG_CMD_MII=y -CONFIG_CMD_PING=y -CONFIG_CMD_BMP=y -CONFIG_CMD_CACHE=y -CONFIG_CMD_PMIC=y -CONFIG_CMD_REGULATOR=y -CONFIG_CMD_EXT2=y -CONFIG_CMD_EXT4=y -CONFIG_CMD_EXT4_WRITE=y -CONFIG_CMD_FAT=y -CONFIG_OF_CONTROL=y -CONFIG_DFU_MMC=y -CONFIG_DFU_RAM=y -CONFIG_DM_GPIO=y -CONFIG_DM_74X164=y -CONFIG_DM_I2C=y -CONFIG_DM_MMC=y -CONFIG_MMC_IO_VOLTAGE=y -CONFIG_MMC_UHS_SUPPORT=y -CONFIG_MMC_HS200_SUPPORT=y -CONFIG_FSL_ESDHC=y -CONFIG_SPI_FLASH=y -CONFIG_SPI_FLASH_EON=y -CONFIG_PHYLIB=y -CONFIG_PINCTRL=y -CONFIG_PINCTRL_IMX7=y -CONFIG_DM_PMIC=y -CONFIG_DM_PMIC_PFUZE100=y -CONFIG_DM_REGULATOR=y -CONFIG_DM_REGULATOR_PFUZE100=y -CONFIG_DM_REGULATOR_FIXED=y -CONFIG_DM_REGULATOR_GPIO=y -CONFIG_DM_SPI=y -CONFIG_SOFT_SPI=y -CONFIG_USB=y -CONFIG_DM_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_HOST_ETHER=y -CONFIG_USB_ETHER_ASIX=y -CONFIG_VIDEO=y -CONFIG_ERRNO_STR=y From f3c326287e3e32f7ffcf2286462793a554b158c4 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sun, 15 Apr 2018 07:37:36 -0300 Subject: [PATCH 23/34] Revert "imximage: Remove failure when no IVT offset is found" This reverts commit b5b0e4e351e20a606de22db6a56ad6bc1e2aa8fd. Commit f916757300c1 ("imx: Create distinct pre-processed mkimage config files") provided a proper fix for the parallel mkimage config files build failure, so the original workaround can be safely reverted now. Signed-off-by: Fabio Estevam Reviewed-by: Stefano Babic --- tools/imximage.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/imximage.c b/tools/imximage.c index 6f16d45..14f8015 100644 --- a/tools/imximage.c +++ b/tools/imximage.c @@ -777,6 +777,11 @@ static uint32_t parse_cfg_file(struct imx_header *imxhdr, char *name) (*set_dcd_rst)(imxhdr, dcd_len, name, lineno); fclose(fd); + /* Exit if there is no BOOT_FROM field specifying the flash_offset */ + if (imximage_ivt_offset == FLASH_OFFSET_UNDEFINED) { + fprintf(stderr, "Error: No BOOT_FROM tag in %s\n", name); + exit(EXIT_FAILURE); + } return dcd_len; } From 178d4f009990feeb01cb2d0002faf6dcca221968 Mon Sep 17 00:00:00 2001 From: Lukasz Majewski Date: Sun, 15 Apr 2018 21:45:54 +0200 Subject: [PATCH 24/34] eth: dm: fec: Change FEC PHY mask setting from CONFIG_PHYLIB to CONFIG_FEC_MXC_PHYADDR Without this commit we do have an explicit dependency on CONFIG_PHYLIB when one wants to set PHY ADDR on a iMX board (FEC + driver model). This shall be changed to CONFIG_FEC_MXC_PHYADDR, as only when we do have it set, we shall mask out other devices. As a side effect, when CONFIG_FEC_MXC_PHYADDR is not set, we scan PHY bus for connected PHY devices. Signed-off-by: Lukasz Majewski --- drivers/net/fec_mxc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index 0076d63..f21fd44 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -1230,7 +1230,7 @@ static int fec_phy_init(struct fec_priv *priv, struct udevice *dev) struct phy_device *phydev; int mask = 0xffffffff; -#ifdef CONFIG_PHYLIB +#ifdef CONFIG_FEC_MXC_PHYADDR mask = 1 << CONFIG_FEC_MXC_PHYADDR; #endif From 948239ea164b6dca98a9d49fb83425b2089e3a46 Mon Sep 17 00:00:00 2001 From: Lukasz Majewski Date: Sun, 15 Apr 2018 21:54:22 +0200 Subject: [PATCH 25/34] dts: dm: fec: imx53: Provide proper compatible string for imx53 fec driver After this change the DM FEC ETH driver can be also reused on some imx53 devices. Signed-off-by: Lukasz Majewski --- drivers/net/fec_mxc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index f21fd44..5740379 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -1345,6 +1345,7 @@ static const struct udevice_id fecmxc_ids[] = { { .compatible = "fsl,imx6sl-fec" }, { .compatible = "fsl,imx6sx-fec" }, { .compatible = "fsl,imx6ul-fec" }, + { .compatible = "fsl,imx53-fec" }, { } }; From 8273209bd9741e52e7a9db4ea76113e82213bbc0 Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Tue, 24 Apr 2018 18:44:31 +0100 Subject: [PATCH 26/34] warp7: secure_defconfig: Remove secure_defconfig This patch removes warp7_secure_defconfig. A previous patch set CONFIG_ARMV7_BOOT_SEC_DEFAULT=y on the unsecure WaRP7 config. Fabio asked if I could confirm that the NXP and upstream kernels will boot on the WaRP7 with CONFIG_ARMV7_BOOT_SEC_DEFAULT=y. I can confirm that this is the case, so there's no need to support the secure defconfig - drop it now. Signed-off-by: Bryan O'Donoghue Suggested-by: Fabio Estevam Reviewed-by: Fabio Estevam --- board/warp7/MAINTAINERS | 1 - configs/warp7_secure_defconfig | 43 ------------------------------------------ 2 files changed, 44 deletions(-) delete mode 100644 configs/warp7_secure_defconfig diff --git a/board/warp7/MAINTAINERS b/board/warp7/MAINTAINERS index 0fc9746..1d3ee29 100644 --- a/board/warp7/MAINTAINERS +++ b/board/warp7/MAINTAINERS @@ -4,4 +4,3 @@ S: Maintained F: board/warp7/ F: include/configs/warp7.h F: configs/warp7_defconfig -F: configs/warp7_secure_defconfig diff --git a/configs/warp7_secure_defconfig b/configs/warp7_secure_defconfig deleted file mode 100644 index 915f218..0000000 --- a/configs/warp7_secure_defconfig +++ /dev/null @@ -1,43 +0,0 @@ -CONFIG_ARM=y -CONFIG_ARCH_MX7=y -CONFIG_SYS_TEXT_BASE=0x87800000 -CONFIG_TARGET_WARP7=y -CONFIG_ARMV7_BOOT_SEC_DEFAULT=y -# CONFIG_ARMV7_VIRT is not set -CONFIG_IMX_RDC=y -CONFIG_IMX_BOOTAUX=y -# CONFIG_CMD_BMODE is not set -CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/warp7/imximage.cfg" -CONFIG_HUSH_PARSER=y -# CONFIG_CMD_BOOTD is not set -CONFIG_CMD_BOOTZ=y -# CONFIG_CMD_IMI is not set -# CONFIG_CMD_XIMG is not set -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 is not set -CONFIG_CMD_CACHE=y -CONFIG_CMD_EXT2=y -CONFIG_CMD_EXT4=y -CONFIG_CMD_EXT4_WRITE=y -CONFIG_CMD_FAT=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_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 From e426e193539e4fa5f52bc55499f66c4159a3372d Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Tue, 24 Apr 2018 18:44:30 +0100 Subject: [PATCH 27/34] warp7: defconfig: Fix CAAM on boot with tip-of-tree Booting the following image with tip-of-tree we get a CAAM DECO error (and subsequent crash due to a kernel bug in 4.1). http://freescale.github.io/#download -> BoardsWaRPboard community - WaRP - Wearable Reference PlatformFSL Community BSP 2.3fsl-image-multimediawayland Image: fsl-image-multimedia-imx7s-warp-20180323-90.rootfs.sdcard Error: caam 30900000.caam: Entropy delay = 3200 caam 30900000.caam: failed to acquire DECO 0 caam 30900000.caam: failed to acquire DECO 0 caam 30900000.caam: Entropy delay = 12400 caam 30900000.caam: failed to acquire DECO 0 caam 30900000.caam: failed to instantiate RNG ------------[ cut here ]------------ WARNING: CPU: 0 PID: 1 at /home/jenkins/workspace/fsl-community-bsp-pyro_xwayland_2/build/tmp/work-shared/imx7s-warp/kernel-source/mm/vmalloc.c:1465 caam_remove+0x6) Trying to vfree() nonexistent vm area (88047000) Modules linked in: CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.1.36-4.1-1.0.x-imx-warp7+ga543d1b #1 Hardware name: Freescale i.MX7 Dual (Device Tree) [<80015d54>] (unwind_backtrace) from [<80012688>] (show_stack+0x10/0x14) [<80012688>] (show_stack) from [<8076e810>] (dump_stack+0x78/0x8c) [<8076e810>] (dump_stack) from [<800346a0>] (warn_slowpath_common+0x80/0xb0) [<800346a0>] (warn_slowpath_common) from [<80034700>] (warn_slowpath_fmt+0x30/0x40) [<80034700>] (warn_slowpath_fmt) from [<8054c278>] (caam_remove+0x6c/0x3f4) [<8054c278>] (caam_remove) from [<8054ce74>] (caam_probe+0x874/0xfa8) [<8054ce74>] (caam_probe) from [<80382a7c>] (platform_drv_probe+0x48/0xa4) [<80382a7c>] (platform_drv_probe) from [<80381328>] (driver_probe_device+0x174/0x2a8) [<80381328>] (driver_probe_device) from [<8038152c>] (__driver_attach+0x8c/0x90) [<8038152c>] (__driver_attach) from [<8037f9d4>] (bus_for_each_dev+0x68/0x9c) [<8037f9d4>] (bus_for_each_dev) from [<80380a68>] (bus_add_driver+0xf4/0x1e8) [<80380a68>] (bus_add_driver) from [<80381b38>] (driver_register+0x78/0xf4) [<80381b38>] (driver_register) from [<80009738>] (do_one_initcall+0x8c/0x1d0) [<80009738>] (do_one_initcall) from [<80a66dac>] (kernel_init_freeable+0x140/0x1d0) [<80a66dac>] (kernel_init_freeable) from [<8076aa38>] (kernel_init+0x8/0xe8) [<8076aa38>] (kernel_init) from [<8000f468>] (ret_from_fork+0x14/0x2c) ---[ end trace d5f941204ed8cb28 ]--- caam: probe of 30900000.caam failed with error -11 Unable to handle kernel NULL pointer dereference at virtual address 00000004 pgd = 80004000 [00000004] *pgd=00000000 Internal error: Oops: 805 [#1] PREEMPT SMP ARM [<8055cdf8>] (caam_sm_startup) from [<80aa83c8>] (caam_sm_init+0x50/0x58) [<80aa83c8>] (caam_sm_init) from [<80009738>] (do_one_initcall+0x8c/0x1d0) [<80009738>] (do_one_initcall) from [<80a66dac>] (kernel_init_freeable+0x140/0x1d0) [<80a66dac>] (kernel_init_freeable) from [<8076aa38>] (kernel_init+0x8/0xe8) [<8076aa38>] (kernel_init) from [<8000f468>] (ret_from_fork+0x14/0x2c) Code: e59d300c e2832010 e5843008 e5834068 (e58a2004) ---[ end trace d5f941204ed8cb29 ]--- Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b Fix: Enable the CAAM correctly by setting CONFIG_ARMV7_BOOT_SEC_DEFAULT=y in the upstream defconfig. Signed-off-by: Bryan O'Donoghue Cc: Fabio Estevam Cc: Breno Lima Reviewed-by: Fabio Estevam Tested-by: Breno Lima --- configs/warp7_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/warp7_defconfig b/configs/warp7_defconfig index 16631a4..b936f4a 100644 --- a/configs/warp7_defconfig +++ b/configs/warp7_defconfig @@ -3,6 +3,7 @@ CONFIG_ARCH_MX7=y CONFIG_SECURE_BOOT=y CONFIG_SYS_TEXT_BASE=0x87800000 CONFIG_TARGET_WARP7=y +CONFIG_ARMV7_BOOT_SEC_DEFAULT=y # CONFIG_ARMV7_VIRT is not set CONFIG_IMX_RDC=y CONFIG_IMX_BOOTAUX=y From 30754ef77c3e88acb5a378d4e2c2bcce6228a118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Szymanski?= Date: Tue, 17 Apr 2018 17:29:31 +0200 Subject: [PATCH 28/34] imx6ul: opos6ul: add SPL_DM support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since commit commit 152038ea1886 ("i.MX6UL: icore: Add SPL_OF_CONTROL support") the OPOS6UL board doesn't boot anymore. Adding SPL_DM support makes the board boot again. Fixes: commit 152038ea1886 ("i.MX6UL: icore: Add SPL_OF_CONTROL support") Signed-off-by: Sébastien Szymanski --- arch/arm/dts/imx6ul-opos6ul.dtsi | 4 ++- arch/arm/dts/imx6ul-opos6uldev.dts | 2 ++ arch/arm/dts/imx6ul.dtsi | 1 + arch/arm/include/asm/arch-mx6/opos6ul.h | 4 --- arch/arm/mach-imx/mx6/Kconfig | 4 +++ arch/arm/mach-imx/mx6/opos6ul.c | 50 ++++----------------------------- board/armadeus/opos6uldev/board.c | 20 +------------ configs/opos6uldev_defconfig | 5 ++++ include/configs/opos6uldev.h | 9 ++---- 9 files changed, 25 insertions(+), 74 deletions(-) diff --git a/arch/arm/dts/imx6ul-opos6ul.dtsi b/arch/arm/dts/imx6ul-opos6ul.dtsi index 51095df..d51ad4d 100644 --- a/arch/arm/dts/imx6ul-opos6ul.dtsi +++ b/arch/arm/dts/imx6ul-opos6ul.dtsi @@ -1,5 +1,5 @@ /* - * Copyright 2017 Armadeus Systems + * Copyright 2018 Armadeus Systems * * This file is dual-licensed: you can use it either under the terms * of the GPL or the X11 license, at your option. Note that this dual @@ -99,6 +99,7 @@ /* eMMC */ &usdhc1 { + u-boot,dm-spl; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_usdhc1>; bus-width = <8>; @@ -161,6 +162,7 @@ }; pinctrl_usdhc1: usdhc1grp { + u-boot,dm-spl; fsl,pins = < MX6UL_PAD_SD1_CMD__USDHC1_CMD 0x17059 MX6UL_PAD_SD1_CLK__USDHC1_CLK 0x10059 diff --git a/arch/arm/dts/imx6ul-opos6uldev.dts b/arch/arm/dts/imx6ul-opos6uldev.dts index 0e59ee5..9a51d1e 100644 --- a/arch/arm/dts/imx6ul-opos6uldev.dts +++ b/arch/arm/dts/imx6ul-opos6uldev.dts @@ -228,6 +228,7 @@ }; &uart1 { + u-boot,dm-spl; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_uart1>; status = "okay"; @@ -373,6 +374,7 @@ }; pinctrl_uart1: uart1grp { + u-boot,dm-spl; fsl,pins = < MX6UL_PAD_UART1_TX_DATA__UART1_DCE_TX 0x1b0b1 MX6UL_PAD_UART1_RX_DATA__UART1_DCE_RX 0x1b0b1 diff --git a/arch/arm/dts/imx6ul.dtsi b/arch/arm/dts/imx6ul.dtsi index b63f5a5..d5ce3f1 100644 --- a/arch/arm/dts/imx6ul.dtsi +++ b/arch/arm/dts/imx6ul.dtsi @@ -194,6 +194,7 @@ #size-cells = <1>; reg = <0x02000000 0x40000>; ranges; + u-boot,dm-spl; ecspi1: ecspi@02008000 { #address-cells = <1>; diff --git a/arch/arm/include/asm/arch-mx6/opos6ul.h b/arch/arm/include/asm/arch-mx6/opos6ul.h index b536385..8adff67 100644 --- a/arch/arm/include/asm/arch-mx6/opos6ul.h +++ b/arch/arm/include/asm/arch-mx6/opos6ul.h @@ -9,8 +9,4 @@ int opos6ul_board_late_init(void); -#ifdef CONFIG_SPL_BUILD -void opos6ul_setup_uart_debug(void); -#endif - #endif diff --git a/arch/arm/mach-imx/mx6/Kconfig b/arch/arm/mach-imx/mx6/Kconfig index aa6f5fa..98ea1f5 100644 --- a/arch/arm/mach-imx/mx6/Kconfig +++ b/arch/arm/mach-imx/mx6/Kconfig @@ -73,6 +73,10 @@ config MX6UL_OPOS6UL select DM_MMC select DM_THERMAL select SUPPORT_SPL + select SPL_DM if SPL + select SPL_OF_CONTROL if SPL + select SPL_SEPARATE_BSS if SPL + select SPL_PINCTRL if SPL config MX6ULL select SYS_L2CACHE_OFF diff --git a/arch/arm/mach-imx/mx6/opos6ul.c b/arch/arm/mach-imx/mx6/opos6ul.c index 2de1321..ef70a7d 100644 --- a/arch/arm/mach-imx/mx6/opos6ul.c +++ b/arch/arm/mach-imx/mx6/opos6ul.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Armadeus Systems + * Copyright (C) 2018 Armadeus Systems * * SPDX-License-Identifier: GPL-2.0+ */ @@ -9,15 +9,12 @@ #include #include #include -#include #include #include #include #include #include #include -#include -#include DECLARE_GLOBAL_DATA_PTR; @@ -138,12 +135,6 @@ int board_late_init(void) return opos6ul_board_late_init(); } -int board_mmc_getcd(struct mmc *mmc) -{ - struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv; - return cfg->esdhc_base == USDHC1_BASE_ADDR; -} - int dram_init(void) { gd->ram_size = imx_ddr_size(); @@ -153,32 +144,9 @@ int dram_init(void) #ifdef CONFIG_SPL_BUILD #include -#include #include #include -#define USDHC_PAD_CTRL ( \ - PAD_CTL_HYS | PAD_CTL_PUS_47K_UP | PAD_CTL_SPEED_MED | \ - PAD_CTL_DSE_80ohm | PAD_CTL_SRE_FAST \ -) - -struct fsl_esdhc_cfg usdhc_cfg[1] = { - {USDHC1_BASE_ADDR, 0, 8}, -}; - -static iomux_v3_cfg_t const usdhc1_pads[] = { - MX6_PAD_SD1_CLK__USDHC1_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL), - MX6_PAD_SD1_CMD__USDHC1_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL), - MX6_PAD_SD1_DATA0__USDHC1_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL), - MX6_PAD_SD1_DATA1__USDHC1_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL), - MX6_PAD_SD1_DATA2__USDHC1_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL), - MX6_PAD_SD1_DATA3__USDHC1_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL), - MX6_PAD_NAND_READY_B__USDHC1_DATA4 | MUX_PAD_CTRL(USDHC_PAD_CTRL), - MX6_PAD_NAND_CE0_B__USDHC1_DATA5 | MUX_PAD_CTRL(USDHC_PAD_CTRL), - MX6_PAD_NAND_CE1_B__USDHC1_DATA6 | MUX_PAD_CTRL(USDHC_PAD_CTRL), - MX6_PAD_NAND_CLE__USDHC1_DATA7 | MUX_PAD_CTRL(USDHC_PAD_CTRL), -}; - static struct mx6ul_iomux_grp_regs mx6_grp_ioregs = { .grp_addds = 0x00000030, .grp_ddrmode_ctl = 0x00020000, @@ -240,13 +208,6 @@ static struct mx6_ddr3_cfg mem_ddr = { .trasmin = 3750, }; -int board_mmc_init(bd_t *bis) -{ - imx_iomux_v3_setup_multiple_pads(usdhc1_pads, ARRAY_SIZE(usdhc1_pads)); - usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK); - return fsl_esdhc_initialize(bis, &usdhc_cfg[0]); -} - static void ccgr_init(void) { struct mxc_ccm_reg *ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; @@ -282,6 +243,11 @@ static void spl_dram_init(void) mx6_dram_cfg(&ddr_sysinfo, &mx6_mmcd_calib, &mem_ddr); } +void spl_board_init(void) +{ + preloader_console_init(); +} + void board_init_f(ulong dummy) { ccgr_init(); @@ -292,10 +258,6 @@ void board_init_f(ulong dummy) /* setup GP timer */ timer_init(); - /* UART clocks enabled and gd valid - init serial console */ - opos6ul_setup_uart_debug(); - preloader_console_init(); - /* DDR initialization */ spl_dram_init(); } diff --git a/board/armadeus/opos6uldev/board.c b/board/armadeus/opos6uldev/board.c index 646094a..a830dc3 100644 --- a/board/armadeus/opos6uldev/board.c +++ b/board/armadeus/opos6uldev/board.c @@ -1,12 +1,11 @@ /* - * Copyright (C) 2017 Armadeus Systems + * Copyright (C) 2018 Armadeus Systems * * SPDX-License-Identifier: GPL-2.0+ */ #include #include -#include #include #include #include @@ -106,20 +105,3 @@ int opos6ul_board_late_init(void) return 0; } - -#ifdef CONFIG_SPL_BUILD -#define UART_PAD_CTRL ( \ - PAD_CTL_HYS | PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \ - PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST \ -) - -static iomux_v3_cfg_t const uart1_pads[] = { - MX6_PAD_UART1_TX_DATA__UART1_DCE_TX | MUX_PAD_CTRL(UART_PAD_CTRL), - MX6_PAD_UART1_RX_DATA__UART1_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL), -}; - -void opos6ul_setup_uart_debug(void) -{ - imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads)); -} -#endif /* CONFIG_SPL_BUILD */ diff --git a/configs/opos6uldev_defconfig b/configs/opos6uldev_defconfig index a2735bc..2fd684a 100644 --- a/configs/opos6uldev_defconfig +++ b/configs/opos6uldev_defconfig @@ -1,8 +1,10 @@ CONFIG_ARM=y CONFIG_ARCH_MX6=y CONFIG_SYS_TEXT_BASE=0x87800000 +CONFIG_SPL_GPIO_SUPPORT=y CONFIG_SPL_LIBCOMMON_SUPPORT=y CONFIG_SPL_LIBGENERIC_SUPPORT=y +CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_TARGET_OPOS6ULDEV=y CONFIG_SPL_MMC_SUPPORT=y CONFIG_SPL_SERIAL_SUPPORT=y @@ -11,6 +13,8 @@ CONFIG_SPL_WATCHDOG_SUPPORT=y CONFIG_SPL=y # CONFIG_CMD_BMODE is not set CONFIG_DEFAULT_DEVICE_TREE="imx6ul-opos6uldev" +CONFIG_SPL_SYS_MALLOC_F_LEN=0x400 +CONFIG_TPL_SYS_MALLOC_F_LEN=0x400 CONFIG_BOOTDELAY=5 CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="console=ttymxc0,115200" @@ -19,6 +23,7 @@ CONFIG_SYS_CONSOLE_IS_IN_ENV=y CONFIG_SUPPORT_RAW_INITRD=y CONFIG_DEFAULT_FDT_FILE="imx6ul-opos6uldev.dtb" CONFIG_VERSION_VARIABLE=y +CONFIG_SPL_BOARD_INIT=y CONFIG_SPL_ENV_SUPPORT=y CONFIG_SPL_YMODEM_SUPPORT=y CONFIG_HUSH_PARSER=y diff --git a/include/configs/opos6uldev.h b/include/configs/opos6uldev.h index 24e1f80..9e853f3 100644 --- a/include/configs/opos6uldev.h +++ b/include/configs/opos6uldev.h @@ -15,11 +15,7 @@ #include "imx6_spl.h" #ifdef CONFIG_SPL_BUILD -#undef CONFIG_DM_GPIO -#undef CONFIG_DM_MMC -#undef CONFIG_BLK - -#define CONFIG_MXC_UART_BASE UART1_BASE +#undef CONFIG_DM_REGULATOR #endif #endif @@ -40,7 +36,6 @@ (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET) /* MMC */ -#define CONFIG_SYS_FSL_ESDHC_ADDR 0 #define CONFIG_SUPPORT_EMMC_BOOT /* USB */ @@ -61,6 +56,7 @@ #endif /* LCD */ +#ifndef CONFIG_SPL_BUILD #ifdef CONFIG_VIDEO #define CONFIG_VIDEO_LOGO #define CONFIG_SPLASH_SCREEN @@ -72,6 +68,7 @@ #define CONFIG_VIDEO_MXS #define MXS_LCDIF_BASE MX6UL_LCDIF1_BASE_ADDR #endif +#endif /* Environment is stored in the eMMC boot partition */ #define CONFIG_SYS_MMC_ENV_DEV 0 From ea772178281fa7442e221ac26c291366090c888f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Szymanski?= Date: Tue, 17 Apr 2018 17:29:32 +0200 Subject: [PATCH 29/34] imx6ul: opos6ul: in Serial Downloader boot mode use ymodem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When booting in Serial Downloader mode load the U-Boot image using ymodem. Signed-off-by: Sébastien Szymanski --- arch/arm/mach-imx/mx6/opos6ul.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm/mach-imx/mx6/opos6ul.c b/arch/arm/mach-imx/mx6/opos6ul.c index ef70a7d..5d39c0b 100644 --- a/arch/arm/mach-imx/mx6/opos6ul.c +++ b/arch/arm/mach-imx/mx6/opos6ul.c @@ -208,6 +208,16 @@ static struct mx6_ddr3_cfg mem_ddr = { .trasmin = 3750, }; +void board_boot_order(u32 *spl_boot_list) +{ + unsigned int bmode = readl(&src_base->sbmr2); + + if (((bmode >> 24) & 0x03) == 0x01) /* Serial Downloader */ + spl_boot_list[0] = BOOT_DEVICE_UART; + else + spl_boot_list[0] = spl_boot_device(); +} + static void ccgr_init(void) { struct mxc_ccm_reg *ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; From 9482aeda660cece398cd85938184f727d1404611 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 21 Apr 2018 16:11:06 +0100 Subject: [PATCH 30/34] ARM: mxs: make lowlevel_init() weak With the full SPL framework enabled, lowlevel_init() is required. Make the empty stub weak so boards can override it. Signed-off-by: Mans Rullgard --- arch/arm/cpu/arm926ejs/mxs/mxs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/cpu/arm926ejs/mxs/mxs.c b/arch/arm/cpu/arm926ejs/mxs/mxs.c index 7a68a8f..5c78170 100644 --- a/arch/arm/cpu/arm926ejs/mxs/mxs.c +++ b/arch/arm/cpu/arm926ejs/mxs/mxs.c @@ -24,7 +24,7 @@ DECLARE_GLOBAL_DATA_PTR; /* Lowlevel init isn't used on i.MX28, so just have a dummy here */ -void lowlevel_init(void) {} +__weak void lowlevel_init(void) {} void reset_cpu(ulong ignored) __attribute__((noreturn)); From da372af6e40d84e8a47baa41d22dd3e953469b74 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 21 Apr 2018 16:11:07 +0100 Subject: [PATCH 31/34] ARM: arm926ejs: fix lowlevel_init call The code attempts to preserve the value of LR by storing it in R12/IP across the lowevel_init() call. However, this register is not saved by the callee. Use a register that guaranteed to be preserved instead. Signed-off-by: Mans Rullgard --- arch/arm/cpu/arm926ejs/start.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/cpu/arm926ejs/start.S b/arch/arm/cpu/arm926ejs/start.S index 959d1ed..a6f0bdb 100644 --- a/arch/arm/cpu/arm926ejs/start.S +++ b/arch/arm/cpu/arm926ejs/start.S @@ -105,9 +105,9 @@ flush_dcache: /* * Go setup Memory and board specific bits prior to relocation. */ - mov ip, lr /* perserve link reg across call */ + mov r4, lr /* perserve link reg across call */ bl lowlevel_init /* go setup pll,mux,memory */ - mov lr, ip /* restore link */ + mov lr, r4 /* restore link */ #endif mov pc, lr /* back to my caller */ #endif /* CONFIG_SKIP_LOWLEVEL_INIT */ From 68f835557c3f2e5ad24b9cb1a11d85fc8fca6f1e Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 21 Apr 2018 16:11:08 +0100 Subject: [PATCH 32/34] ARM: spl: include arm/thumb glue sections When building in Thumb mode, the linker might generate mode switching stubs in .glue sections. Include these in the final link. Signed-off-by: Mans Rullgard --- arch/arm/cpu/u-boot-spl.lds | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/cpu/u-boot-spl.lds b/arch/arm/cpu/u-boot-spl.lds index 65f7b68..38fc9b4 100644 --- a/arch/arm/cpu/u-boot-spl.lds +++ b/arch/arm/cpu/u-boot-spl.lds @@ -21,6 +21,7 @@ SECTIONS *(.vectors) CPUDIR/start.o (.text*) *(.text*) + *(.glue*) } . = ALIGN(4); From 33ea119382d820294e22bc99c4ea32cb5fac1a71 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 21 Apr 2018 16:11:09 +0100 Subject: [PATCH 33/34] ARM: mxs: move spl data With full SPL enabled, the loaded image overwrites the mxs_spl_data location. Moving it a slightly lower address fixes this. Signed-off-by: Mans Rullgard --- arch/arm/cpu/arm926ejs/mxs/mxs.c | 6 ++---- arch/arm/cpu/arm926ejs/mxs/spl_boot.c | 3 +-- arch/arm/include/asm/arch-mxs/sys_proto.h | 2 ++ 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/arch/arm/cpu/arm926ejs/mxs/mxs.c b/arch/arm/cpu/arm926ejs/mxs/mxs.c index 5c78170..09b5c04 100644 --- a/arch/arm/cpu/arm926ejs/mxs/mxs.c +++ b/arch/arm/cpu/arm926ejs/mxs/mxs.c @@ -178,8 +178,7 @@ const char *get_imx_type(u32 imxtype) int print_cpuinfo(void) { u32 cpurev; - struct mxs_spl_data *data = (struct mxs_spl_data *) - ((CONFIG_SYS_TEXT_BASE - sizeof(struct mxs_spl_data)) & ~0xf); + struct mxs_spl_data *data = MXS_SPL_DATA; cpurev = get_cpu_rev(); printf("CPU: Freescale i.MX%s rev%d.%d at %d MHz\n", @@ -277,8 +276,7 @@ void imx_get_mac_from_fuse(int dev_id, unsigned char *mac) int mxs_dram_init(void) { - struct mxs_spl_data *data = (struct mxs_spl_data *) - ((CONFIG_SYS_TEXT_BASE - sizeof(struct mxs_spl_data)) & ~0xf); + struct mxs_spl_data *data = MXS_SPL_DATA; if (data->mem_dram_size == 0) { printf("MXS:\n" diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_boot.c b/arch/arm/cpu/arm926ejs/mxs/spl_boot.c index d9d1d73..0c39256 100644 --- a/arch/arm/cpu/arm926ejs/mxs/spl_boot.c +++ b/arch/arm/cpu/arm926ejs/mxs/spl_boot.c @@ -120,8 +120,7 @@ void mxs_common_spl_init(const uint32_t arg, const uint32_t *resptr, const iomux_cfg_t *iomux_setup, const unsigned int iomux_size) { - struct mxs_spl_data *data = (struct mxs_spl_data *) - ((CONFIG_SYS_TEXT_BASE - sizeof(struct mxs_spl_data)) & ~0xf); + struct mxs_spl_data *data = MXS_SPL_DATA; uint8_t bootmode = mxs_get_bootmode_index(); gd = &gdata; diff --git a/arch/arm/include/asm/arch-mxs/sys_proto.h b/arch/arm/include/asm/arch-mxs/sys_proto.h index 6096763..b23ee6d 100644 --- a/arch/arm/include/asm/arch-mxs/sys_proto.h +++ b/arch/arm/include/asm/arch-mxs/sys_proto.h @@ -85,6 +85,8 @@ static const struct mxs_pair mxs_boot_modes[] = { #define MXS_BM_SDMMC1_3V3 0x0a #define MXS_BM_SDMMC1_1V8 0x1a +#define MXS_SPL_DATA ((struct mxs_spl_data *)(CONFIG_SYS_TEXT_BASE - 0x200)) + struct mxs_spl_data { uint8_t boot_mode_idx; uint32_t mem_dram_size; From 07a8f79ee850b1e59371519f179d32fea171bbec Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 21 Apr 2018 16:11:10 +0100 Subject: [PATCH 34/34] ARM: mxs: support full SPL framework This allows using the full SPL framework on mxs devices. In this mode, the u-boot.sb image loaded by the boot ROM contains only the SPL which then loads U-Boot proper or a kernel in falcon mode. Signed-off-by: Mans Rullgard --- arch/arm/Kconfig | 2 +- arch/arm/cpu/arm926ejs/mxs/Makefile | 4 ++-- arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx23.cfg | 5 +++++ arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx28.cfg | 6 ++++++ arch/arm/cpu/arm926ejs/mxs/spl_boot.c | 2 ++ include/configs/mxs.h | 2 ++ 6 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx23.cfg create mode 100644 arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx28.cfg diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 7212fc5..0acdd16 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1352,7 +1352,7 @@ source "arch/arm/Kconfig.debug" endmenu config SPL_LDSCRIPT - default "arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds" if ARCH_MX23 || ARCH_MX28 + default "arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds" if (ARCH_MX23 || ARCH_MX28) && !SPL_FRAMEWORK default "arch/arm/cpu/arm1136/u-boot-spl.lds" if CPU_ARM1136 default "arch/arm/cpu/armv8/u-boot-spl.lds" if ARM64 diff --git a/arch/arm/cpu/arm926ejs/mxs/Makefile b/arch/arm/cpu/arm926ejs/mxs/Makefile index 71c2c0e..83b05ac 100644 --- a/arch/arm/cpu/arm926ejs/mxs/Makefile +++ b/arch/arm/cpu/arm926ejs/mxs/Makefile @@ -14,8 +14,8 @@ obj-y += spl_boot.o spl_lradc_init.o spl_mem_init.o spl_power_init.o endif # Specify the target for use in elftosb call -MKIMAGE_TARGET-$(CONFIG_MX23) = mxsimage.mx23.cfg -MKIMAGE_TARGET-$(CONFIG_MX28) = mxsimage.mx28.cfg +MKIMAGE_TARGET-$(CONFIG_MX23) = mxsimage$(CONFIG_SPL_FRAMEWORK:%=-spl).mx23.cfg +MKIMAGE_TARGET-$(CONFIG_MX28) = mxsimage$(CONFIG_SPL_FRAMEWORK:%=-spl).mx28.cfg # Generate HAB-capable IVT # diff --git a/arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx23.cfg b/arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx23.cfg new file mode 100644 index 0000000..ab2183e --- /dev/null +++ b/arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx23.cfg @@ -0,0 +1,5 @@ +DISPLAYPROGRESS +SECTION 0x0 BOOTABLE + TAG LAST + LOAD 0x1000 spl/u-boot-spl.bin + CALL 0x1000 0x0 diff --git a/arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx28.cfg b/arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx28.cfg new file mode 100644 index 0000000..0d95064 --- /dev/null +++ b/arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx28.cfg @@ -0,0 +1,6 @@ +DISPLAYPROGRESS +SECTION 0x0 BOOTABLE + TAG LAST + LOAD 0x1000 spl/u-boot-spl.bin + LOAD IVT 0x8000 0x1000 + CALL HAB 0x8000 0x0 diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_boot.c b/arch/arm/cpu/arm926ejs/mxs/spl_boot.c index 0c39256..bc39465 100644 --- a/arch/arm/cpu/arm926ejs/mxs/spl_boot.c +++ b/arch/arm/cpu/arm926ejs/mxs/spl_boot.c @@ -146,6 +146,7 @@ void mxs_common_spl_init(const uint32_t arg, const uint32_t *resptr, } } +#ifndef CONFIG_SPL_FRAMEWORK /* Support aparatus */ inline void board_init_f(unsigned long bootflag) { @@ -158,3 +159,4 @@ inline void board_init_r(gd_t *id, ulong dest_addr) for (;;) ; } +#endif diff --git a/include/configs/mxs.h b/include/configs/mxs.h index f07f81c..0fe0770 100644 --- a/include/configs/mxs.h +++ b/include/configs/mxs.h @@ -44,8 +44,10 @@ /* Startup hooks */ /* SPL */ +#ifndef CONFIG_SPL_FRAMEWORK #define CONFIG_SPL_NO_CPU_SUPPORT_CODE #define CONFIG_SPL_START_S_PATH "arch/arm/cpu/arm926ejs/mxs" +#endif /* Memory sizes */ #define CONFIG_SYS_MALLOC_LEN 0x00400000 /* 4 MB for malloc */