From fd72dd0188457fa760c1d3b8ffe08626528e81e4 Mon Sep 17 00:00:00 2001 From: Josef Holzmayr Date: Sun, 23 Jul 2023 22:51:55 +0200 Subject: [PATCH] fix: Tegra, Jetpack5: remove outdated state scripts State scripts referring to TX2 and Nano can be removed. See also comment: https://github.com/OE4T/meta-mender-community/pull/18#discussion_r1271045501 Signed-off-by: Josef Holzmayr --- .../redundant-boot-commit-check-script-uboot | 38 ------- .../files/redundant-boot-install-script | 69 ------------ .../files/redundant-boot-install-script-uboot | 101 ------------------ .../tegra-state-scripts_1.0.bb | 28 ----- 4 files changed, 236 deletions(-) delete mode 100644 meta-mender-tegra/meta-mender-tegra-jetpack5/recipes-mender/tegra-state-scripts/files/redundant-boot-commit-check-script-uboot delete mode 100644 meta-mender-tegra/meta-mender-tegra-jetpack5/recipes-mender/tegra-state-scripts/files/redundant-boot-install-script delete mode 100644 meta-mender-tegra/meta-mender-tegra-jetpack5/recipes-mender/tegra-state-scripts/files/redundant-boot-install-script-uboot diff --git a/meta-mender-tegra/meta-mender-tegra-jetpack5/recipes-mender/tegra-state-scripts/files/redundant-boot-commit-check-script-uboot b/meta-mender-tegra/meta-mender-tegra-jetpack5/recipes-mender/tegra-state-scripts/files/redundant-boot-commit-check-script-uboot deleted file mode 100644 index f2764b572..000000000 --- a/meta-mender-tegra/meta-mender-tegra-jetpack5/recipes-mender/tegra-state-scripts/files/redundant-boot-commit-check-script-uboot +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -LABELCHARS="AB" - -echo "Verifying Tegra bootloader update" -curslot=`nvbootctrl get-current-slot 2>/dev/null || tegra-boot-control --current-slot 2>/dev/null` -cfglbl="\"RootfsPart${LABELCHARS:$curslot:1}\"" -devnam=`grep -h "$cfglbl:" /etc/mender/mender.conf /var/lib/mender/mender.conf | cut -d: -f2 | cut -d, -f1 | tr -d '" '` -if [ -z "$devnam" ]; then - echo "ERR: could not determine expected mender device name for boot slot $curslot" >&2 - exit 1 -fi - -# If the rootfs partitions are eMMC/SDcard device names, verify that -# the mender boot partition in U-Boot and the Tegra bootloader boot -# slot match. If not, the Tegra bootloader update failed, and we -# need to reset the boot slot to get the Tegra bootloader and Mender -# resynchronized. -if [ "${devnam##/dev/mmcblk}" != "${devnam}" ]; then - bootpart=`fw_printenv -n mender_boot_part` - if [ -z "$bootpart" ]; then - echo "ERR: could not retrieve mender_boot_part from U-Boot env" >&2 - exit 1 - fi - devnampart=`expr "${devnam##/dev/mmcblk*p}" \+ 0 2>/dev/null` - if [ -z "$devnampart" ]; then - echo "ERR: could not extract partition number from rootfs device name" >&2 - exit 1 - fi - if [ $bootpart -ne $devnampart ]; then - altslot=$(expr 1 - $curslot) - echo "Detected Tegra bootloader upgrade failure, resetting boot slot to $altslot" >&2 - echo "*** Reboot required ***" >&2 - tegra-boot-control --set-active $altslot - exit 1 - fi -fi -exit 0 diff --git a/meta-mender-tegra/meta-mender-tegra-jetpack5/recipes-mender/tegra-state-scripts/files/redundant-boot-install-script b/meta-mender-tegra/meta-mender-tegra-jetpack5/recipes-mender/tegra-state-scripts/files/redundant-boot-install-script deleted file mode 100644 index 5779ac86b..000000000 --- a/meta-mender-tegra/meta-mender-tegra-jetpack5/recipes-mender/tegra-state-scripts/files/redundant-boot-install-script +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh - -mnt= -LABELCHARS="AB" -COPY_MACHINE_ID=@COPY_MACHINE_ID@ - -cleanup() { - [ -n "$mnt" ] || return - for d in sys proc dev run; do - if mountpoint -q "${mnt}/${d}"; then - umount "${mnt}/${d}" >/dev/null 2>&1 || true - fi - done - if mountpoint -q "$mnt"; then - umount "$mnt" >/dev/null 2>&1 || true - fi - rmdir "$mnt" >/dev/null 2>&1 || true -} - -echo "Installing NVIDIA bootloader update payload" - -if which tegra-boot-control >/dev/null 2>&1; then - current_slot=`tegra-boot-control --current-slot` -else - current_slot=`nvbootctrl get-current-slot` -fi -echo "Current boot slot: $current_slot" -otherslot=`expr 1 - $current_slot` -cfglbl="\"RootfsPart${LABELCHARS:$otherslot:1}\"" -devnam=`grep -h "$cfglbl:" /etc/mender/mender.conf /var/lib/mender/mender.conf | cut -d: -f2 | cut -d, -f1 | tr -d '" '` -if [ -z "$devnam" ]; then - echo "ERR: could not determine device name for boot slot $otherslot" >&2 - exit 1 -fi -mnt=`mktemp -d -t nvbup.XXXXXX` -if [ -z "$mnt" -o ! -d "$mnt" ]; then - echo "ERR: could not create directory for mounting install partition" >&2 - exit 1 -fi -mount -o ro "$devnam" "$mnt" -if [ ! -d "${mnt}/opt/ota_package" ]; then - echo "ERR: Missing /opt/ota_package directory in installed rootfs" >&2 - cleanup - exit 1 -fi -# tegra-bootloader-update needs access to these filesystems, -# so bind-mount them into the new rootfs for the chroot -mount --bind /sys "${mnt}/sys" -mount --bind /proc "${mnt}/proc" -mount --bind /dev "${mnt}/dev" -# for tegra-bootinfo -mount --bind /run "${mnt}/run" - -if ! chroot "${mnt}" /usr/bin/tegra-bootloader-update /opt/ota_package/bl_update_payload; then - echo "ERR: bootloader update failed" >&2 - cleanup - exit 1 -fi -echo "Successful bootloader update" -if [ -n "$COPY_MACHINE_ID" ]; then - curid=$(systemd-machine-id-setup --print) - storedid=$(chroot "${mnt}" /usr/bin/tegra-bootinfo -n -v machine_id 2>/dev/null) - if [ "$curid" != "$storedid" ]; then - chroot "${mnt}" /usr/bin/tegra-bootinfo --initialize 2>/dev/null - chroot "${mnt}" /usr/bin/tegra-bootinfo -V machine_id "$curid" - fi -fi -cleanup -exit 0 diff --git a/meta-mender-tegra/meta-mender-tegra-jetpack5/recipes-mender/tegra-state-scripts/files/redundant-boot-install-script-uboot b/meta-mender-tegra/meta-mender-tegra-jetpack5/recipes-mender/tegra-state-scripts/files/redundant-boot-install-script-uboot deleted file mode 100644 index 27932951a..000000000 --- a/meta-mender-tegra/meta-mender-tegra-jetpack5/recipes-mender/tegra-state-scripts/files/redundant-boot-install-script-uboot +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/sh - -mnt= -UBOOTVARS="bootcount mender_boot_part mender_boot_part_hex upgrade_available" -ubvarfile= -install_fwenv= - -cleanup() { - [ -n "$mnt" ] || return - for d in sys proc dev run; do - if mountpoint -q "${mnt}/${d}"; then - umount "${mnt}/${d}" >/dev/null 2>&1 || true - fi - done - if mountpoint -q "$mnt"; then - umount "$mnt" >/dev/null 2>&1 || true - fi - rmdir "$mnt" >/dev/null 2>&1 || true -} - -save_vars() { - local v - ubvarfile=$(mktemp -p "$1" ubvars.XXXXXX) - for v in $UBOOTVARS; do - fw_printenv $v >>$ubvarfile - done -} - -echo "Installing NVIDIA bootloader update payload" - -new_boot_part=`fw_printenv -n mender_boot_part` -mnt=`mktemp -d -t nvbup.XXXXXX` -if [ -z "$mnt" -o ! -d "$mnt" ]; then - echo "ERR: could not create directory for mounting install partition" >&2 - exit 1 -fi -mount -o ro /dev/mmcblk0p${new_boot_part} "$mnt" -if [ ! -d "${mnt}/opt/ota_package" ]; then - echo "ERR: Missing /opt/ota_package directory in installed rootfs" >&2 - cleanup - exit 1 -fi -# tegra-bootloader-update needs access to these filesystems, -# so bind-mount them into the new rootfs for the chroot -mount --bind /sys "${mnt}/sys" -mount --bind /proc "${mnt}/proc" -mount --bind /dev "${mnt}/dev" -mount -t tmpfs tmpfs "${mnt}/run" - -# Check for u-boot environment location change; save vars for restoration -# into the new environment after the update -if [ -e "$mnt/usr/share/u-boot/fw_env.config" ]; then - if ! diff -qbi /etc/fw_env.config $mnt/usr/share/u-boot/fw_env.config > /dev/null 2>&1; then - save_vars "${mnt}/run" - install_fwenv=yes - fi -fi - -if ! chroot "${mnt}" /usr/bin/tegra-bootloader-update --dry-run /opt/ota_package/bl_update_payload >/dev/null 2>&1; then - # If the tool reports that the version partitions are corrupted, this is an update on a tegra210 - # device with the old partition layout where the U-Boot environment overwrote the version partition(s), - # in which case we recover via complete initialization. - if chroot "${mnt}" /usr/bin/tegra-bootloader-update --dry-run /opt/ota_package/bl_update_payload 2>&1 | grep -q 'version partitions are corrupted'; then - # For the recoverable case, we will have also detected a change the U-Boot environment change - if [ -n "$install_fwenv" ]; then - echo "Detected bootloader partition upgrade, reinitializing" >&2 - if ! chroot "${mnt}" /usr/bin/tegra-bootloader-update --initialize /opt/ota_package/bl_update_payload; then - echo "ERR: bootloader re-initialization failed" >&2 - cleanup - exit 1 - fi - else - echo "WARN: VER partitions are corrupted" >&2 - echo "WARN: Please refer to https://github.com/OE4T/tegra-demo-distro/pull/113 for additional context" >&2 - echo "WARN: Attempting update anyway" >&2 - fi - else - echo "ERR: cannot perform bootloader update" >&2 - cleanup - exit 1 - fi -elif ! chroot "${mnt}" /usr/bin/tegra-bootloader-update /opt/ota_package/bl_update_payload; then - echo "ERR: bootloader update failed" >&2 - cleanup - exit 1 -fi -# If the U-Boot environment config has changed, propagate the important variables -# to the new environment -if [ -n "$install_fwenv" ]; then - if ! chroot "${mnt}" /usr/bin/fw_setenv -c /usr/share/u-boot/fw_env.config -s /run/$(basename "$ubvarfile"); then - echo "ERR: could not restore U-Boot environment after bootloader update" >&2 - cleanup - exit 1 - fi - if [ -L /etc/fw_env.config ]; then - cp $mnt/usr/share/u-boot/fw_env.config $(readlink /etc/fw_env.config) - fi -fi -echo "Successful bootloader update" -cleanup -exit 0 diff --git a/meta-mender-tegra/meta-mender-tegra-jetpack5/recipes-mender/tegra-state-scripts/tegra-state-scripts_1.0.bb b/meta-mender-tegra/meta-mender-tegra-jetpack5/recipes-mender/tegra-state-scripts/tegra-state-scripts_1.0.bb index 85bd8fc34..58d95ca64 100644 --- a/meta-mender-tegra/meta-mender-tegra-jetpack5/recipes-mender/tegra-state-scripts/tegra-state-scripts_1.0.bb +++ b/meta-mender-tegra/meta-mender-tegra-jetpack5/recipes-mender/tegra-state-scripts/tegra-state-scripts_1.0.bb @@ -1,7 +1,4 @@ SRC_URI = " \ - file://redundant-boot-commit-check-script-uboot \ - file://redundant-boot-install-script \ - file://redundant-boot-install-script-uboot \ file://switch-rootfs \ " @@ -15,35 +12,10 @@ inherit mender-state-scripts PERSIST_MACHINE_ID="" PERSIST_MACHINE_ID:mender-persist-systemd-machine-id = "yes" -# We have a different install script for U-Boot vs. cboot, since -# the mechanism for determining boot partitions is different between -# the two, and with cboot there is no U-Boot environment for copying -# 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 -} - -copy_install_script:mender-uboot() { - cp ${S}/redundant-boot-install-script-uboot ${MENDER_STATE_SCRIPTS_DIR}/ArtifactInstall_Leave_80_bl-update - cp ${S}/redundant-boot-commit-check-script-uboot ${MENDER_STATE_SCRIPTS_DIR}/ArtifactCommit_Enter_80_bl-check-update -} - do_compile() { : } -do_compile:tegra194() { - copy_install_script -} - -do_compile:tegra186() { - copy_install_script -} - -do_compile:tegra210() { - cp ${S}/redundant-boot-install-script-uboot ${MENDER_STATE_SCRIPTS_DIR}/ArtifactInstall_Leave_80_bl-update -} - do_compile:tegra234() { cp ${S}/switch-rootfs ${MENDER_STATE_SCRIPTS_DIR}/ArtifactInstall_Leave_50_switch-rootfs }