Nvidia Jetson L4T Integration

Hi @lramirez

I have a question regarding the OTA update.
Following the above steps I encounter a small issue. Everything goes fine and there is a partition swap with all my data exchanged between partitions A and B after the artifact update but there is no system update. Before and after the update when I do cat / etc / nv_tegra_release I get the same 32.6.1 version. I wanted to update from version 32.6.1 to version 32.7.3

Here are all my steps that I followed through the installation process:

Install a fresh Jetpack Linux version on AGX that supports A/B update ( I used 32.6.1 ):

On Host computer:

Download version from here:

tar xpf Jetson_Linux_aarch64.tbz2
cd ./Linux_for_Tegra/rootfs
sudo tar -jxpf …/…/Tegra-Linux-Sample-Root-Filesystem
<release_type>.tbz2
cd …/…
tar xpf ./ota_tools_aarch64.tbz2
tar xpf ./secureboot
_aarch64.tbz2
cd Linux_for_Tegra

Check the Sector size and No. of sectors of the hard drive you want to flash:
sector size: cat /sys/block/nvme0n1/queue/hw_sector_size
num_sectors: cat /sys/block/nvme0n1/size
In the Linux_for_Tegra/tools/kernel_flash/flash_l4t_nvme_rootfs_ab.xml <device type="nvme" instance="0" sector_size="512" num_sectors="1000215216">

sudo ./apply_binaries.sh

sudo ROOTFS_AB=1 ./tools/kernel_flash/l4t_initrd_flash.sh --external-device nvme0n1 -c ./tools/kernel_flash/flash_l4t_nvme_rootfs_ab.xml --external-only -S 32GiB --showlogs jetson-agx-xavier-devkit external

On Jetson AGX Xavier:
sudo mkfs.ext4 /dev/nvme0n1p12

sudo mkdir -p /data
sudo su -c “echo ‘/dev/nvme0n1p12 /data ext4 defaults 0 0’ >> /etc/fstab”
sudo mount -a

sudo apt update && sudo apt upgrade
sudo apt install curl
sudo apt install nano

curl -fLsS https://get.mender.io -o get-mender.sh
sudo bash get-mender.sh mender-client

configure mender client → hosted mender server credentials.

sudo mv /var/lib/mender /data
sudo ln -s /data/mender /var/lib/mender
sudo mkdir -p /usr/share/mender/modules/v3
sudo touch /usr/share/mender/modules/v3/rootfs-image-jetson
cd /usr/share/mender/modules/v3
sudo nano rootfs-image-jetson

#!/bin/sh

set -ue

STATE="$1"
FILES="$2"

ota_payload_package="$FILES"/files/ota_payload_package.tar.gz
nvidia_tools="$FILES"/files/ota_tools_aarch64.tbz2

# Nvidia uses the concept of "slots", they will
# be always 0 and 1 values for A and B partitions

MENDER_ROOTFS_PART_A_NUMBER="0"
MENDER_ROOTFS_PART_B_NUMBER="1"

# Some useful information for integrity check
mkdir -p "/data/fs_update/"
mender_boot_part="/data/fs_update/mender_boot_part"
active_num="$(nvbootctrl get-current-slot)"

if test $active_num -eq $MENDER_ROOTFS_PART_A_NUMBER; then
    passive_num=$MENDER_ROOTFS_PART_B_NUMBER
else
    passive_num=$MENDER_ROOTFS_PART_A_NUMBER
fi

case "$STATE" in
      Download)
        if [ "$(nvbootctrl get-number-slots)" != "2" ]; then
            echo "Your device need to be configured to use A/B partitioning"
            exit 1
        fi
        ;;

    ArtifactInstall)
        # Let's record what slot we expect to boot next time
        echo $passive_num > $mender_boot_part
        # Let's enable Nvidia's scripts
        mkdir -p "$HOME"/workdir
        export WORKDIR="$HOME"/workdir
        tar -jxvf $nvidia_tools -C $WORKDIR
        # UDA partition as temp location disabled initially
        UDA=""
        # If you have a big enough UDA partition or a small rootfs
        # partition size, uncomment the following line  
        #UDA="data/"
        # Let's move the payload
        mkdir -p "/${UDA}ota/"
        mv $ota_payload_package "/${UDA}ota/"
        mkdir -p "/${UDA}ota_work"
        if [ ! -z "$UDA" ]
        then
            ln -sfn "/${UDA}ota_work" "/ota_work"
        fi
        # Let's run the upgrade process
        cd ${WORKDIR}/Linux_for_Tegra/tools/ota_tools/version_upgrade
        ./nv_ota_start.sh /dev/nvme0n1 "/${UDA}ota/ota_payload_package.tar.gz"
        # nv_ota_start.sh set the unused slot to active for next reboot
        >&2 echo "Next boot will load Slot $passive_num" 
        #cleaning up the disk
        if [ ! -z "$UDA" ]; then
            rm -rf "/${UDA}ota_work"
            rm -rf "/${UDA}ota/"
        fi   
        ;;

    PerformsFullUpdate)
        echo "Yes"
        ;;

    NeedsArtifactReboot)
        echo "Automatic"
        ;;

    SupportsRollback)
        echo "Yes"
        ;;

    ArtifactVerifyReboot)
        # We use stderr for logging as Mender protocol uses stdout for exchanging messages with the server.
        >&2 echo "ArtifactVerifyReboot: The active partition is $active_num while the last passive was $(cat $mender_boot_part)"
        if test "$(cat $mender_boot_part)" != "$active_num"; then
            exit 1
        fi
        # Recommend calling sync at the end here as well
        sync
        ;;

    ArtifactVerifyRollbackReboot)
        >&2 echo "ArtifactVerifyRollbackReboot: The active partition is $active_num while the last passive was $(cat $mender_boot_part)"
        if test "$(cat $mender_boot_part)" = "$active_num"; then
            exit 1
        fi
        # Recommend calling sync at the end here as well
        sync
        ;;

    ArtifactCommit)
        >&2 echo "ArtifactCommit: The active partition is $active_num while the last passive was $(cat $mender_boot_part)"
        if test "$(cat $mender_boot_part)" = "$active_num"; then
            nvbootctrl mark-boot-successful
        else
            # If we get here, an upgrade in standalone mode failed to  
            # boot and the user is trying to commit from the old OS.
            # This communicates to the user that the upgrade failed.
            echo "Upgrade failed and was reverted: refusing to commit!"
            exit 1
        fi
        ;;

    ArtifactRollback)
        >&2 echo "ArtifactRollback: The active partition is $active_num while the last passive was $(cat $mender_boot_part)"
        if test "$(cat $mender_boot_part)" = "$active_num"; then
            nvbootctrl set-active-boot-slot $passive_num
        fi
        sync
        ;;

esac
exit 0

a small note-----> I replaced in this part of the script the internal with my external drive: ./nv_ota_start.sh /dev/nvme0n1 "/${UDA}ota/ota_payload_package.tar.gz"

sudo chmod +x /usr/share/mender/modules/v3/rootfs-image-jetson
sudo systemctl restart mender-client

sudo su
sudo mender snapshot dump | ssh $USER@$HOST /bin/sh -c ‘cat > $HOME/my-jetson-fs.raw’

on Host computer:

New Jetpack version ( I used 32.7.3 ):

tar xpf Jetson_Linux_aarch64.tbz2
cd ./Linux_for_Tegra/rootfs
sudo tar -jxpf …/…/Tegra-Linux-Sample-Root-Filesystem
<release_type>.tbz2
cd …/…
tar xpf ./ota_tools__aarch64.tbz2
cd Linux_for_Tegra

BASE_BSP=/tmp/Jetpack_Linux/32_6_1/Linux_for_Tegra
TARGET_BSP=/tmp/Jetpack_Linux/32_7_3/Linux_for_Tegra

check:
echo $TARGET_BSP
echo $BASE_BSP

sudo ./tools/ota_tools/version_upgrade/build_base_recovery_image.sh jetson-agx-xavier-devkit R32-6 ${BASE_BSP} ${BASE_BSP}/rootfs ${TARGET_BSP}

go to the Mender snapshot file and run this commands to mount it as a filesystem image:
mkdir -p tmp-fs
sudo mount -o loop my-jetson-fs.raw tmp-fs
cd tmp-fs
sudo tar -cvpzf …/image_fs.tar.gz --exclude=./data --exclude=./image_fs.tar.gz --one-file-system ./
cd …

cp tools/ota_tools/version_upgrade/nv_ota_rootfs_updater.sh rootfs_updater.sh
sudo ./tools/ota_tools/version_upgrade/l4t_generate_ota_package.sh -sr -o rootfs_updater.sh -f /home/petar/jetson/image_fs.tar.gz jetson-agx-xavier-devkit R32-6

Create Mender Arthefact:
ARTIFACT_NAME=“R37_2_3_update”
DEVICE_TYPE=“jetson-agx-xavier”
OUTPUT_PATH=“/home/petar/R37_2_3_update.mender”
IMAGE=“/tmp/Jetpack_Linux/32_7_3/Linux_for_Tegra/bootloader/jetson-agx-xavier-devkit/ota_payload_package.tar.gz”
OTA_TOOLS=“/tmp/Jetpack_Linux/32_7_3/ota_tools_aarch64.tbz2”
mender-artifact write module-image -T rootfs-image-jetson -n ${ARTIFACT_NAME} -t ${DEVICE_TYPE} -o ${OUTPUT_PATH} -f ${IMAGE} -f ${OTA_TOOLS}

upload to mender server using GUI or CLI

check jetpack version:
cat / etc / nv_tegra_release

Hello @petarkalafatic,

Regarding the delta feature this is not possible. In another thread I shared a workaround and the technical challenge on why this is not possible. I hope it helps :slight_smile:

Hello @petarkalafatic,

Regarding the second question about not seeing the rootfs updated. Did you check with nvbootctrl that the device was able to actually perform the flip between slots? Can you check the inactive/passive slot to see if the content was copied as expected but the bootloader did not flip the partitions?

BR,
Luis