tegra-minimal-init: support L4T UEFI boot chain variable

Stock L4T puts a different 'root=' setting into the kernel image
in the two kernel partitions and/or writes the extlinux.conf differently
based on which slot is being updated.  To avoid having to do that,
and since the bootloader itself doesn't update the kernel command line
to indicate which boot chain we should be using, parse the
BootChainFwCurrent EFI variable to make that determination instead.

Signed-off-by: Matt Madison <matt@madison.systems>
This commit is contained in:
Matt Madison
2022-08-26 08:23:40 -07:00
committed by Matt Madison
parent 59808261e5
commit 164ce0d6ed
2 changed files with 14 additions and 4 deletions

View File

@@ -1,8 +1,9 @@
#!/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
mount -t proc proc /proc
mount -t devtmpfs none /dev
mount -t sysfs sysfs /sys
mount -t proc proc -o nosuid,nodev,noexec /proc
mount -t devtmpfs none -o nosuid /dev
mount -t sysfs sysfs -o nosuid,nodev,noexec /sys
mount -t efivarfs efivarfs -o nosuid,nodev,noexec /sys/firmware/efi/efivars
rootdev=""
opt="rw"

View File

@@ -1,13 +1,22 @@
slotsfx=""
mayberoot=""
foundslotsfx="no"
for bootarg in `cat /proc/cmdline`; do
case "$bootarg" in
boot.slot_suffix=*) slotsfx="${bootarg##boot.slot_suffix=}" ;;
boot.slot_suffix=*) slotsfx="${bootarg##boot.slot_suffix=}"; foundslotsfx="yes" ;;
root=*) mayberoot="${bootarg##root=}" ;;
ro) opt="ro" ;;
rootwait) wait="yes" ;;
esac
done
if [ "$foundslotsfx" != "yes" ]; then
# This variable file contains a type (should be 6) followed by the value (should be 0 or 1)
bcdata=$(echo $(hexdump -n 8 -e '2/4 " %u"' /sys/firmware/efi/efivars/BootChainFwCurrent-781e084c-a330-417c-b678-38e696380cb9 2>/dev/null))
if [ "$(echo "$bcdata" | cut -d' ' -f1)" = "6" ]; then
slotnum=$(echo "$bcdata" | cut -d' ' -f2)
[ "$slotnum" != "1" ] || slotsfx="_b"
fi
fi
rootdev=`blkid -l -t PARTLABEL=APP$slotsfx | cut -d: -f1`
if [ -z "$rootdev" ]; then
if [ -n "$mayberoot" ]; then