Compiling Jetson TX2 source code L4T 32.3.1: Difference between revisions

From RidgeRun Developer Wiki
(Created page with "= 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 Te...")
 
mNo edit summary
 
(19 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= Introduction =
<seo title="Compiling Tegra Source Code | Compiling Jetson TX2 source code L4T 32.3.1 | RidgeRun" titlemode="replace" keywords="GStreamer, Linux SDK, Linux BSP,  Embedded Linux, Device Drivers, NVIDIA, Xilinx, TI, NXP, Freescale, Embedded Linux driver development, Linux Software development, Embedded Linux SDK, Embedded Linux Application development, GStreamer Multimedia Framework,Jetson TX2 source code, L4T 32.3.1, Tegra Source Code, L4T 32.3, Jetson, Nvidia Jetson, Tegra, Nvidia Tegra, Jetson TX1, Tegra TX1, Tegra TX2"  description="Learn about compiling Tegra source code L4T 32.3.1 for Jetson TX1 and TX2 at RidgeRun Developer."></seo>
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.


L4T 32.3.1 is used by JetPack 4.3 (You can get more information from [https://developer.nvidia.com/embedded/jetpack-archive jetpack-archive]).
<table>
<tr>
<td><div class="clear; float:right">__TOC__</div></td>
<td>
{{NVIDIA Preferred Partner logo}}
<td>
<center>
{{ContactUs Button}}
</center>
</tr>
</table>


= Build kernel =
== 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: [https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-3231/index.html NVIDIA Tegra Linux Driver Package Development Guide 32.3.1 release].
 
L4T 32.3.1 is used by [https://developer.nvidia.com/embedded/jetpack JetPack 4.3].
 
== Build NVIDIA Jetson TX2 kernel source code ==


'''1. Download and install the Toolchain'''
'''1. Download and install the Toolchain'''


NVIDIA recommends using the Linaro 7.3.1 2018.05 toolchain for L4T 32.3 ([https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-3231/index.html#page/Tegra%2520Linux%2520Driver%2520Package%2520Development%2520Guide%2Fxavier_toolchain.html%23 toolchain])
NVIDIA recommends using the Linaro 7.3.1 2018.05 toolchain for L4T 32.3 ([https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-3231/index.html#page/Tegra%2520Linux%2520Driver%2520Package%2520Development%2520Guide%2Fxavier_toolchain.html%23 Jetson Linux Driver PackageToolchain])


Download the pre-built toolchain binaries from: 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
Download the pre-built toolchain binaries: [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 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:


<syntaxhighlight lang="bash" style="background-color:cornsilk">
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
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
</syntaxhighlight>


Execute the following commands to extract the toolchain:
<syntaxhighlight lang="bash" style="background-color:cornsilk">
tar xf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz
</syntaxhighlight>


'''2. Download the kernel sources for L4T 32.3.1'''
'''2. Download the kernel sources for L4T 32.3.1'''
<syntaxhighlight lang="bash" style="background-color:cornsilk">
<syntaxhighlight lang="bash" style="background-color:cornsilk">
wget https://developer.download.nvidia.com/embedded/L4T/r32-3-1_Release_v1.0/Sources/T210/public_sources.tbz2
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
</syntaxhighlight>
</syntaxhighlight>


Line 25: Line 51:
tar -xvf public_sources.tbz2
tar -xvf public_sources.tbz2
cd Linux_for_Tegra/source/public
cd Linux_for_Tegra/source/public
JETSON_TX2_SOURCES=$(pwd)
JETSON_TX2_KERNEL_SOURCES=$(pwd)
tar -xf kernel_src.tbz2
tar -xf kernel_src.tbz2
</syntaxhighlight>
</syntaxhighlight>


Apply corresponding patches (if any) and follow to the next section.
'''3. Compile Jetson TX2 kernel and dtb ('''d'''evice '''t'''ree '''b'''lob)'''
<syntaxhighlight lang="bash" style="background-color:cornsilk">
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
</syntaxhighlight>
here you have to select the modules you want to compile, for example for libguvc something like this is required:


'''3. Compile kernel and dtb'''
<syntaxhighlight lang="bash" style="background-color:cornsilk">
-> Device Drivers
    -> USB support (USB_SUPPORT [=y])
        -> USB Gadget Support (USB_GADGET [=y])
            -> USB Gadget Drivers (<choice> [=m])
</syntaxhighlight>
 
Now compile the kernel image, dtbs and modules:


<syntaxhighlight lang="bash" style="background-color:cornsilk">
<syntaxhighlight lang="bash" style="background-color:cornsilk">
cd $JETSON_TX2_SOURCES/Linux_for_Tegra/source/public/
make -C kernel/kernel-4.9/ ARCH=arm64 O=$TEGRA_KERNEL_OUT LOCALVERSION=-tegra CROSS_COMPILE=${TOOLCHAIN_PREFIX} -j$(nproc) Image
CROSS_COMPILE=${HOME}/toolchain_bin_${VERSION}/${TOOLCHAIN_DIR}/bin/$CC_PREFIX
make -C kernel/kernel-4.9/ ARCH=arm64 O=$TEGRA_KERNEL_OUT LOCALVERSION=-tegra CROSS_COMPILE=${TOOLCHAIN_PREFIX} -j$(nproc) dtbs
KERNEL_OUT=$JETSON_TX2_SOURCES/Linux_for_Tegra/source/public/build
make -C kernel/kernel-4.9/ ARCH=arm64 O=$TEGRA_KERNEL_OUT LOCALVERSION=-tegra CROSS_COMPILE=${TOOLCHAIN_PREFIX} -j$(nproc) modules
KERNEL_MODULES_OUT=$JETSON_TX2_SOURCES/Linux_for_Tegra/source/public/modules
make -C kernel/kernel-4.9/ ARCH=arm64 O=$TEGRA_KERNEL_OUT LOCALVERSION=-tegra INSTALL_MOD_PATH=$KERNEL_MODULES_OUT modules_install
cd $JETSON_TX2_SOURCES/Linux_for_Tegra/source/public/
make -C kernel/kernel-4.9/ ARCH=arm64 O=$KERNEL_OUT tegra_defconfig
make -C kernel/kernel-4.9/ ARCH=arm64 O=$KERNEL_OUT menuconfig
</syntaxhighlight>
</syntaxhighlight>


'''Download and extract
== Install L4T 32.3.1 kernel image on the Jetson TX2 ==
== Set up helper environment variables ==
 
This guide assumes that the user already has sdk-manager installed. This link contains details about how to [https://docs.nvidia.com/sdk-manager/download-run-sdkm/index.html install]  NVIDIA [https://developer.nvidia.com/nvidia-sdk-manager SDK Manager].
 
NVIDIA_SDK_MANAGER contains the directory where NVIDIA SDK manager was installed. For example:
 
<syntaxhighlight lang="bash" style="background-color:cornsilk">
export NVIDIA_SDK_MANAGER=$HOME/nvidia/nvidia_sdk/
</syntaxhighlight>
 
Export the following variables:
 
<syntaxhighlight lang="bash" style="background-color:cornsilk">
JETPACK_4_3_P3310=${NVIDIA_SDK_MANAGER}/JetPack_4.3_Linux_P3310/Linux_for_Tegra/
</syntaxhighlight>
 
=== Copy kernel, device tree and modules into JetPack 4.3 ===
 
<syntaxhighlight lang="bash" style="background-color:cornsilk">
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/
</syntaxhighlight>
 
=== Flash the kernel and the DTB ===
 
For this it's required to use NVIDIA's script 'flash.sh':
 
<syntaxhighlight lang="bash" style="background-color:cornsilk">
sudo ./flash.sh -r -d kernel/dtb/tegra186-quill-p3310-1000-c03-00-base.dtb -K kernel/Image jetson-tx2 mmcblk0p1
</syntaxhighlight>
 
{{ContactUs}}
 
 
[[Category:Jetson]][[Category:JetsonNano]][[Category: JetsonTX2‏‎]][[Category:NVIDIA Xavier]]

Latest revision as of 04:03, 8 May 2024


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 information is available at RidgeRun Engineering Services, 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.