Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update NVIDIA bootloader state on every boot #8

Merged
merged 3 commits into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions meta-mender-tegra/classes/tegra-mender-setup.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -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'}"
madisongh marked this conversation as resolved.
Show resolved Hide resolved
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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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
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
madisongh marked this conversation as resolved.
Show resolved Hide resolved
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"

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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() {
Expand All @@ -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).
Expand All @@ -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
Expand Down