diff --git a/meta-mender-tegra/classes/tegra-mender-setup.bbclass b/meta-mender-tegra/classes/tegra-mender-setup.bbclass index 67966bb91..50ebb5f15 100644 --- a/meta-mender-tegra/classes/tegra-mender-setup.bbclass +++ b/meta-mender-tegra/classes/tegra-mender-setup.bbclass @@ -35,6 +35,8 @@ PREFERRED_PROVIDER_u-boot-fw-utils = "u-boot-fw-utils-tegra" PREFERRED_PROVIDER_libubootenv:tegra = "${@'libubootenv-fake' if d.getVar('PREFERRED_PROVIDER_virtual/bootloader').startswith('cboot') else 'libubootenv'}" PREFERRED_RPROVIDER_u-boot-fw-utils = "u-boot-fw-utils-tegra" PREFERRED_RPROVIDER_libubootenv-bin:tegra = "${@'libubootenv-fake' if d.getVar('PREFERRED_PROVIDER_virtual/bootloader').startswith('cboot') else 'libubootenv-bin'}" +PREFERRED_PROVIDER_libubootenv:tegra234 = "libubootenv-fake" + # Note: this isn't really a boot file, just put it here to keep the mender build from # complaining about empty IMAGE_BOOT_FILES. We won't use the full image anyway, just the mender file IMAGE_BOOT_FILES = "u-boot-dtb.bin" @@ -48,12 +50,14 @@ MENDER_DATA_PART_NUMBER_DEFAULT:tegra194 = "43" MENDER_DATA_PART_NUMBER_DEFAULT:tegra210 = "${@'16' if (d.getVar('TEGRA_SPIFLASH_BOOT') or '') == '1' else '23'}" MENDER_DATA_PART_NUMBER_DEFAULT:jetson-nano-emmc = "19" MENDER_DATA_PART_NUMBER_DEFAULT:xavier-nx = "12" +MENDER_DATA_PART_NUMBER_DEFAULT:tegra234 = "16" MENDER_ROOTFS_PART_A_NUMBER_DEFAULT = "1" MENDER_ROOTFS_PART_B_NUMBER_DEFAULT:tegra186 = "33" MENDER_ROOTFS_PART_B_NUMBER_DEFAULT:tegra194 = "42" MENDER_ROOTFS_PART_B_NUMBER_DEFAULT:tegra210 = "${@'15' if (d.getVar('TEGRA_SPIFLASH_BOOT') or '') == '1' else '22'}" MENDER_ROOTFS_PART_B_NUMBER_DEFAULT:jetson-nano-emmc = "18" MENDER_ROOTFS_PART_B_NUMBER_DEFAULT:xavier-nx = "11" +MENDER_ROOTFS_PART_B_NUMBER_DEFAULT:tegra234 = "2" # Machine name and flash layout changed for SDcard Nanos in L4T R32.5.x MENDER_DATA_PART_NUMBER_DEFAULT:jetson-nano-devkit = "3" diff --git a/meta-mender-tegra/conf/layer.conf b/meta-mender-tegra/conf/layer.conf index a76764375..05b116300 100644 --- a/meta-mender-tegra/conf/layer.conf +++ b/meta-mender-tegra/conf/layer.conf @@ -10,3 +10,10 @@ BBFILE_PRIORITY_meta-mender-tegra = "10" LAYERVERSION_meta-mender-tegra = "1" LAYERSERIES_COMPAT_meta-mender-tegra = "kirkstone" LAYERDEPENDS_meta-mender-tegra = "tegra" + +BBMASK:tegra234:append = " \ + recipes-bsp/cboot/ \ + recipes-bsp/u-boot/patches \ + recipes-bsp/u-boot/libubootenv_.* \ + recipes-bsp/u-boot/u-boot.* \ + " diff --git a/meta-mender-tegra/recipes-bsp/tegra-binaries/mender-custom-flash-layout/jetson-agx-orin-devkit/flash_mender.xml b/meta-mender-tegra/recipes-bsp/tegra-binaries/mender-custom-flash-layout/jetson-agx-orin-devkit/flash_mender.xml new file mode 100644 index 000000000..791c6fa22 --- /dev/null +++ b/meta-mender-tegra/recipes-bsp/tegra-binaries/mender-custom-flash-layout/jetson-agx-orin-devkit/flash_mender.xml @@ -0,0 +1,760 @@ + + + + + + + + + + sequential + basic + 1048576 + 0 + 8 + 0 + + + sequential + basic + 524288 + 0 + 8 + 0 + MB1FILE + 262144 + + + sequential + basic + 262144 + 0 + 8 + 0 + PSCBL1FILE + 65536 + + + sequential + basic + 131072 + 0 + 8 + 0 + 65536 + + + sequential + basic + 262144 + 0 + 8 + 0 + 65536 + + + sequential + basic + 1048576 + 0 + 8 + 0 + TSECFW + 65536 + + + sequential + basic + 1048576 + 0 + 8 + 0 + NVHOSTNVDEC + 65536 + + + sequential + basic + 524288 + 0 + 8 + 0 + MB2BLFILE + 65536 + + + sequential + basic + 262144 + 0 + 8 + 0 + XUSB_FW + 65536 + + + sequential + basic + 1572864 + 0 + 8 + 0 + BPFFILE + 65536 + + + sequential + basic + 4194304 + 0 + 8 + 0 + BPFDTB_FILE + 65536 + + + sequential + basic + 786432 + 0 + 8 + 0 + PSCFW + 65536 + + + sequential + basic + 524288 + 0 + 8 + 0 + MCE_IMAGE + 65536 + + + sequential + basic + 196608 + 0 + 8 + 0 + WB0FILE + 65536 + + + sequential + basic + 196608 + 0 + 8 + 0 + PSCRF_IMAGE + 65536 + + + sequential + basic + 131072 + 0 + 8 + 0 + MB2RF_IMAGE + 65536 + + + sequential + basic + 3670016 + 0 + 8 + 0 + TBCDTB-FILE + 65536 + + + sequential + basic + 4194304 + 0 + 8 + 0 + TOSFILE + 65536 + + + sequential + basic + 2097152 + 0 + 8 + 0 + 65536 + + + sequential + basic + 262144 + 0 + 8 + 0 + EKSFILE + 65536 + + + sequential + basic + 5242880 + 0 + 8 + 0 + DCE + 65536 + + + sequential + basic + 589824 + 0 + 8 + 0 + SPEFILE + 65536 + + + sequential + basic + 1048576 + 0 + 8 + 0 + CAMERAFW + 65536 + + + sequential + basic + 2097152 + 0 + 8 + 0 + adsp-fw.bin + 65536 + + + sequential + basic + 1376256 + 0 + 8 + 0 + 65536 + + + sequential + basic + 524288 + 0 + 8 + 0 + MB1FILE + 262144 + + + sequential + basic + 262144 + 0 + 8 + 0 + PSCBL1FILE + 65536 + + + sequential + basic + 131072 + 0 + 8 + 0 + 65536 + + + sequential + basic + 262144 + 0 + 8 + 0 + 65536 + + + sequential + basic + 1048576 + 0 + 8 + 0 + TSECFW + 65536 + + + sequential + basic + 1048576 + 0 + 8 + 0 + NVHOSTNVDEC + 65536 + + + sequential + basic + 524288 + 0 + 8 + 0 + MB2BLFILE + 65536 + + + sequential + basic + 262144 + 0 + 8 + 0 + XUSB_FW + 65536 + + + sequential + basic + 1572864 + 0 + 8 + 0 + BPFFILE + 65536 + + + sequential + basic + 4194304 + 0 + 8 + 0 + BPFDTB_FILE + 65536 + + + sequential + basic + 786432 + 0 + 8 + 0 + PSCFW + 65536 + + + sequential + basic + 524288 + 0 + 8 + 0 + MCE_IMAGE + 65536 + + + sequential + basic + 196608 + 0 + 8 + 0 + WB0FILE + 65536 + + + sequential + basic + 196608 + 0 + 8 + 0 + PSCRF_IMAGE + 65536 + + + sequential + basic + 131072 + 0 + 8 + 0 + MB2RF_IMAGE + 65536 + + + sequential + basic + 3670016 + 0 + 8 + 0 + TBCDTB-FILE + 65536 + + + sequential + basic + 4194304 + 0 + 8 + 0 + TOSFILE + 65536 + + + sequential + basic + 2097152 + 0 + 8 + 0 + 65536 + + + sequential + basic + 262144 + 0 + 8 + 0 + EKSFILE + 65536 + + + sequential + basic + 5242880 + 0 + 8 + 0 + DCE + 65536 + + + sequential + basic + 589824 + 0 + 8 + 0 + SPEFILE + 65536 + + + sequential + basic + 1048576 + 0 + 8 + 0 + CAMERAFW + 65536 + + + sequential + basic + 2097152 + 0 + 8 + 0 + adsp-fw.bin + 65536 + + + sequential + basic + 1376256 + 0 + 8 + 0 + 65536 + + + sequential + basic + 262144 + 0 + 0x8 + 0 + 65536 + + + sequential + basic + 524288 + 0 + 0x8 + 0 + 65536 + + + sequential + basic + 0x3F70000 + 196608 + 0 + 0x8 + 0 + 65536 + + + sequential + basic + 0x3FA0000 + 65536 + 65536 + 0 + 8 + 0 + + + sequential + basic + 65536 + 65536 + 0 + 8 + 0 + + + sequential + basic + 65536 + 65536 + 0 + 8 + 0 + + + sequential + basic + 0x3FD0000 + 65536 + 65536 + 0 + 0 + 8 + 0 + VERFILE + + + sequential + basic + 65536 + 65536 + 0 + 0 + 8 + 0 + VERFILE + + + sequential + basic + 0xFFFFFFFFFFFFFFFF + 0 + 8 + 0 + + + + + sequential + basic + 512 + 0 + 8 + 0 + + + sequential + basic + 19968 + 0 + 8 + 0 + + + sequential + basic + 134217728 + 0 + 8 + 0 + LNXFILE + + + sequential + basic + 786432 + 0 + 8 + 0 + DTB_FILE + + + sequential + basic + 33161216 + 0 + 8 + 0 + + + sequential + basic + 134217728 + 0 + 8 + 0 + LNXFILE_b + + + sequential + basic + 786432 + 0 + 8 + 0 + DTB_FILE + + + sequential + basic + 33161216 + 0 + 8 + 0 + + + sequential + basic + RECSIZE + 0 + 8 + 0 + RECFILE + + + sequential + basic + 524288 + 0 + 8 + 0 + RECDTB-FILE + + + sequential + basic + 67108864 + 0 + 0x8 + 0 + ESP_FILE + C12A7328-F81F-11D2-BA4B-00A0C93EC93B + **Required.** EFI system partition with L4T Launcher. + + + sequential + basic + RECSIZE + 0 + 8 + 0 + + + sequential + basic + 524288 + 0 + 8 + 0 + + + sequential + basic + 67108864 + 0 + 0x8 + 0 + **Required.** EFI system partition for fail-safe ESP update. + + + sequential + basic + 922222592 + 0 + 8 + 0 + **Required.** Reserve space in case there is any partition change + required in the future, for example, adding new partitions or increasing size + of some partitions. + + + sequential + basic + APPSIZE + 0 + 0x8 + 16384 + 0 + APPUUID + APPFILE + **Required.** Contains the rootfs. This partition must be assigned + the "1" for id as it is physically put to the end of the device, so that it + can be accessed as the fixed known special device `/dev/mmcblk0p1`. + + + sequential + basic + APPSIZE + 0 + 0x8 + 16384 + 0 + APPUUID_b + APPFILE_b + **Required.** Contains the rootfs. This partition must be defined + after `primary_GPT` so that it can be accessed as the fixed known special device + `/dev/mmcblk0p2`. + + + sequential + basic + 18432 + 0 + 0x808 + DATAFILE + 0 + **Required.** Automatically takes all remaining space on the device except that + occupied by the `secondary_gpt` partition. Allocation attribute must be set to 0x808. + May be mounted and used to store user data. + + + sequential + basic + 0xFFFFFFFFFFFFFFFF + 0 + 8 + 0 + + + diff --git a/meta-mender-tegra/recipes-bsp/tegra-binaries/redundant-boot-overrides_%.bbappend b/meta-mender-tegra/recipes-bsp/tegra-binaries/redundant-boot-overrides_%.bbappend index 136a46673..6870ae935 100644 --- a/meta-mender-tegra/recipes-bsp/tegra-binaries/redundant-boot-overrides_%.bbappend +++ b/meta-mender-tegra/recipes-bsp/tegra-binaries/redundant-boot-overrides_%.bbappend @@ -1,2 +1,2 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/${BPN}:" -RDEPENDS:${PN} += "tegra-redundant-boot-nvbootctrl" +# RDEPENDS:${PN} += "tegra-redundant-boot-nvbootctrl" diff --git a/meta-mender-tegra/recipes-bsp/tegra-binaries/tegra-redundant-boot_%.bbappend b/meta-mender-tegra/recipes-bsp/tegra-binaries/tegra-redundant-boot_%.bbappend index 7dd1c2f82..924af6d77 100644 --- a/meta-mender-tegra/recipes-bsp/tegra-binaries/tegra-redundant-boot_%.bbappend +++ b/meta-mender-tegra/recipes-bsp/tegra-binaries/tegra-redundant-boot_%.bbappend @@ -1,4 +1,5 @@ EXTRADEPS = "redundant-boot-overrides" EXTRADEPS:tegra210 = "" +EXTRADEPS:tegra234 = "" RDEPENDS:${PN} += "${EXTRADEPS}" diff --git a/meta-mender-tegra/recipes-bsp/tegra-bup-payload/tegra-bup-payload_%.bbappend b/meta-mender-tegra/recipes-bsp/tegra-bup-payload/tegra-bup-payload_%.bbappend index 7f0cd8e91..65421c273 100644 --- a/meta-mender-tegra/recipes-bsp/tegra-bup-payload/tegra-bup-payload_%.bbappend +++ b/meta-mender-tegra/recipes-bsp/tegra-bup-payload/tegra-bup-payload_%.bbappend @@ -1,2 +1,2 @@ RDEPENDS:${PN}:remove = "tegra-redundant-boot" -RDEPENDS:${PN}:append = " tegra-boot-tools-updater" +# RDEPENDS:${PN}:append = " tegra-boot-tools-updater" diff --git a/meta-mender-tegra/recipes-bsp/u-boot/libubootenv-fake_1.0.bb b/meta-mender-tegra/recipes-bsp/u-boot/libubootenv-fake_1.0.bb index adb6a9b33..9b8e488cd 100644 --- a/meta-mender-tegra/recipes-bsp/u-boot/libubootenv-fake_1.0.bb +++ b/meta-mender-tegra/recipes-bsp/u-boot/libubootenv-fake_1.0.bb @@ -23,5 +23,6 @@ PACKAGE_ARCH = "${MACHINE_ARCH}" RPROVIDES:${PN} += "libubootenv-bin u-boot-fw-utils" RDEPENDS:${PN} = "tegra-boot-tools" +RDEPENDS:${PN}:tegra234 = "" RCONFLICTS:${PN} = "libubootenv-bin" RREPLACES:${PN} = "libubootenv-bin" diff --git a/meta-mender-tegra/recipes-bsp/uefi/edk2-firmware-tegra_%.bbappend b/meta-mender-tegra/recipes-bsp/uefi/edk2-firmware-tegra_%.bbappend new file mode 100644 index 000000000..6ff39d1ea --- /dev/null +++ b/meta-mender-tegra/recipes-bsp/uefi/edk2-firmware-tegra_%.bbappend @@ -0,0 +1,7 @@ + +FILESEXTRAPATHS:prepend := "${THISDIR}/files:" + +SRC_URI += "file://0007-runtime-access-for-KernelCommandLine-efivar.patch;patchdir=.." +SRC_URI += "file://0008-enable-rootfs-redundancy.patch;patchdir=.." + + diff --git a/meta-mender-tegra/recipes-bsp/uefi/files/0007-runtime-access-for-KernelCommandLine-efivar.patch b/meta-mender-tegra/recipes-bsp/uefi/files/0007-runtime-access-for-KernelCommandLine-efivar.patch new file mode 100644 index 000000000..f41c26682 --- /dev/null +++ b/meta-mender-tegra/recipes-bsp/uefi/files/0007-runtime-access-for-KernelCommandLine-efivar.patch @@ -0,0 +1,39 @@ +diff --git edk2-tegra.a/edk2-nvidia/Silicon/NVIDIA/Drivers/NvidiaConfigDxe/NvidiaConfigDxe.c edk2-tegra.b/edk2-nvidia/Silicon/NVIDIA/Drivers/NvidiaConfigDxe/NvidiaConfigDxe.c +index 90e515ae..a00efb6c 100644 +--- edk2-tegra.a/edk2-nvidia/Silicon/NVIDIA/Drivers/NvidiaConfigDxe/NvidiaConfigDxe.c ++++ edk2-tegra.b/edk2-nvidia/Silicon/NVIDIA/Drivers/NvidiaConfigDxe/NvidiaConfigDxe.c +@@ -133,7 +133,7 @@ InitializeSettings ( + if (KernelCmdLineLen < sizeof (CmdLine)) { + KernelCmdLineLen = sizeof (CmdLine); + ZeroMem (&CmdLine, KernelCmdLineLen); +- Status = gRT->SetVariable (L"KernelCommandLine", &gNVIDIAPublicVariableGuid, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, KernelCmdLineLen, (VOID *)&CmdLine); ++ Status = gRT->SetVariable (L"KernelCommandLine", &gNVIDIAPublicVariableGuid, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, KernelCmdLineLen, (VOID *)&CmdLine); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Error setting command line variable %r\r\n", __FUNCTION__, Status)); + } +diff --git edk2-tegra.a/edk2-nvidia/Silicon/NVIDIA/Drivers/NvidiaConfigDxe/NvidiaConfigHii.vfr edk2-tegra.b/edk2-nvidia/Silicon/NVIDIA/Drivers/NvidiaConfigDxe/NvidiaConfigHii.vfr +index dbc26647..58c9aa91 100644 +--- edk2-tegra.a/edk2-nvidia/Silicon/NVIDIA/Drivers/NvidiaConfigDxe/NvidiaConfigHii.vfr ++++ edk2-tegra.b/edk2-nvidia/Silicon/NVIDIA/Drivers/NvidiaConfigDxe/NvidiaConfigHii.vfr +@@ -58,7 +58,7 @@ formset + guid = NVIDIA_TOKEN_SPACE_GUID; + + efivarstore NVIDIA_KERNEL_COMMAND_LINE, +- attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, // EFI variable attributes ++ attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS, // EFI variable attributes + name = KernelCommandLine, + guid = NVIDIA_PUBLIC_VARIABLE_GUID; + +diff --git edk2-tegra.a/edk2-nvidia/Silicon/NVIDIA/Library/PlatformBootManagerLib/PlatformBm.c edk2-tegra.b/edk2-nvidia/Silicon/NVIDIA/Library/PlatformBootManagerLib/PlatformBm.c +index a3fb49d6..f642b433 100644 +--- edk2-tegra.a/edk2-nvidia/Silicon/NVIDIA/Library/PlatformBootManagerLib/PlatformBm.c ++++ edk2-tegra.b/edk2-nvidia/Silicon/NVIDIA/Library/PlatformBootManagerLib/PlatformBm.c +@@ -1023,7 +1023,7 @@ IsPlatformConfigurationNeeded ( + AddlCmdLen = sizeof (AddlCmdLine); + Status = gRT->GetVariable (L"KernelCommandLine", &gNVIDIAPublicVariableGuid, &AddlCmdLineAttributes, &AddlCmdLen, &AddlCmdLine); + if (EFI_ERROR (Status)) { +- AddlCmdLineAttributes = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS; ++ AddlCmdLineAttributes = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS; + ZeroMem (&AddlCmdLine, sizeof (AddlCmdLine)); + } + diff --git a/meta-mender-tegra/recipes-bsp/uefi/files/0008-enable-rootfs-redundancy.patch b/meta-mender-tegra/recipes-bsp/uefi/files/0008-enable-rootfs-redundancy.patch new file mode 100644 index 000000000..556b92e12 --- /dev/null +++ b/meta-mender-tegra/recipes-bsp/uefi/files/0008-enable-rootfs-redundancy.patch @@ -0,0 +1,13 @@ +diff --git edk2-tegra.a/edk2-nvidia/Silicon/NVIDIA/Tegra/DeviceTree/L4TConfiguration.dts edk2-tegra.b/edk2-nvidia/Silicon/NVIDIA/Tegra/DeviceTree/L4TConfiguration.dts +index 2c619e21..b254ae76 100644 +--- edk2-tegra.a/edk2-nvidia/Silicon/NVIDIA/Tegra/DeviceTree/L4TConfiguration.dts ++++ edk2-tegra.b/edk2-nvidia/Silicon/NVIDIA/Tegra/DeviceTree/L4TConfiguration.dts +@@ -37,7 +37,7 @@ + locked; + }; + RootfsRedundancyLevel { +- data = [00 00 00 00]; ++ data = [01 00 00 00]; + runtime; + locked; + }; diff --git a/meta-mender-tegra/recipes-core/initrdscripts/tegra-minimal-init_%.bbappend b/meta-mender-tegra/recipes-core/initrdscripts/tegra-minimal-init_%.bbappend index 8046d1340..cb33efc35 100644 --- a/meta-mender-tegra/recipes-core/initrdscripts/tegra-minimal-init_%.bbappend +++ b/meta-mender-tegra/recipes-core/initrdscripts/tegra-minimal-init_%.bbappend @@ -3,4 +3,5 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/${BPN}:" EXTRADEPS = "" EXTRADEPS:tegra = "tegra-boot-tools-earlyboot" EXTRADEPS:tegra210 = "" +EXTRADEPS:tegra234 = "" RDEPENDS:${PN} += "${EXTRADEPS}" diff --git a/meta-mender-tegra/recipes-mender/mender-client/files/tegra234/efi_systemd_machine_id.sh b/meta-mender-tegra/recipes-mender/mender-client/files/tegra234/efi_systemd_machine_id.sh new file mode 100644 index 000000000..54f20acec --- /dev/null +++ b/meta-mender-tegra/recipes-mender/mender-client/files/tegra234/efi_systemd_machine_id.sh @@ -0,0 +1,128 @@ +#!/bin/sh + +function to_unicode() { + local in="$1" + local out + + for (( i=0; i<${#in}; i++)); do + char=${in:i:1} + out+="$char" + out+="\x00" + done + echo -n "$out" +} + + +function fill_to_size() { + local size="$2" + local out="$1" + local fill_size=$(( $size - (${#out}*2/5) )) + + for i in $(seq $fill_size) + do + out+="\x00" + done + + echo -n "$out" +} + + +function write_efivar() { + local readonly varname="781e084c-a330-417c-b678-38e696380cb9-KernelCommandLine" + local readonly total_size=514 + local readonly attr_size=4 + local readonly data_size=$(( $total_size - $attr_size)) + local in="$1" + + #printf "\nin=$in\n" + local out="$(to_unicode "$in")" + out="$(fill_to_size "$out" $data_size)" + + local f=$(mktemp) + printf "$out" > $f + efivar -n $varname -f $f -w + rm ${f} +} + +function read_efivar() { + local readonly varname="/sys/firmware/efi/efivars/KernelCommandLine-781e084c-a330-417c-b678-38e696380cb9" + local var=$(cat $varname | tail -c +4 | tr -d '[\000]') + + echo -n "$var" +} + + +function read_efi_machine_id() { + local var=$(read_efivar) + local id + + for i in $var; do + case $i in + systemd.machine_id=*) + id="${i#*=}" + ;; + *) + ;; + esac + done + echo -n "$id" +} + + +function write_efi_machine_id() { + local id="$1" + local var=$(read_efivar) + local out_var + local sep="" + local id_mod=false + + for i in $var; do + out_var+="$sep" + case $i in + systemd.machine_id=*) + out_var+="systemd.machine_id=$id" + id_mod=true + ;; + *) + out_var+="$i" + ;; + esac + sep=" " + done + + if [ "$id_mod" = false ] ; then + out_var+="${sep}systemd.machine_id=$id" + fi + + write_efivar "$out_var" +} + + +usage="Usage: efi_systemd_machine_id.sh [-r] [-w val]" + +while getopts "rw:" opt; do + case ${opt} in + r ) + printf "$(read_efi_machine_id)\n" + ;; + w ) + write_efi_machine_id $OPTARG + ;; + \? ) + echo "$usage";exit 2 + ;; + esac +done + + +if [ $OPTIND -eq 1 ]; then + echo "$usage"; exit 1 +fi + + + + + + + + diff --git a/meta-mender-tegra/recipes-mender/mender-client/files/tegra234/tegra234-mender-client-set-systemd-machine-id.sh b/meta-mender-tegra/recipes-mender/mender-client/files/tegra234/tegra234-mender-client-set-systemd-machine-id.sh new file mode 100644 index 000000000..841ab4fcb --- /dev/null +++ b/meta-mender-tegra/recipes-mender/mender-client/files/tegra234/tegra234-mender-client-set-systemd-machine-id.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +set -eu + +BOOTENV_PRINT="efi_systemd_machine_id.sh -r" +BOOTENV_SET="efi_systemd_machine_id.sh -w" + +CURRENT_BOOTLOADER_ID=$($BOOTENV_PRINT 2>/dev/null | cut -d= -f2) +CURRENT_SYSTEMD_ID=$(cat /etc/machine-id) + +rc=0 +if [ -z "${CURRENT_BOOTLOADER_ID}" ] && [ ! -z "${CURRENT_SYSTEMD_ID}" ]; then + $BOOTENV_SET "${CURRENT_SYSTEMD_ID}" + rc=$? +elif [ "${CURRENT_BOOTLOADER_ID}" != "${CURRENT_SYSTEMD_ID}" ]; then + echo "Error; bootloader and systemd disagree on machine-id." >&2 + rc=1 +fi + +exit $rc diff --git a/meta-mender-tegra/recipes-mender/mender-client/mender-client_%.bbappend b/meta-mender-tegra/recipes-mender/mender-client/mender-client_%.bbappend index d10ca62cf..a761e93e1 100644 --- a/meta-mender-tegra/recipes-mender/mender-client/mender-client_%.bbappend +++ b/meta-mender-tegra/recipes-mender/mender-client/mender-client_%.bbappend @@ -1,4 +1,21 @@ EXTRADEPS = "" EXTRADEPS:tegra = "tegra-bup-payload tegra-boot-tools tegra-boot-tools-nvbootctrl tegra-boot-tools-lateboot${@' libubootenv-fake' if d.getVar('PREFERRED_PROVIDER_virtual/bootloader').startswith('cboot') else ''}" EXTRADEPS:tegra210 = "tegra-bup-payload tegra-boot-tools" +EXTRADEPS:jetson-agx-orin-devkit = "tegra-bup-payload libubootenv-fake" RDEPENDS:${PN} += "${EXTRADEPS}" + +FILESEXTRAPATHS:prepend:tegra234 := "${THISDIR}/files/tegra234:" + +SRC_URI:remove:mender-persist-systemd-machine-id = " \ + file://mender-client-set-systemd-machine-id.sh \ +" +SRC_URI:append:tegra234:mender-persist-systemd-machine-id = " \ + file://tegra234-mender-client-set-systemd-machine-id.sh \ + file://efi_systemd_machine_id.sh \ +" + +do_install:prepend:tegra234:class-target:mender-persist-systemd-machine-id() { + install -d -m 755 ${D}${bindir} + install -m 755 ${WORKDIR}/efi_systemd_machine_id.sh ${D}${bindir}/ + cp ${WORKDIR}/tegra234-mender-client-set-systemd-machine-id.sh ${WORKDIR}/mender-client-set-systemd-machine-id.sh +} diff --git a/meta-mender-tegra/recipes-mender/tegra-state-scripts/files/switch-rootfs b/meta-mender-tegra/recipes-mender/tegra-state-scripts/files/switch-rootfs new file mode 100644 index 000000000..315fa4892 --- /dev/null +++ b/meta-mender-tegra/recipes-mender/tegra-state-scripts/files/switch-rootfs @@ -0,0 +1,26 @@ +#!/bin/sh +echo "$(mender show-artifact): $(basename "$0") was called!" >&2 + +get_bootpart() { + local current_slot=`nvbootctrl get-current-slot 2>/dev/null` + if [ -z "$current_slot" ]; then + echo "ERR: could not identify current boot slot" >&2 + echo "UNKNOWN" + return + fi + echo "$current_slot" +} + +current_slot=`get_bootpart` +echo "current_slot=$current_slot" >&2 + +next_slot= +if [ $current_slot = "0" ]; then + next_slot="1" +else + next_slot="0" +fi + +echo "next_slot=$next_slot" >&2 +nvbootctrl set-active-boot-slot $next_slot +exit 0 diff --git a/meta-mender-tegra/recipes-mender/tegra-state-scripts/tegra-state-scripts_1.0.bb b/meta-mender-tegra/recipes-mender/tegra-state-scripts/tegra-state-scripts_1.0.bb index ac3ea64ed..85bd8fc34 100644 --- a/meta-mender-tegra/recipes-mender/tegra-state-scripts/tegra-state-scripts_1.0.bb +++ b/meta-mender-tegra/recipes-mender/tegra-state-scripts/tegra-state-scripts_1.0.bb @@ -2,6 +2,7 @@ SRC_URI = " \ file://redundant-boot-commit-check-script-uboot \ file://redundant-boot-install-script \ file://redundant-boot-install-script-uboot \ + file://switch-rootfs \ " LICENSE = "Apache-2.0" @@ -43,6 +44,10 @@ 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 +} + # Make sure scripts aren't left around from old builds do_deploy:prepend() { rm -rf ${DEPLOYDIR}/mender-state-scripts