Skip to content

Commit 55e851e

Browse files
committed
Unset nerves_fw_active to avoid confusion
This completely removes the `nerves_fw_active` U-Boot environment variable on upgrades so that stale versions don't exist. It also cleans up `nerves_fw_validated` to only be the slot-specific versions. This shouldn't change or break anything so long as relatively up to date versions of `Nerves.Runtime` are being used.
1 parent 6196309 commit 55e851e

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

fwup.conf

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ task complete {
7272

7373
include("${NERVES_PROVISIONING}")
7474

75-
uboot_setenv(uboot-env, "nerves_fw_active", "a") # mirrors autoboot.txt
7675
uboot_setenv(uboot-env, "nerves_fw_devpath", ${NERVES_FW_DEVPATH})
7776
uboot_setenv(uboot-env, "a.nerves_fw_validated", "1")
7877
uboot_setenv(uboot-env, "a.nerves_fw_application_part0_devpath", ${NERVES_FW_APPLICATION_PART0_DEVPATH})
@@ -218,10 +217,12 @@ task upgrade.old-a {
218217
uboot_setenv(uboot-env, "a.nerves_fw_vcs_identifier", ${NERVES_FW_VCS_IDENTIFIER})
219218
uboot_setenv(uboot-env, "a.nerves_fw_misc", ${NERVES_FW_MISC})
220219
uboot_setenv(uboot-env, "a.nerves_fw_uuid", "\${FWUP_META_UUID}")
220+
uboot_unsetenv(uboot-env, "nerves_fw_active") # No longer used
221+
uboot_unsetenv(uboot-env, "nerves_fw_validated") # No longer used
221222

222-
# Switch over to boot the new firmware but validate since can't go back
223-
uboot_setenv(uboot-env, "nerves_fw_active", "a") # mirrors autoboot.txt
223+
# Validate since can't go back
224224
uboot_setenv(uboot-env, "a.nerves_fw_validated", "1")
225+
uboot_setenv(uboot-env, "b.nerves_fw_validated", "0")
225226
mbr_write(mbr)
226227
}
227228
}
@@ -304,10 +305,12 @@ task upgrade.old-b {
304305
uboot_setenv(uboot-env, "b.nerves_fw_vcs_identifier", ${NERVES_FW_VCS_IDENTIFIER})
305306
uboot_setenv(uboot-env, "b.nerves_fw_misc", ${NERVES_FW_MISC})
306307
uboot_setenv(uboot-env, "b.nerves_fw_uuid", "\${FWUP_META_UUID}")
308+
uboot_unsetenv(uboot-env, "nerves_fw_active") # No longer used
309+
uboot_unsetenv(uboot-env, "nerves_fw_validated") # No longer used
307310

308-
# Switch over to boot the new firmware but validate since can't go back
309-
uboot_setenv(uboot-env, "nerves_fw_active", "b") # mirrors autoboot.txt
311+
# Validate since can't go back
310312
uboot_setenv(uboot-env, "b.nerves_fw_validated", "1")
313+
uboot_setenv(uboot-env, "a.nerves_fw_validated", "0")
311314
mbr_write(mbr)
312315
}
313316
}

fwup.conf.eex

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ task complete {
7777

7878
include("${NERVES_PROVISIONING}")
7979

80-
uboot_setenv(uboot-env, "nerves_fw_active", "a") # mirrors autoboot.txt
8180
uboot_setenv(uboot-env, "nerves_fw_devpath", ${NERVES_FW_DEVPATH})
8281
uboot_setenv(uboot-env, "a.nerves_fw_validated", "1")
8382
uboot_setenv(uboot-env, "a.nerves_fw_application_part0_devpath", ${NERVES_FW_APPLICATION_PART0_DEVPATH})
@@ -175,10 +174,12 @@ task upgrade.old-a {
175174
uboot_setenv(uboot-env, "a.nerves_fw_vcs_identifier", ${NERVES_FW_VCS_IDENTIFIER})
176175
uboot_setenv(uboot-env, "a.nerves_fw_misc", ${NERVES_FW_MISC})
177176
uboot_setenv(uboot-env, "a.nerves_fw_uuid", "\${FWUP_META_UUID}")
177+
uboot_unsetenv(uboot-env, "nerves_fw_active") # No longer used
178+
uboot_unsetenv(uboot-env, "nerves_fw_validated") # No longer used
178179

179-
# Switch over to boot the new firmware but validate since can't go back
180-
uboot_setenv(uboot-env, "nerves_fw_active", "a") # mirrors autoboot.txt
180+
# Validate since can't go back
181181
uboot_setenv(uboot-env, "a.nerves_fw_validated", "1")
182+
uboot_setenv(uboot-env, "b.nerves_fw_validated", "0")
182183
mbr_write(mbr)
183184
}
184185
}
@@ -238,10 +239,12 @@ task upgrade.old-b {
238239
uboot_setenv(uboot-env, "b.nerves_fw_vcs_identifier", ${NERVES_FW_VCS_IDENTIFIER})
239240
uboot_setenv(uboot-env, "b.nerves_fw_misc", ${NERVES_FW_MISC})
240241
uboot_setenv(uboot-env, "b.nerves_fw_uuid", "\${FWUP_META_UUID}")
242+
uboot_unsetenv(uboot-env, "nerves_fw_active") # No longer used
243+
uboot_unsetenv(uboot-env, "nerves_fw_validated") # No longer used
241244

242-
# Switch over to boot the new firmware but validate since can't go back
243-
uboot_setenv(uboot-env, "nerves_fw_active", "b") # mirrors autoboot.txt
245+
# Validate since can't go back
244246
uboot_setenv(uboot-env, "b.nerves_fw_validated", "1")
247+
uboot_setenv(uboot-env, "a.nerves_fw_validated", "0")
245248
mbr_write(mbr)
246249
}
247250
}

0 commit comments

Comments
 (0)