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

jetson: Update next active slots on HUP #245

Merged
9 commits merged into from
Feb 2, 2022
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Mark boot slot as successful once the system is up

[Service]
Type=oneshot
ExecStart=/bin/sh -c /usr/bin/mark_active_tegra_boot_slot.sh

[Install]
WantedBy=multi-user.target
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@acostach is this service running every single boot, even if no HUP happened?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @alexgg , indeed, it needs to run every boot, otherwise the tegra bootloaders will consider that the current one failed and decrease the current slot's priority, causing the alternate to be loaded once the retries number is achieved.

Disabling redundant boot after marking a boot sequence as successful unfortunately triggers the default slot _a to be loaded, so the only option for now is to mark every boot if we want to have the kernel and dtb loaded from the selected raw partitions, _a or _b.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

# Ensure reduntant boot is enabled
if /usr/bin/tegra-boot-control -e ; then
echo "Tegra redundant boot: enabled successfully"
else
echo "Tegra redundant boot: failed to enable!"
fi;

# If the boot process was
# able to start the rollback service, we can
# mark the current boot as successful
# Othrwise if not marked, the old kernel
# and dtb slots will be used after 3 attempts
# as per https://forums.developer.nvidia.com/t/failed-bootloader-watchdog-recovery/154380/5
if /usr/bin/tegra-boot-control -m ; then
echo "Tegra redundant boot: marked successful boot"
else
echo "Tegra redundant boot: failed to record successful boot"
fi

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"

# libuuid was split from the main
# util-linux later, after Dunfell
DEPENDS:remove = "util-linux-libuuid"
DEPENDS:append = " util-linux"

SRC_URI += " \
file://mark_active_tegra_boot_slot.sh \
file://mark-active-slot.service \
"

# Once redundant boot is enabled, each boot
# needs to be marked as successful once
# the system is up to prevent the tegra
# bootloaders from decrementing boot count
# and reverting to the previous slot. If
# redundant boot is disabled, default slot _a
# is used.
SYSTEMD_PACKAGES += " ${PN}"
SYSTEMD_SERVICE:${PN} += " mark-active-slot.service"

# Upon rollback to a release that does not have
# this feature implemented, the _a slots will
# be used by default, without chaning behavior.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor type here chaning -> changing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @jakogut , I'll get that fixed

do_install:append() {
install -m 0755 ${WORKDIR}/mark_active_tegra_boot_slot.sh ${D}${bindir}/
install -m 0644 ${WORKDIR}/mark-active-slot.service ${D}${systemd_unitdir}/system/
}

FILES:${PN} += " \
/lib/systemd/system/mark-active-slot.service \
"