[U-Boot] [PATCH][v2] board/lx2160ardb: Add distro boot support

Priyanka Jain priyanka.jain at nxp.com
Thu Nov 29 09:00:37 UTC 2018


Add u-boot enviroments to support distro boot which scan
boot.scr from external storage devices
(e.g. SD/USB/SATA/SCSI disk) and execute autoboot script.

Signed-off-by: Priyanka Jain <priyanka.jain at nxp.com>
---
Depends on https://patchwork.ozlabs.org/patch/990094/
Changes for v2:
 xspi_bootcmd, sd_bootcmd env variables are
 dependent on board. So, move the definition
 from lx2160a_common.h file to lx2160ardb.h file

 configs/lx2160ardb_tfa_defconfig |  3 +-
 include/configs/lx2160a_common.h | 84 +++++++++++++++++++++++++++++++++++-----
 include/configs/lx2160ardb.h     | 29 +++++++-------
 3 files changed, 90 insertions(+), 26 deletions(-)

diff --git a/configs/lx2160ardb_tfa_defconfig b/configs/lx2160ardb_tfa_defconfig
index 64cc31d..86fdcfc 100644
--- a/configs/lx2160ardb_tfa_defconfig
+++ b/configs/lx2160ardb_tfa_defconfig
@@ -6,7 +6,6 @@ CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT=y
 CONFIG_DEFAULT_DEVICE_TREE="fsl-lx2160a-rdb"
 CONFIG_NR_DRAM_BANKS=3
 CONFIG_DM=y
-CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_STDOUT_VIA_ALIAS=y
@@ -14,7 +13,7 @@ CONFIG_TFABOOT=y
 CONFIG_BOOTDELAY=10
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyAMA0,115200 root=/dev/ram0 earlycon=pl011,mmio32,0x21c0000 ramdisk_size=0x2000000 default_hugepagesz=1024m hugepagesz=1024m hugepages=2 pci=pcie_bus_perf"
-# CONFIG_CMD_IMLS is not set
+# CONFIG_USE_BOOTCOMMAND is not set
 CONFIG_CMD_GREPENV=y
 CONFIG_CMD_EEPROM=y
 CONFIG_CMD_GPT=y
diff --git a/include/configs/lx2160a_common.h b/include/configs/lx2160a_common.h
index 19053b43a1..5b4fabe 100644
--- a/include/configs/lx2160a_common.h
+++ b/include/configs/lx2160a_common.h
@@ -194,16 +194,6 @@ unsigned long get_board_ddr_clk(void);
 #define CONFIG_SYS_BOOTM_LEN   (64 << 20)      /* Increase max gunzip size */
 
 /* Initial environment variables */
-#define XSPI_NOR_BOOTCOMMAND	"fsl_mc apply dpl 0x20d00000;" \
-				"sf probe 0:0;" \
-				"sf read 0xa0000000 0x1000000 0x3000000;" \
-				"bootm 0xa0000000"
-
-#define SD_BOOTCOMMAND		"mmc read 0xa0000000 0x6800 0xA0;" \
-				"fsl_mc apply dpl 0xa0000000;" \
-				"mmc read 0xb0000000 0x8000 0x1d000;" \
-				"bootm 0xb0000000"
-
 #define XSPI_MC_INIT_CMD			\
 	"fsl_mc start mc 0x20a00000 0x20e00000\0"
 
@@ -212,4 +202,78 @@ unsigned long get_board_ddr_clk(void);
 	"mmc read 0x80100000 0x7000 0x800;"	\
 	"fsl_mc start mc 0x80000000 0x80100000\0"
 
+#define EXTRA_ENV_SETTINGS			\
+	"hwconfig=fsl_ddr:bank_intlv=auto\0"	\
+	"ramdisk_addr=0x800000\0"		\
+	"ramdisk_size=0x2000000\0"		\
+	"fdt_high=0xa0000000\0"			\
+	"initrd_high=0xffffffffffffffff\0"	\
+	"fdt_addr=0x64f00000\0"			\
+	"kernel_start=0x1000000\0"		\
+	"kernelheader_start=0x800000\0"		\
+	"scriptaddr=0x80000000\0"		\
+	"scripthdraddr=0x80080000\0"		\
+	"fdtheader_addr_r=0x80100000\0"		\
+	"kernelheader_addr_r=0x80200000\0"	\
+	"kernel_addr_r=0x81000000\0"		\
+	"kernelheader_size=0x40000\0"		\
+	"fdt_addr_r=0x90000000\0"		\
+	"load_addr=0xa0000000\0"		\
+	"kernel_size=0x2800000\0"		\
+	"kernel_addr_sd=0x8000\0"		\
+	"kernel_size_sd=0x1d000\0"              \
+	"console=ttyAMA0,38400n8\0"		\
+	BOOTENV					\
+	"mcmemsize=0x70000000\0"		\
+	XSPI_MC_INIT_CMD				\
+	"boot_scripts=lx2160ardb_boot.scr\0"	\
+	"boot_script_hdr=hdr_lx2160ardb_bs.out\0"	\
+	"scan_dev_for_boot_part="		\
+		"part list ${devtype} ${devnum} devplist; "	\
+		"env exists devplist || setenv devplist 1; "	\
+		"for distro_bootpart in ${devplist}; do "	\
+			"if fstype ${devtype} "			\
+				"${devnum}:${distro_bootpart} "	\
+				"bootfstype; then "		\
+				"run scan_dev_for_boot; "	\
+			"fi; "					\
+		"done\0"					\
+	"scan_dev_for_boot="					\
+		"echo Scanning ${devtype} "			\
+			"${devnum}:${distro_bootpart}...; "	\
+		"for prefix in ${boot_prefixes}; do "		\
+			"run scan_dev_for_scripts; "		\
+		"done;\0"					\
+	"boot_a_script="					\
+		"load ${devtype} ${devnum}:${distro_bootpart} "	\
+			"${scriptaddr} ${prefix}${script}; "	\
+		"env exists secureboot && load ${devtype} "	\
+			"${devnum}:${distro_bootpart} "		\
+			"${scripthdraddr} ${prefix}${boot_script_hdr} "	\
+			"&& esbc_validate ${scripthdraddr};"	\
+		"source ${scriptaddr}\0"
+
+#define XSPI_NOR_BOOTCOMMAND						\
+			"env exists mcinitcmd && env exists secureboot "\
+			"&& esbc_validate 0x20780000; "			\
+			"env exists mcinitcmd && "			\
+			"fsl_mc lazyapply dpl 0x20d00000; "		\
+			"run distro_bootcmd;run xspi_bootcmd; "		\
+			"env exists secureboot && esbc_halt;"
+
+#define SD_BOOTCOMMAND						\
+		"env exists mcinitcmd && mmcinfo; "		\
+		"mmc read 0x80001000 0x6800 0x800; "		\
+		"env exists mcinitcmd && env exists secureboot "	\
+		" && mmc read 0x80780000 0x3C00 0x10 "		\
+		"&& esbc_validate 0x80780000;env exists mcinitcmd "	\
+		"&& fsl_mc lazyapply dpl 0x80001000;"		\
+		"run distro_bootcmd;run sd_bootcmd;"		\
+		"env exists secureboot && esbc_halt;"
+
+#define BOOT_TARGET_DEVICES(func) \
+	func(MMC, mmc, 0) \
+	func(SCSI, scsi, 0)
+#include <config_distro_bootcmd.h>
+
 #endif /* __LX2_COMMON_H */
diff --git a/include/configs/lx2160ardb.h b/include/configs/lx2160ardb.h
index 67d214d..8c91fea 100644
--- a/include/configs/lx2160ardb.h
+++ b/include/configs/lx2160ardb.h
@@ -81,21 +81,22 @@
 
 /* Initial environment variables */
 #define CONFIG_EXTRA_ENV_SETTINGS		\
-	"hwconfig=fsl_ddr:bank_intlv=auto\0"	\
-	"scriptaddr=0x80800000\0"		\
-	"kernel_addr_r=0x81000000\0"		\
-	"pxefile_addr_r=0x81000000\0"		\
-	"fdt_addr_r=0x88000000\0"		\
-	"ramdisk_addr_r=0x89000000\0"		\
-	"loadaddr=0x80100000\0"			\
-	"kernel_addr=0x100000\0"		\
-	"ramdisk_addr=0x800000\0"		\
-	"ramdisk_size=0x2000000\0"		\
-	"fdt_high=0xa0000000\0"			\
-	"initrd_high=0xffffffffffffffff\0"	\
-	"kernel_start=0x21000000\0"		\
+	EXTRA_ENV_SETTINGS			\
 	"lx2160ardb_vdd_mv=800\0"		\
-	"mcmemsize=0x40000000\0"
+	"BOARD=lx2160ardb\0"			\
+	"xspi_bootcmd=echo Trying load from flexspi..;"		\
+		"sf probe 0:0 && sf read $load_addr "		\
+		"$kernel_start $kernel_size ; env exists secureboot &&"	\
+		"sf read $kernelheader_addr_r $kernelheader_start "	\
+		"$kernelheader_size && esbc_validate ${kernelheader_addr_r}; "\
+		" bootm $load_addr#$BOARD\0"			\
+	"sd_bootcmd=echo Trying load from sd card..;"		\
+		"mmcinfo; mmc read $load_addr "			\
+		"$kernel_addr_sd $kernel_size_sd ;"		\
+		"env exists secureboot && mmc read $kernelheader_addr_r "\
+		"$kernelhdr_addr_sd $kernelhdr_size_sd "	\
+		" && esbc_validate ${kernelheader_addr_r};"	\
+		"bootm $load_addr#$BOARD\0"
 
 #include <asm/fsl_secure_boot.h>
 
-- 
2.7.4



More information about the U-Boot mailing list