-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfwup-ops.conf
More file actions
88 lines (78 loc) · 3.23 KB
/
fwup-ops.conf
File metadata and controls
88 lines (78 loc) · 3.23 KB
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
# -----------------------------------------------------------------
# Post-installation operations – SG2002
# -----------------------------------------------------------------
require-fwup-version = "1.0.0"
include("${NERVES_SDK_IMAGES:-.}/fwup_include/fwup-common.conf")
##
# factory-reset – erases the writable ext4 data partition
##
task factory-reset {
on-init {
info("Erasing application data partition")
trim(${APP_PART_OFFSET}, ${APP_PART_COUNT})
raw_memset(${APP_PART_OFFSET}, 256, 0xff)
}
}
##
# prevent-revert – delete the old slot so it can’t be rebooted
##
task prevent-revert.a {
require-uboot-variable(uboot-env, "nerves_fw_active", "b")
on-init {
uboot_unsetenv(uboot-env, "a.nerves_fw_platform")
uboot_unsetenv(uboot-env, "a.nerves_fw_architecture")
trim(${ROOTFS_A_PART_OFFSET}, ${ROOTFS_A_PART_COUNT})
}
}
task prevent-revert.b {
require-uboot-variable(uboot-env, "nerves_fw_active", "a")
on-init {
uboot_unsetenv(uboot-env, "b.nerves_fw_platform")
uboot_unsetenv(uboot-env, "b.nerves_fw_architecture")
trim(${ROOTFS_B_PART_OFFSET}, ${ROOTFS_B_PART_COUNT})
}
}
task prevent-revert.fail { on-init { error("Error detecting active slot") } }
##
# revert – go back to the previous validated slot
##
task revert.a {
require-uboot-variable(uboot-env, "nerves_fw_active", "b")
require-uboot-variable(uboot-env, "a.nerves_fw_platform", "${NERVES_FW_PLATFORM}")
require-uboot-variable(uboot-env, "a.nerves_fw_architecture", "${NERVES_FW_ARCHITECTURE}")
on-init {
info("Reverting to partition A")
uboot_setenv(uboot-env, "nerves_fw_active", "a")
uboot_setenv(uboot-env, "nerves_fw_validated", "1")
}
}
task revert.b {
require-uboot-variable(uboot-env, "nerves_fw_active", "a")
require-uboot-variable(uboot-env, "b.nerves_fw_platform", "${NERVES_FW_PLATFORM}")
require-uboot-variable(uboot-env, "b.nerves_fw_architecture", "${NERVES_FW_ARCHITECTURE}")
on-init {
info("Reverting to partition B")
uboot_setenv(uboot-env, "nerves_fw_active", "b")
uboot_setenv(uboot-env, "nerves_fw_validated", "1")
}
}
task revert.wrongplatform { on-init { error("Unexpected platform/architecture") } }
##
# validate – called by `nerves_runtime` once the new rootfs has booted successfully
##
task validate {
on-init {
info("Marking firmware valid")
uboot_setenv(uboot-env, "nerves_fw_validated", "1")
uboot_setenv(uboot-env, "upgrade_available", "0")
uboot_setenv(uboot-env, "bootcount", "1")
}
}
##
# status – print active slot
##
task status.aa { require-path-on-device("/", "/dev/mmcblk1p2") require-uboot-variable(uboot-env,"nerves_fw_active","a") on-init{ info("a") } }
task status.ab { require-path-on-device("/", "/dev/mmcblk1p2") require-uboot-variable(uboot-env,"nerves_fw_active","b") on-init{ info("a->b") } }
task status.bb { require-path-on-device("/", "/dev/mmcblk1p3") require-uboot-variable(uboot-env,"nerves_fw_active","b") on-init{ info("b") } }
task status.ba { require-path-on-device("/", "/dev/mmcblk1p3") require-uboot-variable(uboot-env,"nerves_fw_active","a") on-init{ info("b->a") } }
task status.fail { on-init { error("fail") } }