Skip to content

Commit

Permalink
tegra: redundant-boot-overrides: add service to replace nv_update_ver…
Browse files Browse the repository at this point in the history
…ifier

With recent versions of L4T, the NVIDIA bootloader on platforms
that support A/B redundancy will automatically decrement the priority
level of the current boot slot before starting the operating system,
expecting that the nv_update_verifier service will reset it if the
OS boot is successful.  If the system boots three times without
resetting the priority, the bootloader will fail over to the alternate
boot slot.

For Mender, we do not use nv_update_verifier due to some undesirable
side-effects, so we mask it from being run at startup.  To prevent
the failover from occurring, provide our own service to run the
necessary commands to both mark the current boot successful and
reset the slot priority.

Signed-off-by: Matt Madison <matt@madison.systems>
  • Loading branch information
madisongh committed Nov 11, 2020
1 parent d6a8be8 commit 5c7a734
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Update bootloader on successful boot
Wants=mender-client.service
After=mender-client.service
ConditionPathExists=!@LOCALSTATEDIR@/lib/mender/dont-mark-next-boot-successful

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=@SBINDIR@/update-nvbootctrl

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 5c7a734

Please sign in to comment.