summaryrefslogtreecommitdiffstats
path: root/defaultenv/bin/boot
blob: ba0437304950b384d51ad91779aac055589e5aeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/sh

. /env/config

if [ x$kernel_loc = xnet ]; then
	kernel_loc=tftp
fi

while getopt "hk:r:i:m:" Option
do
if [ ${Option} = k ]; then
	kernel_loc=${OPTARG}
elif [ ${Option} = r ]; then
	rootfs_loc=${OPTARG}
elif [ ${Option} = i ]; then
	ip=${OPTARG}
elif [ ${Option} = m ]; then
	mode=${OPTARG}
else
	. /env/bin/_boot_help
	exit 0
fi
done

if [ x$mode = xnand ]; then
	rootfs_loc=nand
	kernel_loc=nand
elif [ x$mode = xnor ]; then
	rootfs_loc=nor
	kernel_loc=nor
elif [ x$mode = xnfs ]; then
	rootfs_loc=net
	kernel_loc=nfs
elif [ x$mode = xtftp ]; then
	rootfs_loc=net
	kernel_loc=tftp
elif [ x$mode = xdisk ]; then
	rootfs_loc=disk
	kernel_loc=disk
fi

if [ x$ip = xdhcp -o x$ip = "xdhcp-barebox" ]; then
	if [ x$kernel_loc = xnfs -o x$kernel_loc = xtftp ]; then
		dhcp
		if [ x$rootpath != x ]; then
			nfsroot=$rootpath
		fi
		if [ x$bootfile != x ]; then
			kernelimage=$bootfile
		fi
	fi
fi

if [ x$ip = xdhcp -o ]; then
	bootargs="$bootargs ip=dhcp"
elif [ x$ip = xnone ]; then
	bootargs="$bootargs ip=none"
else
	bootargs="$bootargs ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask::eth0:"
fi


if [ x$rootfs_loc = xnet ]; then
	bootargs="$bootargs root=/dev/nfs nfsroot=$nfsroot,v3,tcp noinitrd"
elif [ x$rootfs_loc = xdisk ]; then
	bootargs="$bootargs root=/dev/$rootfs_part_linux_dev rootfstype=$rootfs_type noinitrd rootwait"
elif [ x$rootfs_loc = xinitrd ]; then
	bootargs="$bootargs root=/dev/ram0 rdinit=/sbin/init"
else
	if [ x$rootfs_loc = xnand ]; then
		rootfs_mtdblock=$rootfs_mtdblock_nand
	else
		rootfs_mtdblock=$rootfs_mtdblock_nor
	fi

	if [ x$rootfs_type = xubifs ]; then
		if [ -z $ubiroot ]; then
			ubiroot="root"
		fi
		bootargs="$bootargs root=ubi0:$ubiroot ubi.mtd=$rootfs_mtdblock"
	else
		bootargs="$bootargs root=/dev/mtdblock$rootfs_mtdblock"
	fi

	bootargs="$bootargs rootfstype=$rootfs_type noinitrd"
fi

if [ -n $nor_parts ]; then
	mtdparts="${mtdparts}physmap-flash.0:${nor_parts}"
fi

if [ -n $nand_parts ]; then
	if [ -n ${mtdparts} ]; then
		mtdparts="${mtdparts};"
	fi
	mtdparts="${mtdparts}${nand_device}:${nand_parts}"
fi

if [ -n $mtdparts ]; then
	bootargs="${bootargs} mtdparts=${mtdparts}"
fi

if [ x$kernel_loc = xnfs -o x$kernel_loc = xtftp ]; then
	kdev=/image
	$kernel_loc $kernelimage $kdev || exit 1
elif [ x$kernel_loc = xnor ]; then
	kdev="/dev/nor0.kernel"
elif [ x$kernel_loc = xnand ]; then
	kdev="/dev/nand0.kernel.bb"
elif [ x$kernel_loc = xdisk ]; then
	kdev="/dev/$kernel_part"
else
	echo "error: set kernel_loc to one of 'tftp', 'nfs', 'nand', 'nor' or 'disk'"
	exit 1
fi

echo "booting kernel from $kdev"

bootm $bootm_opt $kdev