Customize JetPack Installation with OTA Update

From RidgeRun Developer Wiki

OTA update with debian packages

Over The Air (OTA) update is a software service available in recent JetPack releases (since release 4.3). This new feature allows to update the system software in the Jetson platforms through debian packages. One great advantage of this approach is that allows to update JetPack software without the need of a host PC, which proves really handy on production modules that tipically aren't too accesible for a software update. OTA is not limited to debian packages, APT repositories are just a way to implement it. The OTA concept is more general and spans to a new software methodology for distributing software across mobile and embedded devices.

NVIDIA releases several debian packages for each main component of the JetPack SDK, they are listed in the NVIDIA Jetson Linux Developer Guide. For instance, there is one debian package for GStreamer (nvidia-l4t-gstreamer), one for the compiled kernel and modules (nvidia-l4t-kernel), and so on. This wiki describes how to customize the default packages that NVIDIA provides. The instructions in this wiki can be used, for example, to update the Linux kernel Image (or modules) and/or the device tree blob (dtb).

Create custom debian packages

Note: To download and extract the debian packages you need to do a JetPack installation using the sdkmanager. Some packages are in <path-to-jetpack-install/Linux_for_Tegra/kernel> and others in <path-to-jetpack-install/Linux_for_Tegra/bootloader> .

nvidia-l4t-kernel

Note: The default package should be located in <path-to-jetpack-install/Linux_for_Tegra/kernel>

These instructions are a slightly modified version of this guide: NVIDIA Jetson Linux Developer Guide

1.Extract the original Debian package:

cd path-to-jetpack-install/Linux_for_Tegra/kernel
mkdir kernel-debian
dpkg -x nvidia-l4t-kernel_4.9.140-tegra-32.4.3-20200625213407_arm64.deb kernel-debian/origin
dpkg -e nvidia-l4t-kernel_4.9.140-tegra-32.4.3-20200625213407_arm64.deb kernel-debian/origin/debian
cd kernel-debian

2. Create a directory in which to build your customized Debian package, and in it, a subdirectory named debian for preparing metadata. The following instructions assume that directory is called repack.

mkdir -p repack/debian/

3. Create directories and metadata to build the debian package. After finishing the next steps the repack directory should look like:

repack/
└── debian
    ├── changelog
    ├── compat
    ├── control
    ├── copyright
    ├── install
    ├── out
    │   ├── boot
    │   ├── lib
    │   └── usr
    ├── postinst
    ├── rules
    ├── source
    │   └── format
    └── triggers

3.1 Create a repack/debian/rules text file in a text editor and add these lines; save the file.

#!/usr/bin/make -f
 
.PHONY: binary
 
clean:
		dh clean
 
binary:
		dh binary
 
build:
 
override_dh_strip:
override_dh_shlibdeps:

3.2 Create a repack/debian/control text file in a text editor and add these lines; save the file.

Source: nvidia-l4t-kernel
Section: kernel
Priority: standard
Maintainer: NVIDIA Corporation
Build-Depends: debhelper (>=9)
Standards-Version: 3.9.6
Homepage: http://developer.nvidia.com/jetson
 
Package: nvidia-l4t-kernel
Architecture: arm64
Pre-Depends: nvidia-l4t-core (>> 32.4-0), nvidia-l4t-core (<< 32.5-0)
Depends: 
Recommends: 
Description: NVIDIA Kernel Package

3.3 Copy these files from the original nvidia-l4t-kernel package to repack/debian directory

•postinst
•triggers
•copyright

cp origin/debian/postinst origin/debian/triggers origin/usr/share/doc/nvidia-l4t-kernel/copyright repack/debian/

3.4 Extract changelog from its archive. Take into account that if you change the version number of this package you may break dependencies of the packages: nvidia-l4t-kernel-headers, nvidia-l4t-kernel-dtbs, nvidia-l4t-jetson-io. One option is to update those packages with a new version dependency, another one is not changing the version number that the default package is released with.

gunzip -c origin/usr/share/doc/nvidia-l4t-kernel/changelog.Debian.gz > repack/debian/changelog

3.5 Create repack/debian/install text file in a text editor. Add the following line, which specifies the location where files are to be installed, then save the file:

debian/out/* /

3.6 Create repack/debian/compat text file and replace its contents with the single digit ‘9’; save the file.

3.7 Create a repack/debian/source/ directory.

mkdir -p repack/debian/source

3.8 Create a text file called repack/debian/source/format in a text editor, add the following line and save the file:

#Add the following line to repack/debian/source/format file
3.0 (native)

4. Create a directory that will contain the customized files that will be installed.

mkdir -p repack/debian/out/

5. Add in repack/debian/out/ directory your customizations by creating subdirectories and installing files as necessary. Add this point you can add a specific kernel module or patched kernel Image that will be installed. For example, if you want to update kernel Image, just overwrite the file at repack/debian/out/boot/Image. Follow the directory structure in the original nvidia-l4t-kernel package. In case of the kernel package this would be the kernel Image and modules:

boot/Image
lib/modules/<release>/kernel/
lib/modules/<release>/modules.*

6. Copy the kernel license file from the original Debian package:

mkdir -p repack/debian/out/usr/share/doc/nvidia-l4t-kernel/
gunzip -c origin/usr/share/doc/nvidia-l4t-kernel/LICENSE.kernel.gz > repack/debian/out/usr/share/doc/nvidia-l4t-kernel/LICENSE.kernel

7. Build the package

cd repack
export CC=aarch64-linux-gnu-gcc
dpkg-buildpackage -uc -b -d -a arm64
  • Note: The debian package will be created in the same directory where repack directory was created.
  • You can check the contents of the generated debian package with the following command:
dpkg -c nvidia-l4t-kernel_4.9.140-tegra-32.4.3-20200625213407_arm64.deb
  • To reinstall the package you can use the following command:
sudo apt-get install --reinstall ./nvidia-l4t-kernel_4.9.140-tegra-32.4.3-20200625213407_arm64.deb
  • Finally, reboot the TX2 board.

nvidia-l4t-kernel-dtbs

Note: The default package should be located in <path-to-jetpack-install/Linux_for_Tegra/kernel>

These instructions are a slightly modified version of this guide: NVIDIA Jetson Linux Developer Guide

1.Extract the original Debian package:

cd path-to-jetpack-install/Linux_for_Tegra/kernel
mkdir dtb-debian
dpkg -x nvidia-l4t-kernel-dtbs_4.9.140-tegra-32.4.3-20200625213407_arm64.deb dtb-debian/origin
dpkg -e nvidia-l4t-kernel-dtbs_4.9.140-tegra-32.4.3-20200625213407_arm64.deb dtb-debian/origin/debian
cd dtb-debian

2. Create a directory in which to build your customized Debian package, and in it, a subdirectory named debian for preparing metadata. The following instructions assume that directory is called repack.

mkdir -p repack/debian/

3. Create directories and metadata to build the debian package. After finishing the next steps the repack directory should look like:

repack/
└── debian
    ├── changelog
    ├── compat
    ├── control
    ├── install
    ├── out
    │   ├── boot
    │   └── usr
    ├── postinst
    ├── rules
    └── source
        └── format

3.1 Create a repack/debian/rules text file in a text editor and add these lines; save the file.

#!/usr/bin/make -f
 
.PHONY: binary
 
clean:
		dh clean
 
binary:
		dh binary
 
build:
 
override_dh_strip:
override_dh_shlibdeps:

3.2 Create a repack/debian/control text file in a text editor and add these lines; save the file.

Source: nvidia-l4t-kernel-dtbs
Section: kernel
Priority: standard
Maintainer: NVIDIA Corporation
Build-Depends: debhelper (>=9)
Standards-Version: 3.9.6
Homepage: http://developer.nvidia.com/jetson

Package: nvidia-l4t-kernel-dtbs
Architecture: arm64
Pre-Depends: nvidia-l4t-core (>> 32.4-0), nvidia-l4t-core (<< 32.5-0)
Depends: device-tree-compiler, nvidia-l4t-kernel (= 4.9.140-tegra-32.4.3-20200625213407)
Description: NVIDIA Kernel DTB Package

3.3 Copy this file from the original nvidia-l4t-kernel-dtbs package to repack/debian directory

cp origin/debian/postinst repack/debian/

3.4 Extract changelog from its archive.

gunzip -c origin/usr/share/doc/nvidia-l4t-kernel-dtbs/changelog.Debian.gz > repack/debian/changelog

3.5 Create repack/debian/install text file in a text editor. Add the following line, which specifies the location where files are to be installed, then save the file:

debian/out/* /

3.6 Create repack/debian/compat text file and replace its contents with the single digit ‘9’; save the file.

3.7 Create a repack/debian/source/ directory.

mkdir -p repack/debian/source

3.8 Create a text file called repack/debian/source/format in a text editor, add the following line and save the file:

#Add the following line to repack/debian/source/format file
3.0 (native)

4. Create a directory that will contain the customized files that will be installed.

mkdir -p repack/debian/out/

5. Add in repack/debian/out/ directory your customizations by creating subdirectories and installing files as necessary. Add this point you can add a customized device tree, for example, when you need to update device tree for TX2 camera/s, overwrite the file in repack/debian/out/boot/tegra186-quill-p3310-1000-c03-00-base.dtb. Follow the directory structure in the original nvidia-l4t-kernel-dtbs package. In case of the device tree package this would be the dtb files:

boot/*.dtb
usr/

6. Build the package

cd repack
export CC=aarch64-linux-gnu-gcc
dpkg-buildpackage -uc -b -d -a arm64
  • Note: The debian package will be created in the same directory where repack directory was created.
  • You can check the contents of the generated debian package with the following command:
dpkg -c nvidia-l4t-kernel-dtbs_4.9.140-tegra-32.4.3-20200625213407_arm64.deb
  • To reinstall the package you can use the following command:
sudo apt-get install --reinstall ./nvidia-l4t-kernel-dtbs_4.9.140-tegra-32.4.3-20200625213407_arm64.deb
  • Reinstalling the debian package will update the file in /boot/dtb/tegra186-quill-p3310-1000-c03-00-base.dtb , but in order for the new device tree to be loaded you need to edit the /boot/extlinux/extlinux.conf, add the following line:
#Add the following line to extlinux.conf

FDT /boot/dtb/tegra186-quill-p3310-1000-c03-00-base.dtb
  • After modifying the extlinux.conf file, it should look similar to this:
TIMEOUT 30
DEFAULT primary

MENU TITLE L4T boot options

LABEL primary
      MENU LABEL primary kernel
      LINUX /boot/Image
      INITRD /boot/initrd
      FDT /boot/dtb/tegra186-quill-p3310-1000-c03-00-base.dtb
      APPEND ${cbootargs} quiet root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0 isolcpus=1-2
  • Finally, reboot the TX2 board.

Known issues

Using a APP partition clone and OTA updates

It has been found that after restoring a system with a backup of the APP partition, as explained here for example, may not allow to change the kernel/dtb following the instructions for custom OTA updates. It may not be even possible to change the kernel/dtb by manually replacing /boot/Image file for the kernel Image and /boot/dtb/tegra186-quill-p3310-1000-c03-00-base.dtb plus the modifications in the /boot/extlinux/extlinux.conf for the device tree.

A workaround is to reinstall all the basic debian packages that NVIDIA provides, a complete list can be found here

sudo apt-get update
sudo apt-get install --reinstall nvidia-l4t-3d-core \
                                 nvidia-l4t-apt-source \
                                 nvidia-l4t-bootloader \
                                 nvidia-l4t-camera \
                                 nvidia-l4t-configs \
                                 nvidia-l4t-core \
                                 nvidia-l4t-cuda \
                                 nvidia-l4t-firmware \
                                 nvidia-l4t-graphics-demos \
                                 nvidia-l4t-gstreamer \
                                 nvidia-l4t-init \
                                 nvidia-l4t-initrd \
                                 nvidia-l4t-initrd \
                                 nvidia-l4t-jetson-io \
                                 nvidia-l4t-jetson-multimedia-api \
                                 nvidia-l4t-kernel \
                                 nvidia-l4t-kernel-dtbs \
                                 nvidia-l4t-kernel-headers \
                                 nvidia-l4t-multimedia \
                                 nvidia-l4t-multimedia-utils \
                                 nvidia-l4t-oem-config \
                                 nvidia-l4t-tools \
                                 nvidia-l4t-wayland \
                                 nvidia-l4t-weston \
                                 nvidia-l4t-x11 \
                                 nvidia-l4t-xusb-firmware

It could be possible that only the following debian package is required:

nvidia-l4t-bootloader

After reinstalling the NVIDIA debian packages, it should be possible to change the kernel/dtb with the custom OTA updates or by manual procedure.