Compiling Jetson TX2 source code L4T 32.3.1

From RidgeRun Developer Wiki


Introduction

This wiki page contains instructions to download and build kernel source code for Jetson TX2, several parts of this wiki were based in the document: NVIDIA Tegra Linux Driver Package Development Guide 32.3.1 release.

L4T 32.3.1 is used by JetPack 4.3.

Build NVIDIA Jetson TX2 kernel source code

1. Download and install the Toolchain

NVIDIA recommends using the Linaro 7.3.1 2018.05 toolchain for L4T 32.3 (Jetson Linux Driver PackageToolchain)

Download the pre-built toolchain binaries: gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz and locate them under $HOME/l4t-gcc, or alternatively execute on console:

mkdir -p $HOME/l4t-gcc
cd $HOME/l4t-gcc
wget http://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz

Execute the following commands to extract the toolchain:

tar xf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz

2. Download the kernel sources for L4T 32.3.1

mkdir -p $HOME/l4t-sources/tx2/
cd $HOME/l4t-sources/tx2
wget https://developer.download.nvidia.com/embedded/L4T/r32-3-1_Release_v1.0/Sources/T186/public_sources.tbz2 # be sure to download the correct sources, since on JP4.3 the only changes are between nano-tx1/tx2-xavier

Execute the following commands to extract the kernel sources:

tar -xvf public_sources.tbz2
cd Linux_for_Tegra/source/public
JETSON_TX2_KERNEL_SOURCES=$(pwd)
tar -xf kernel_src.tbz2

Apply corresponding patches (if any) and follow to the next section.

3. Compile Jetson TX2 kernel and dtb (device tree blob)

cd $JETSON_TX2_KERNEL_SOURCES

TOOLCHAIN_PREFIX=$HOME/l4t-gcc/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
TEGRA_KERNEL_OUT=$JETSON_TX2_KERNEL_SOURCES/build
KERNEL_MODULES_OUT=$JETSON_TX2_KERNEL_SOURCES/modules

make -C kernel/kernel-4.9/ ARCH=arm64 O=$TEGRA_KERNEL_OUT LOCALVERSION=-tegra CROSS_COMPILE=${TOOLCHAIN_PREFIX} tegra_defconfig
make -C kernel/kernel-4.9/ ARCH=arm64 O=$TEGRA_KERNEL_OUT LOCALVERSION=-tegra CROSS_COMPILE=${TOOLCHAIN_PREFIX} menuconfig

here you have to select the modules you want to compile, for example for libguvc something like this is required:

 -> Device Drivers
    -> USB support (USB_SUPPORT [=y]) 
        -> USB Gadget Support (USB_GADGET [=y]) 
            -> USB Gadget Drivers (<choice> [=m])

Now compile the kernel image, dtbs and modules:

make -C kernel/kernel-4.9/ ARCH=arm64 O=$TEGRA_KERNEL_OUT LOCALVERSION=-tegra CROSS_COMPILE=${TOOLCHAIN_PREFIX} -j$(nproc) Image
make -C kernel/kernel-4.9/ ARCH=arm64 O=$TEGRA_KERNEL_OUT LOCALVERSION=-tegra CROSS_COMPILE=${TOOLCHAIN_PREFIX} -j$(nproc) dtbs
make -C kernel/kernel-4.9/ ARCH=arm64 O=$TEGRA_KERNEL_OUT LOCALVERSION=-tegra CROSS_COMPILE=${TOOLCHAIN_PREFIX} -j$(nproc) modules
make -C kernel/kernel-4.9/ ARCH=arm64 O=$TEGRA_KERNEL_OUT LOCALVERSION=-tegra INSTALL_MOD_PATH=$KERNEL_MODULES_OUT modules_install

Install L4T 32.3.1 kernel image on the Jetson TX2

This guide assumes that the user already has sdk-manager installed. This link contains details about how to install NVIDIA SDK Manager.

NVIDIA_SDK_MANAGER contains the directory where NVIDIA SDK manager was installed. For example:

export NVIDIA_SDK_MANAGER=$HOME/nvidia/nvidia_sdk/

Export the following variables:

JETPACK_4_3_P3310=${NVIDIA_SDK_MANAGER}/JetPack_4.3_Linux_P3310/Linux_for_Tegra/

Copy kernel, device tree and modules into JetPack 4.3

cd ${JETPACK_4_3_P3310}
# Copy kernel generated
cp -rfv $JETSON_TX2_KERNEL_SOURCES/build/arch/arm64/boot/Image kernel/
# Copy device tree generated
cp -rfv $JETSON_TX2_KERNEL_SOURCES/build/arch/arm64/boot/dts/tegra186-quill-p3310* kernel/dtb/
# Copy new modules
sudo cp -arfv $JETSON_TX2_KERNEL_SOURCES/modules/lib rootfs/

Flash the kernel and the DTB

For this it's required to use NVIDIA's script 'flash.sh':

sudo ./flash.sh -r -d kernel/dtb/tegra186-quill-p3310-1000-c03-00-base.dtb -K kernel/Image jetson-tx2 mmcblk0p1


RidgeRun Resources

Quick Start Client Engagement Process RidgeRun Blog Homepage
Technical and Sales Support RidgeRun Online Store RidgeRun Videos Contact Us
RidgeRun.ai: Artificial Intelligence | Generative AI | Machine Learning

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.