From cb5881cbe7092dbee6183d876b7be1b14debaf63 Mon Sep 17 00:00:00 2001 From: Alexandru Costache Date: Mon, 14 Oct 2024 12:31:54 +0000 Subject: [PATCH] initramfs/migrate: Copy Jetson Orin boot artifact and UEFI capsule Copying these files before unmounting the rootfs is needed for the case where the NVME is provisioned with a flasher image already. If the QSPI is accessible, it will be written directly, otherwise a capsule update will be prepared by the resin-init-flasher-board script and applied by the UEFI firmware as soon as the board re-boots. If the capsule update is interrupted on the first boot, a device specific service will attempt to re-trigger it in the next two boots. Change-type: patch Signed-off-by: Alexandru Costache --- .../recipes-core/initrdscripts/files/migrate | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) mode change 100644 => 100755 meta-balena-common/recipes-core/initrdscripts/files/migrate diff --git a/meta-balena-common/recipes-core/initrdscripts/files/migrate b/meta-balena-common/recipes-core/initrdscripts/files/migrate old mode 100644 new mode 100755 index fab61c86b1..4f20f85cfa --- a/meta-balena-common/recipes-core/initrdscripts/files/migrate +++ b/meta-balena-common/recipes-core/initrdscripts/files/migrate @@ -96,7 +96,9 @@ migrate_enabled() { migrate_run() { # Find the raw image in the rootfs partition image=$(find "${ROOTFS_DIR}" -xdev -type f -name "${BALENA_IMAGE}") - kernel_images=$(find "${ROOTFS_DIR}" -xdev -type f -name "@@KERNEL_IMAGETYPE@@*") + kernel_images=$(find "${ROOTFS_DIR}" -xdev -type f -name "Image*") + jetson_orin_capsule=$(find "${ROOTFS_DIR}" -xdev -type f -name "TEGRA_BL_*Cap*") + jetson_orin_boot_artifact=$(find "${ROOTFS_DIR}" -xdev -type f -name "boot0.img.gz") if [ -n "${image}" ]; then EXTERNAL_DEVICE_BOOT_PART_MOUNTPOINT="${BALENA_BOOT_MOUNTPOINT}" if findmnt "${FLASH_BOOT_MOUNT}" > /dev/null; then @@ -120,6 +122,21 @@ migrate_run() { # shellcheck disable=SC2086 cp -a ${kernel_images} "/tmp" + # If this is a Jetson Orin device, the flasher image contains + # a compressed boot blob as well as a UEFI capsule. + # If the QSPI is accessible, it will be written directly, + # otherwise a capsule update will be triggered on the next boot + # after provisioning + if [ -f "${jetson_orin_capsule}" ]; then + cp "${jetson_orin_capsule}" "/tmp/" + info "Copied ${jetson_orin_capsule}" + fi + + if [ -f "${jetson_orin_boot_artifact}" ]; then + cp "${jetson_orin_boot_artifact}" "/tmp/" + info "Copied ${jetson_orin_boot_artifact}" + fi + # Need to source this again to set CONFIG_PATH correctly unset CONFIG_PATH # shellcheck disable=SC1091