-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathboot.scr.txt
78 lines (68 loc) · 2 KB
/
boot.scr.txt
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
boot_scr_filesize=${filesize}
# constant values
setenv mender_boot_part_A 3
setenv mender_boot_part_hex_A 3
setenv mender_boot_part_B 4
setenv mender_boot_part_hex_B 4
setenv bootlimit 1
# initialize and store variables on first boot
if test "${edi_first_boot_done}" != "true"
then
echo "Going to write environment on first boot!"
setenv bootcount 0
setenv upgrade_available 0
setenv mender_boot_part ${mender_boot_part_A}
setenv mender_boot_part_hex ${mender_boot_part_hex_A}
setenv edi_first_boot_done true
saveenv
fi
if test ${upgrade_available} = 1
then
# mender will reset bootcount within EnableUpdatedPartition
setexpr bootcount ${bootcount} + 1
saveenv
else
setenv bootcount 0
fi
if test ${bootcount} -gt ${bootlimit}
then
echo "Switching back to previous setup due to hitting bootlimit!"
if test ${mender_boot_part} = ${mender_boot_part_A}
then
setenv mender_boot_part ${mender_boot_part_B}
setenv mender_boot_part_hex ${mender_boot_part_hex_B}
else
setenv mender_boot_part ${mender_boot_part_A}
setenv mender_boot_part_hex ${mender_boot_part_hex_A}
fi
setenv upgrade_available 0
saveenv
fi
setexpr secondary_scriptaddr ${loadaddr}
setenv edi_mmc_device ${dev}:${mender_boot_part_hex}
if test "${iface}" = "usb"
then
setenv edi_boot_device /dev/sda1
setenv edi_data_device /dev/sda2
setenv edi_root_device /dev/sda${mender_boot_part}
else
setenv edi_boot_device /dev/mmcblk2p1
setenv edi_data_device /dev/mmcblk2p2
setenv edi_root_device /dev/mmcblk2p${mender_boot_part}
fi
if ext4load ${iface} ${edi_mmc_device} ${secondary_scriptaddr} /boot/boot.scr
then
echo "Successfully loaded secondary boot script."
else
echo "Trying to reset an environment setup that does not match the current installation!"
setenv edi_first_boot_done false
saveenv
# avoid busy reboot loop
sleep 60
reset
fi
source ${secondary_scriptaddr}
if test ${upgrade_available} = 1
then
reset
fi