JetPack OTA Updates: Tips and Tricks

From RidgeRun Developer Connection
Jump to: navigation, search

Nvidia-preferred-partner-badge-rgb-for-screen.png

RR Contact Us.png

JetPack 4.6 introduced a very useful feature: Over-The-Air updates. OTA updates make it easier to update a Jetson target since most of the work is done on the host system. Also, the host and the target system do not need to be connected to complete the update.

There is a documentation available online for the default scenarios that use the stock Linux for Tegra sources from NVIDIA. However, as the use case becomes more specific, there appear more details that need to be considered for the update to be successful.

This wiki aims at documenting some of those specific details. To understand this wiki, consider the following setup:

  • Target platform: Jetson Xavier AGX.
  • Custom hardware: D3 16-channel board.
  • Custom kernel sources: XYZ Project
  • Continuous updates on top of the same release of Linux for Tegra
  • No network connection is available on the target platform.

General overview of the JetPack OTA update procedure

The OTA updates are comprised of three main steps:

  1. Generating the OTA Payload on the host. This step will take into consideration the custom hardware and kernel sources.
  2. Copying the OTA Payload onto the target. Usually, there is an OTA server available through the internet that can be used to download the payload, but it is also possible to use an external USB drive.
  3. Triggering the OTA update on the target.

Generate the OTA Payload on the Host

Setup the Environment

To simplify the commands used, set up the following variables according to your system.

  • JetPack related variables:
JETPACK=~/nvidia/nvidia_sdk
JETSON_L4T=${JETPACK}/JetPack_4.6_Linux_JETSON_AGX_XAVIER_TARGETS_XYZ/Linux_for_Tegra
TOOLCHAIN_DIR=gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu
CC_PREFIX=aarch64-linux-gnu-
CROSS_COMPILE=${JETPACK}/toolchain/${TOOLCHAIN_DIR}/bin/$CC_PREFIX
  • Kernel related variables
SOURCES_DIR=~/work/devdirs/client/xyz_project
KERNEL_DIR=kernel-4.9
KERNEL_OUT=${JETSON_L4T}/sources/kernel/${KERNEL_DIR}/build
KERNEL_MODULES_OUT=${JETSON_L4T}/sources/kernel/${KERNEL_DIR}/build/modules

Compile and Install the Kernel Sources

  • Create a symbolic link for the kernel sources inside Linux for Tegra:
cd $JETSON_L4T
ln -s $SOURCES_DIR sources
  • Compile the sources. Note that these are custom kernel sources for the custom hardware (D3's 16-channel board). Your use case might be different.
make -C sources/kernel/kernel-4.9/ ARCH=arm64 O=$KERNEL_OUT LOCALVERSION=-tegra CROSS_COMPILE=${CROSS_COMPILE} tegra_d3_16ch_defconfig
make -C sources/kernel/kernel-4.9/ ARCH=arm64 O=$KERNEL_OUT LOCALVERSION=-tegra CROSS_COMPILE=${CROSS_COMPILE} -j4
make -C sources/kernel/kernel-4.9/ ARCH=arm64 O=$KERNEL_OUT LOCALVERSION=-tegra CROSS_COMPILE=${CROSS_COMPILE} -j4 modules
make -C sources/kernel/kernel-4.9/ ARCH=arm64 O=$KERNEL_OUT LOCALVERSION=-tegra CROSS_COMPILE=${CROSS_COMPILE} INSTALL_MOD_PATH=$KERNEL_MODULES_OUT modules_install
  • Install the compiled sources into the Linux for Tegra directory. Note the custom DTB d3-xavier-16ch.dtb.
cd ${JETSON_L4T}
cp sources/kernel/kernel-4.9/build/arch/arm64/boot/dts/d3-xavier-16ch.dtb kernel/dtb/d3-xavier-16ch.dtb
cp sources/kernel/kernel-4.9/build/arch/arm64/boot/Image kernel/Image
sudo cp -r sources/kernel/kernel-4.9/build/modules/lib/* rootfs/lib/

Custom Hardware Specific Details

  • Open the Xavier configuration file:
sudo vim ${JETSON_L4T}/p2972-0000.conf.common
  • Look for the DTB_FILE parameter and change it to the correct one.
DTB_FILE=d3-xavier-16ch.dtb;
  • Also, it is possible to change the boot arguments here. For example, to add the Active Overlays of D3's 16-channel board.
CMDLINE_ADD="console=ttyTCU0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0 rootfstype=ext4 active_overlays=ar0820_0,ar0234_4";

Customize the Rootfs

You can add files to any directory in the rootfs. For example, NVIDIA binaries with fixes to known issues (camera ordering and timeouts), ISP configuration files...

  • To do so, prepare a directory that contains anything you would like to add under the rootfs.
$COPY_TO_ROOTFS/
├── usr
│   └── lib
│       └── aarch64-linux-gnu
│           ├── gstreamer-1.0
│           │   └── libgstnvarguscamerasrc.so
│           └── tegra
│               ├── libnvargus.so
│               ├── libnvargus_socketclient.so
│               └── libnvargus_socketserver.so
└── var
    └── nvidia
        └── nvcam
            └── settings
                └── camera_overrides.isp
  • Copy the contents into the rootfs directory.
sudo cp -r $COPY_TO_ROOTFS/* ${JETSON_L4T}/rootfs
  • You can also copy the OTA tools needed to trigger any future OTA update. You can download them here at the end of the page, under the "Tools" section.
OTA_TOOLS=~/Downloads/ota_tools_R32.6.1_aarch64.tbz2
sudo cp -r --preserve=mode,ownership $OTA_TOOLS $JETSON_L4T/rootfs/home/nvidia
  • You can do even more things here: move kernel modules around, install Python application programs, modify configuration files... Everything you add/remove to the rootfs directory will be reflected in the file system of the target, just keep in mind that permission and ownership must be preserved.

Create a Default User

To avoid the initial configuration wizard, it is possible to set up a default user and password for the installation.

  • To create a default user nvidia with password nvidia, run:
cd $JETSON_L4T
sudo ./tools/l4t_create_default_user.sh -u nvidia -p nvidia

Generate the OTA Payload

Download and Install the OTA Tools

  • Extract the contents:
OTA_TOOLS=~/Downloads/ota_tools_R32.6.1_aarch64.tbz2
OTA_TOOLS_DIR=~/Downloads/ota_tools_R32.6.1_aarch64
mkdir -p $OTA_TOOLS_DIR
sudo tar -xpf $OTA_TOOLS -C $OTA_TOOLS_DIR
  • Install the OTA Tools in the Linux for Tegra directory:
sudo cp -r --preserve=mode,ownership $OTA_TOOLS_DIR/Linux_for_Tegra/tools/ota_tools/version_upgrade/* $JETSON_L4T/tools/ota_tools/version_upgrade/

Disable Network Access Verification

By default, the NVIDIA OTA Tools will generate an OTA Payload that will require network access to finish the update. If the target is not connected to the network this will cause the OTA update process to fail. The target will be stuck in a loop that prevents it from booting up; you can see more information about it at Jetson AGX Xavier-OTA developer form Q&A's . To prevent this from happening, one of the scripts from the OTA tools must be hacked.

  • Open the script:
sudo vim $JETSON_L4T/tools/ota_tools/version_upgrade/nv_recovery.sh
  • Comment out the line that calls the reboot system function:
# Enable remote access through ssh
ota_log "enable_remote_access"
if ! enable_remote_access; then
       ota_log "Failed to run \"enable_remote_access\""
       # reboot_system <-- comment out this line to allow OTA update without network connection
fi

Generate the Payload

  • OTA updates can be used to update from different JetPack versions to the latest JetPack 4.6 and some variables are used to reflect this. OTA updates can also be used to update from JetPack 4.6 to JetPack 4.6, which is a much simpler case:
ToT_BSP=${JETSON_L4T}
BASE_BSP=${ToT_BSP}
TARGET_BSP=${ToT_BSP}
  • Run the following commands to generate the OTA Payload:
cd $JETSON_L4T
sudo ./tools/ota_tools/version_upgrade/build_base_recovery_image.sh jetson-agx-xavier-devkit R32-6 ${BASE_BSP} ${BASE_BSP}/rootfs ${TARGET_BSP} # Recovery image
sudo ./tools/ota_tools/version_upgrade/l4t_generate_ota_package.sh jetson-agx-xavier-devkit R32-6 # Payload

Copy the Payload onto the Target

For this use case, the OTA server is not accessible over a network. Instead, the OTA server is implemented as a removable drive, for example, a USB stick.

  • Identify the device:
# Before connecting the USB stick:
lsblk

# After connecting the USB stick:
lsblk

# Look for differences and identify the device. Use the size of the drive as a tell. 
  • Create a mountpoint for the drive and mount it:
USB=~/media/jmorua/upgrade
DEV=/dev/sdc1
sudo mkdir -p $USB
sudo mount $DEV $USB
  • Copy the Payload to the USB drive:
cp ${JETSON_L4T}/bootloader/jetson-agx-xavier-devkit/ota_payload_package.tar.gz $USB
  • Also copy the OTA tools because they will be needed in the target to trigger the update.
OTA_TOOLS=~/Downloads/ota_tools_R32.6.1_aarch64.tbz2
cp $OTA_TOOLS $USB
  • Finally unmount the USB drive:
sudo unmount $USB

Trigger the OTA Update on the Target

  • To do this, you will first need to have a Jetson platform already up and running. OTA updates cannot be used to flash the Xavier for the first time, instead, use the SDK Manager.
  • Follow the same procedure to connect and mount the USB drive:
# Before connecting the USB stick:
lsblk

# After connecting the USB stick:
lsblk

# Look for differences and identify the device. Use the size of the drive as a tell. 
  • Create some directories needed by the OTA process:
WORKDIR=~/workdir
OTADIR=/ota
sudo mkdir -p $WORKDIR $OTADIR
  • Copy the contents of the USB to the target:
sudo cp $USB/ota_tools_R32.6.1_aarch64.tbz2 $WORKDIR
sudo cp $USB/ota_payload_package.tar.gz $OTADIR
  • Trigger the OTA update:
cd ${WORKDIR}
sudo tar -xpf $WORKDIR/ota_tools_R32.6.1_aarch64.tbz2
cd ${WORKDIR}/Linux_for_Tegra/tools/ota_tools/version_upgrade
sudo ./nv_ota_start.sh /dev/mmcblk0 ${OTADIR}/ota_payload_package.tar.gz
  • Wait for it to finish. A message will appear to notify you that the update will be finished when the system is rebooted.
Rootfs is to be updated in the recovery kernel once the device is rebooted.
  • Reboot the system:
sudo reboot

References


RidgeRun Resources

Quick Start Client Engagement Process RidgeRun Blog Homepage
Technical and Sales Support RidgeRun Online Store RidgeRun Videos Contact Us

OOjs UI icon message-progressive.svg Contact Us

Visit our Main Website for the RidgeRun Products and Online Store. RidgeRun Engineering informations are available in RidgeRun Professional Services, RidgeRun Subscription Model and Client Engagement Process wiki pages. Please email to support@ridgerun.com for technical questions and contactus@ridgerun.com for other queries. Contact details for sponsoring the RidgeRun GStreamer projects are available in Sponsor Projects page. Ridgerun-logo.svg
RR Contact Us.png