/
boot.cmd.in
56 lines (49 loc) · 1.83 KB
/
boot.cmd.in
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
if test -e virtio 0:1 uboot.env; then env load; fi;
setenv fallback_bootargs ""
fdt addr ${fdt_addr} && fdt get value bootargs /chosen bootargs || setenv bootargs ${fallback_bootargs}
test -n "${BOOT_ORDER}" || setenv BOOT_ORDER "SDV_A SDV_B"
test -n "${BOOT_SDV_A_LEFT}" || setenv BOOT_SDV_A_LEFT 3
test -n "${BOOT_SDV_B_LEFT}" || setenv BOOT_SDV_B_LEFT 3
setenv bootpart
setenv raucslot
for BOOT_SLOT in "${BOOT_ORDER}"; do
if test "x${bootpart}" != "x"; then
# skip remaining slots
elif test "x${BOOT_SLOT}" = "xSDV_A"; then
if test ${BOOT_SDV_A_LEFT} -gt 0; then
setexpr BOOT_SDV_A_LEFT ${BOOT_SDV_A_LEFT} - 1
echo "Found valid RAUC slot SDV_A"
setenv bootpart "/dev/vda4"
setenv raucslot "SDV_A"
fi
elif test "x${BOOT_SLOT}" = "xSDV_B"; then
if test ${BOOT_SDV_B_LEFT} -gt 0; then
setexpr BOOT_SDV_B_LEFT ${BOOT_SDV_B_LEFT} - 1
echo "Found valid RAUC slot SDV_B"
setenv bootpart "/dev/vda5"
setenv raucslot "SDV_B"
fi
fi
done
# Use the automated slot counting as the default
setenv bootmenu_0 Autoboot=''
# Short-circuit automated bootargs if a menu entry is chosen
setenv bootmenu_1 Boot SDV Image Full='setenv bootpart "/dev/vda4" && setenv raucslot "SDV_A"'
setenv bootmenu_2 Boot SDV Image Minimal='setenv bootpart "/dev/vda5" && setenv raucslot "SDV_B"'
setenv bootmenu_3 Reset=reset
setenv bootmenu_4 Power Off=poweroff
bootmenu 3
if test -n "${bootpart}"; then
setenv bootargs "${bootargs} root=${bootpart} rauc.slot=${raucslot}"
echo "Booting with boot args: ${bootargs}"
saveenv
else
echo "No valid RAUC slot found. Resetting tries to 3"
setenv BOOT_SDV_A_LEFT 3
setenv BOOT_SDV_B_LEFT 3
saveenv
reset
fi
fatload virtio 0:1 ${kernel_addr_r} @@KERNEL_IMAGETYPE@@
if test ! -e virtio 0:1 uboot.env; then saveenv; fi;
@@KERNEL_BOOTCMD@@ ${kernel_addr_r} - ${fdt_addr}