aboutsummaryrefslogtreecommitdiff
path: root/boot-script/boot/boot.cmd
blob: b0e3478ca9edbdd0078821d2f909e10ebdc2339b (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
# to compile this script use:
# mkimage -C none -A arm -T script -d boot.cmd boot.scr

# fallback default values
load_addr=0x01000000
fdtfile=dtb
kernelfile=Image
initrdfile=uInitrd
rootdevice=/dev/mmcblk0p1
rootdevice_flags=rw
loglevel=7
os_type=linux

echo "Boot script running from ${devtype} ${devnum}"

if test ${board_name} = "puma_rk3399"; then
	if test ${devtype} = "mmc" && test ${devnum} -eq 0;then
		rootdevice=/dev/mmcblk1p1
		if test ! -n ${androidboot_mode}; then
			androidboot_mode=emmc
		fi
	elif test ${devtype} = "mmc" && test ${devnum} -eq 1;then
		rootdevice=/dev/mmcblk0p1 
		if test ! -n ${androidboot_mode}; then
			androidboot_mode=sd
		fi
	elif test ${devtype} = "usb"; then
		rootdevice=/dev/sda1
	else
		if test ! -n ${androidboot_mode}; then
			androidboot_mode=unknown
		fi
	fi
fi

if test ${board_name} = "lion_rk3368"; then
	if test ${devtype} = "mmc" && test ${devnum} -eq 0;then
		rootdevice=/dev/mmcblk1p1
	elif test ${devtype} = "mmc" && test ${devnum} -eq 1;then
		rootdevice=/dev/mmcblk0p1
	fi
fi

if load ${devtype} ${devnum} ${fdt_addr_r} /boot/${board_name}/defaultEnv.txt; then
	setenv load_path "/boot/${board_name}"
	echo "Import default environment from /boot/${board_name}/defaultEnv.txt"
	env import -t ${fdt_addr_r} ${filesize}
else 
	if load ${devtype} ${devnum} ${fdt_addr_r} /boot/defaultEnv.txt; then
		setenv load_path "/boot"
		echo "Import default environment from /boot/defaultEnv.txt"
		env import -t ${fdt_addr_r} ${filesize}
	fi
fi

if load ${devtype} ${devnum} ${load_addr} ${load_path}/userEnv.txt; then
	echo "Import default environment from ${load_path}/userEnv.txt"
	env import -t ${load_addr} ${filesize}
fi

if test -n ${userscript}; then 
	if load ${devtype} ${devnum} ${load_addr} ${load_path}/${userscript}; then
		echo "Running userscript from ${load_path}/${userscript}"
		source ${load_addr}
	fi
fi

if test ${os_type} = android; then
	setenv bootargs "rw rootwait androidboot.hardware=${board_name} androidboot.mode=${androidboot_mode} ${extraargs}"
else
	setenv bootargs "root=${rootdevice} ${rootdevice_flags} rootwait ${console} consoleblank=0 loglevel=${loglevel} ${extraargs}"
fi

if load ${devtype} ${devnum} ${fdt_addr_r} ${load_path}/${fdtfile}; then
	echo "Load devicetree from ${load_path}/${fdtfile}"
fi
fdt addr ${fdt_addr_r}
fdt resize

for overlay_file in ${overlays}; do
	if load ${devtype} ${devnum} ${load_addr} ${load_path}/overlays/${overlay_file}; then
		echo "Apply devicetree overlay ${load_path}/overlays/${overlay_file}"
		fdt apply ${load_addr}
	fi
done

load ${devtype} ${devnum} ${kernel_addr_r} ${load_path}/${kernelfile}

if load ${devtype} ${devnum} ${ramdisk_addr_r} ${load_path}/${initrdfile}; then
	booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
else
	echo "Start Kernel without initrd"
	booti ${kernel_addr_r} - ${fdt_addr_r}
fi