diff --git a/meta-mender-tegra/classes/tegra-mender-setup.bbclass b/meta-mender-tegra/classes/tegra-mender-setup.bbclass index af50773a..0b1d9ea6 100644 --- a/meta-mender-tegra/classes/tegra-mender-setup.bbclass +++ b/meta-mender-tegra/classes/tegra-mender-setup.bbclass @@ -19,9 +19,9 @@ ARTIFACTIMG_FSTYPE = "ext4" IMAGE_TYPEDEP_tegraflash += " dataimg" IMAGE_FSTYPES += "dataimg" PREFERRED_PROVIDER_u-boot-fw-utils = "u-boot-fw-utils-tegra" -PREFERRED_PROVIDER_libubootenv_tegra = "${'libubootenv-fake' if d.getVar('PREFERRED_PROVIDER_virtual/bootloader').startswith('cboot') else 'libubootenv'}" +PREFERRED_PROVIDER_libubootenv_tegra = "${@'libubootenv-fake' if d.getVar('PREFERRED_PROVIDER_virtual/bootloader').startswith('cboot') else 'libubootenv'}" PREFERRED_RPROVIDER_u-boot-fw-utils = "u-boot-fw-utils-tegra" -PREFERRED_RPROVIDER_libubootenv-bin_tegra = "${'libubootenv-fake' if d.getVar('PREFERRED_PROVIDER_virtual/bootloader').startswith('cboot') else 'libubootenv-bin'}" +PREFERRED_RPROVIDER_libubootenv-bin_tegra = "${@'libubootenv-fake' if d.getVar('PREFERRED_PROVIDER_virtual/bootloader').startswith('cboot') else 'libubootenv-bin'}" # Note: this isn't really a boot file, just put it here to keep the mender build from # complaining about empty IMAGE_BOOT_FILES. We won't use the full image anyway, just the mender file IMAGE_BOOT_FILES = "u-boot-dtb.bin" diff --git a/meta-mender-tegra/recipes-bsp/tegra-binaries/redundant-boot-overrides/update-nvbootctrl.service.in b/meta-mender-tegra/recipes-bsp/tegra-binaries/redundant-boot-overrides/update-nvbootctrl.service.in new file mode 100644 index 00000000..e03ad79a --- /dev/null +++ b/meta-mender-tegra/recipes-bsp/tegra-binaries/redundant-boot-overrides/update-nvbootctrl.service.in @@ -0,0 +1,12 @@ +[Unit] +Description=Update bootloader on successful boot +ConditionPathExists=!@LOCALSTATEDIR@/lib/mender/dont-mark-next-boot-successful +Before=network.target + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=@SBINDIR@/update-nvbootctrl + +[Install] +WantedBy=multi-user.target diff --git a/meta-mender-tegra/recipes-bsp/tegra-binaries/redundant-boot-overrides/update-nvbootctrl.sh.in b/meta-mender-tegra/recipes-bsp/tegra-binaries/redundant-boot-overrides/update-nvbootctrl.sh.in new file mode 100644 index 00000000..e8e64127 --- /dev/null +++ b/meta-mender-tegra/recipes-bsp/tegra-binaries/redundant-boot-overrides/update-nvbootctrl.sh.in @@ -0,0 +1,10 @@ +#!/bin/sh +NVBC=@SBINDIR@/nvbootctrl +curslot=$($NVBC get-current-slot) +if [ -n "$curslot" ]; then + if $NVBC set-active-boot-slot $curslot && $NVBC mark-boot-successful; then + exit 0 + fi +fi +echo "ERR: could not update NV boot slots" >&2 +exit 1 diff --git a/meta-mender-tegra/recipes-bsp/tegra-binaries/redundant-boot-overrides_1.0.bb b/meta-mender-tegra/recipes-bsp/tegra-binaries/redundant-boot-overrides_1.0.bb index 19cd2b98..5a9fc6e0 100644 --- a/meta-mender-tegra/recipes-bsp/tegra-binaries/redundant-boot-overrides_1.0.bb +++ b/meta-mender-tegra/recipes-bsp/tegra-binaries/redundant-boot-overrides_1.0.bb @@ -3,12 +3,37 @@ LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" COMPATIBLE_MACHINE = "(tegra)" +COMPATIBLE_MACHINE_tegra210 = "(-)" + +SRC_URI = "\ + file://update-nvbootctrl.service.in \ + file://update-nvbootctrl.sh.in \ +" + +inherit systemd S = "${WORKDIR}" +B = "${WORKDIR}/build" + +run_sed() { + outfile=$(basename "$1" .in) + sed -e's,@SBINDIR@,${sbindir},g' \ + -e's,@LOCALSTATEDIR@,${localstatedir},g' "$1" > ${B}/$outfile +} + +do_configure() { + run_sed ${S}/update-nvbootctrl.service.in + run_sed ${S}/update-nvbootctrl.sh.in +} do_compile[noexec] = "1" do_install() { install -d ${D}${sysconfdir}/systemd/system/ ln -sf /dev/null ${D}${sysconfdir}/systemd/system/nv_update_verifier.service + install -d ${D}${systemd_system_unitdir} ${D}${sbindir} + install -m 0755 ${B}/update-nvbootctrl.sh ${D}${sbindir}/update-nvbootctrl + install -m 0644 ${B}/update-nvbootctrl.service ${D}${systemd_system_unitdir}/ } + +SYSTEMD_SERVICE_${PN} = "update-nvbootctrl.service" diff --git a/meta-mender-tegra/recipes-mender/tegra-state-scripts/files/redundant-boot-commit-script b/meta-mender-tegra/recipes-mender/tegra-state-scripts/files/redundant-boot-commit-script deleted file mode 100644 index ce8490eb..00000000 --- a/meta-mender-tegra/recipes-mender/tegra-state-scripts/files/redundant-boot-commit-script +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -e -echo "Notifying NV bootloader of successful upgrade" -curslot=`nvbootctrl get-current-slot` -if ! nvbootctrl mark-boot-successful; then - echo "ERR: could not set boot-succesful status for slot: $curslot" >&2 - exit 1 -fi -echo "Marked boot slot $curslot as successful" -exit 0 diff --git a/meta-mender-tegra/recipes-mender/tegra-state-scripts/files/redundant-boot-rollback-reboot-script b/meta-mender-tegra/recipes-mender/tegra-state-scripts/files/redundant-boot-rollback-reboot-script deleted file mode 100644 index 1e1ab88b..00000000 --- a/meta-mender-tegra/recipes-mender/tegra-state-scripts/files/redundant-boot-rollback-reboot-script +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -e - -# We've rebooted after a rollback, let the Tegra bootloader -# know that we booted successfully. - -curslot=`nvbootctrl get-current-slot` -if ! nvbootctrl mark-boot-successful; then - echo "ERR: could not restore boot-succesful status for slot: $curslot" >&2 - exit 1 -fi -echo "Marked boot slot $curslot as successful" -exit 0 - diff --git a/meta-mender-tegra/recipes-mender/tegra-state-scripts/files/redundant-boot-rollback-script b/meta-mender-tegra/recipes-mender/tegra-state-scripts/files/redundant-boot-rollback-script deleted file mode 100644 index 4e7f7398..00000000 --- a/meta-mender-tegra/recipes-mender/tegra-state-scripts/files/redundant-boot-rollback-script +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -echo "Rolling back NV bootloader upgrade" -curslot=`nvbootctrl get-current-slot` - -# If cboot failed to boot after an update, the -# current boot slot should be the pre-update slot -# already, but set it to be sure -if ! nvbootctrl set-active-boot-slot $curslot; then - echo "ERR: could not set active boot slot to: $curslot" >&2 - exit 1 -fi -exit 0 diff --git a/meta-mender-tegra/recipes-mender/tegra-state-scripts/files/redundant-boot-rollback-script-uboot b/meta-mender-tegra/recipes-mender/tegra-state-scripts/files/redundant-boot-rollback-script-uboot index 05eddf3a..afd2e030 100644 --- a/meta-mender-tegra/recipes-mender/tegra-state-scripts/files/redundant-boot-rollback-script-uboot +++ b/meta-mender-tegra/recipes-mender/tegra-state-scripts/files/redundant-boot-rollback-script-uboot @@ -38,10 +38,3 @@ if [ "${devnam##/dev/mmcblk}" != "${devnam}" ]; then exit 0 fi fi - -# Otherwise, just make sure the current slot is -# the one we're booting from -if ! nvbootctrl set-active-boot-slot $curslot; then - echo "ERR: could not set active boot slot to: $curslot" >&2 - exit 1 -fi diff --git a/meta-mender-tegra/recipes-mender/tegra-state-scripts/tegra-state-scripts_1.0.bb b/meta-mender-tegra/recipes-mender/tegra-state-scripts/tegra-state-scripts_1.0.bb index 59317617..bcdbdc25 100644 --- a/meta-mender-tegra/recipes-mender/tegra-state-scripts/tegra-state-scripts_1.0.bb +++ b/meta-mender-tegra/recipes-mender/tegra-state-scripts/tegra-state-scripts_1.0.bb @@ -1,11 +1,8 @@ SRC_URI = " \ - file://redundant-boot-commit-script \ file://redundant-boot-commit-check-script-uboot \ file://redundant-boot-install-script \ file://redundant-boot-install-script-uboot \ - file://redundant-boot-rollback-script \ file://redundant-boot-rollback-script-uboot \ - file://redundant-boot-rollback-reboot-script \ " LICENSE = "Apache-2.0" @@ -24,7 +21,6 @@ PERSIST_MACHINE_ID_mender-persist-systemd-machine-id = "yes" # the machine-id. copy_install_script() { sed -e's,@COPY_MACHINE_ID@,${PERSIST_MACHINE_ID},' ${S}/redundant-boot-install-script > ${MENDER_STATE_SCRIPTS_DIR}/ArtifactInstall_Leave_80_bl-update - cp ${S}/redundant-boot-rollback-script ${MENDER_STATE_SCRIPTS_DIR}/ArtifactRollback_Leave_80_bl-rollback } copy_install_script_mender-uboot() { @@ -33,11 +29,6 @@ copy_install_script_mender-uboot() { cp ${S}/redundant-boot-commit-check-script-uboot ${MENDER_STATE_SCRIPTS_DIR}/ArtifactCommit_Enter_80_bl-check-update } -copy_other_scripts() { - cp ${S}/redundant-boot-commit-script ${MENDER_STATE_SCRIPTS_DIR}/ArtifactCommit_Leave_90_bl-commit - cp ${S}/redundant-boot-rollback-reboot-script ${MENDER_STATE_SCRIPTS_DIR}/ArtifactRollbackReboot_Leave_90_bl-rolledback -} - # These scripts are only needed for tegra platforms with the # A/B-redundant bootloader, which currently are just TX2 # (tegra186) and Xavier (tegra194). @@ -47,12 +38,10 @@ do_compile() { do_compile_tegra194() { copy_install_script - copy_other_scripts } do_compile_tegra186() { copy_install_script - copy_other_scripts } # Make sure scripts aren't left around from old builds