board/lx2160ardb: Add distro boot support
authorPriyanka Jain <priyanka.jain@nxp.com>
Thu, 24 Jan 2019 05:22:18 +0000 (05:22 +0000)
committerPrabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
Tue, 19 Feb 2019 04:56:44 +0000 (10:26 +0530)
Add u-boot enviroments to support distro boot which scan
boot.scr from external storage devices
(e.g. SD/USB/SCSI disk) and execute autoboot script

Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
Reviewed-by: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
configs/lx2160ardb_tfa_defconfig
include/configs/lx2160a_common.h
include/configs/lx2160ardb.h

index 80dd2c102290ec28d4f02c0694f149359c6eba8c..2dc49c7f5d145e5b4d6cb69930f9435faf98f17e 100644 (file)
@@ -14,6 +14,7 @@ CONFIG_OF_STDOUT_VIA_ALIAS=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_USE_BOOTCOMMAND is not set
 CONFIG_CMD_GREPENV=y
 CONFIG_CMD_EEPROM=y
 CONFIG_CMD_GPT=y
index 41931e5b5384d69a9fbf2e2a8f14ff5c1d7c4164..0e0e72d06baf2ad4c772f9023bad6ec876140399 100644 (file)
@@ -193,16 +193,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"
 
@@ -211,4 +201,79 @@ 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(USB, usb, 0) \
+       func(MMC, mmc, 0) \
+       func(SCSI, scsi, 0)
+#include <config_distro_bootcmd.h>
+
 #endif /* __LX2_COMMON_H */
index 818aa3856ef83d98a8b000a157b8ebd747f52cb6..972bb5e102bcbb2c26ef3c09dfd3c702ba4f67d5 100644 (file)
 
 /* 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>