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