Current section
Files
Jump to
Current section
Files
nerves_system_sg2002
fwup-ops.conf
fwup-ops.conf
# -----------------------------------------------------------------
# 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") } }