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 miscadj "
27if test '${boardsoc}' = 'imx53'; then
28       setenv bootargs '${bootargs} di=${dig_in} key1=${key1}';
29fi;"
30setenv boot_fitImage "
31	setenv fdt_conf 'conf@${boardsoc}-${boardname}.dtb';
32	setenv itbcfg "\"#\${fdt_conf}\"";
33	print itbcfg;
34	bootm '${loadaddr}${itbcfg}';"
35
36#------------------------------------------------------------
37#
38# Provide default 'bootcmd' command
39#------------------------------------------------------------
40setenv bootcmd "
41if test -e ${devtype} ${devnum}:${distro_bootpart} ${kernel_file}; then
42	echo Found kernel image: ${kernel_file};
43	if load ${devtype} ${devnum}:${distro_bootpart} ${loadaddr} \
44	   ${kernel_file}; then
45		run mmcargs;
46		run miscadj;
47		run boot_fitImage;
48	fi;
49fi;"
50
51#------------------------------------------------------------
52#
53# Provide 'boot_tftp_kernel' command
54#------------------------------------------------------------
55setenv download_kernel "tftpboot ${loadaddr} ${kernel_file}"
56
57setenv boot_tftp_kernel "
58if run download_kernel; then
59	run mmcargs;
60	run miscadj;
61	run boot_fitImage;
62fi"
63
64#------------------------------------------------------------
65#
66# Provide 'boot_nfs' command
67#------------------------------------------------------------
68setenv rootpath "/srv/tftp/KP/rootfs"
69setenv nfsargs "setenv bootargs root=/dev/nfs rw \
70       nfsroot=${serverip}:${rootpath},nolock,nfsvers=3"
71setenv addip "setenv bootargs ${bootargs} \
72       ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:\
73       ${hostname}:eth0:on"
74
75setenv boot_nfs "
76if run download_kernel; then
77	run nfsargs;
78	run addip;
79	setenv bootargs ${bootargs} console=${console};
80
81	run boot_fitImage;
82fi"
83
84#------------------------------------------------------------
85#
86# Set correct boot flow
87#------------------------------------------------------------
88
89setenv bcmd "
90if test ! -n ${bootcmd_force}; then
91	run bootcmd;
92fi;
93if test ${bootcmd_force} = nfs; then
94	run boot_nfs;
95else if test ${bootcmd_force} = tftp_kernel; then
96	run boot_tftp_kernel;
97     fi;
98fi"
99
100run bcmd
101