boot: script: The boot.scr file for K+P's boards
[oweals/u-boot.git] / board / k+p / bootscripts / tpcboot.cmd
1 #
2 # Copyright (C) 2018
3 # Lukasz Majewski, DENX Software Engineering, lukma@denx.de
4 #
5 #
6 # This is an example file to generate boot.scr - a boot script for U-Boot
7 # Generate boot.scr:
8 # ./tools/mkimage -c none -A arm -T script -d tpcboot.cmd boot.scr
9 #
10 # SPDX-License-Identifier:      GPL-2.0+
11
12
13 # Input envs (to be set in environment)
14 # Mandatory:
15 # kernel_file = "fitImage"
16 # boardname = "XXXX"  // set automatically in u-boot
17 # boardsoc = "imx6q"  // set automatically in u-boot
18 #
19 # Optional:
20 # bootcmd_force = "nfs" "tftp_kernel"
21 # If not set - eMMC/SD boot
22
23 # Generic setup
24 setenv mmcroot "/dev/mmcblk${devnum}p2 rootwait rw"
25 setenv displayargs ""
26 setenv mmcargs "setenv bootargs console=${console} ${smp} root=${mmcroot} \
27         ${displayargs}"
28 setenv boot_fitImage "
29         setenv fdt_conf 'conf@${boardsoc}-${boardname}.dtb';
30         setenv itbcfg "\"#\${fdt_conf}\"";
31         print itbcfg;
32         bootm '${loadaddr}${itbcfg}';"
33
34 #------------------------------------------------------------
35 #
36 # Provide default 'bootcmd' command
37 #------------------------------------------------------------
38 setenv bootcmd "
39 if test -e ${devtype} ${devnum}:${distro_bootpart} ${kernel_file}; then
40         echo Found kernel image: ${kernel_file};
41         if load ${devtype} ${devnum}:${distro_bootpart} ${loadaddr} \
42            ${kernel_file}; then
43                 run mmcargs;
44                 run boot_fitImage;
45         fi;
46 fi;"
47
48 #------------------------------------------------------------
49 #
50 # Provide 'boot_tftp_kernel' command
51 #------------------------------------------------------------
52 setenv download_kernel "tftpboot ${loadaddr} ${kernel_file}"
53
54 setenv boot_tftp_kernel "
55 if run download_kernel; then
56         run mmcargs;
57         run boot_fitImage;
58 fi"
59
60 #------------------------------------------------------------
61 #
62 # Provide 'boot_nfs' command
63 #------------------------------------------------------------
64 setenv rootpath "/srv/tftp/KP/rootfs"
65 setenv nfsargs "setenv bootargs root=/dev/nfs rw \
66        nfsroot=${serverip}:${rootpath},nolock,nfsvers=3"
67 setenv addip "setenv bootargs ${bootargs} \
68        ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:\
69        ${hostname}:eth0:on"
70
71 setenv boot_nfs "
72 if run download_kernel; then
73         run nfsargs;
74         run addip;
75         setenv bootargs ${bootargs} console=${console};
76
77         run boot_fitImage;
78 fi"
79
80 #------------------------------------------------------------
81 #
82 # Set correct boot flow
83 #------------------------------------------------------------
84
85 setenv bcmd "
86 if test ! -n ${bootcmd_force}; then
87         run bootcmd;
88 fi;
89 if test ${bootcmd_force} = nfs; then
90         run boot_nfs;
91 else if test ${bootcmd_force} = tftp_kernel; then
92         run boot_tftp_kernel;
93      fi;
94 fi"
95
96 run bcmd