xref: /openbmc/u-boot/board/k+p/bootscripts/tpcboot.cmd (revision 699e831e158a5846778d8bd6af054d4276277cb6)
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
24setenv mmcroot "/dev/mmcblk${devnum}p2 rootwait rw"
25setenv displayargs ""
26setenv mmcargs "setenv bootargs console=${console} ${smp} root=${mmcroot} \
27	${displayargs}"
28setenv 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#------------------------------------------------------------
38setenv bootcmd "
39if 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;
46fi;"
47
48#------------------------------------------------------------
49#
50# Provide 'boot_tftp_kernel' command
51#------------------------------------------------------------
52setenv download_kernel "tftpboot ${loadaddr} ${kernel_file}"
53
54setenv boot_tftp_kernel "
55if run download_kernel; then
56	run mmcargs;
57	run boot_fitImage;
58fi"
59
60#------------------------------------------------------------
61#
62# Provide 'boot_nfs' command
63#------------------------------------------------------------
64setenv rootpath "/srv/tftp/KP/rootfs"
65setenv nfsargs "setenv bootargs root=/dev/nfs rw \
66       nfsroot=${serverip}:${rootpath},nolock,nfsvers=3"
67setenv addip "setenv bootargs ${bootargs} \
68       ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:\
69       ${hostname}:eth0:on"
70
71setenv boot_nfs "
72if run download_kernel; then
73	run nfsargs;
74	run addip;
75	setenv bootargs ${bootargs} console=${console};
76
77	run boot_fitImage;
78fi"
79
80#------------------------------------------------------------
81#
82# Set correct boot flow
83#------------------------------------------------------------
84
85setenv bcmd "
86if test ! -n ${bootcmd_force}; then
87	run bootcmd;
88fi;
89if test ${bootcmd_force} = nfs; then
90	run boot_nfs;
91else if test ${bootcmd_force} = tftp_kernel; then
92	run boot_tftp_kernel;
93     fi;
94fi"
95
96run bcmd
97