Skip to content

Commit

Permalink
Merge pull request #1 from irodriguez-veridas/switch-rootfs
Browse files Browse the repository at this point in the history
Rewrite switch-rootfs using capsule
  • Loading branch information
mwest90 authored Apr 29, 2024
2 parents 06c1019 + 09f17ab commit 14b68a8
Showing 1 changed file with 11 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
set -e
echo "$(mender show-artifact): $(basename "$0") was called!" >&2

get_bootpart() {
Expand All @@ -11,30 +12,22 @@ get_bootpart() {
echo "$current_slot"
}

reset_unbootable_status() {
local AB="AB"
local slot="Slot${AB:$1:1}"
local varname="781e084c-a330-417c-b678-38e696380cb9-RootfsStatus${slot}"

local f=$(mktemp)
printf "\x00\x00\x00\x00" > $f
efivar -n "${varname}" -f $f -w
rm ${f}
}


current_slot=`get_bootpart`
echo "current_slot=$current_slot" >&2

next_slot=
next_rootfs_dev=
if [ $current_slot = "0" ]; then
next_slot="1"
next_rootfs_dev="/dev/disk/by-partlabel/APP_b"
else
next_slot="0"
next_rootfs_dev="/dev/disk/by-partlabel/APP"
fi

echo "next_slot=$next_slot" >&2
nvbootctrl set-active-boot-slot $next_slot
reset_unbootable_status $next_slot
tmp_mount=`mktemp -d`

mkdir -p /opt/nvidia/esp/EFI/UpdateCapsule
mount -o ro $next_rootfs_dev $tmp_mount
cp ${tmp_mount}/opt/nvidia/UpdateCapsule/tegra-bl.cap /opt/nvidia/esp/EFI/UpdateCapsule/TEGRA_BL.Cap
umount $tmp_mount
oe4t-set-uefi-OSIndications

exit 0

0 comments on commit 14b68a8

Please sign in to comment.