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...")
 
No edit summary
Line 10: Line 10:
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 toolchain])


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 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 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">
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/T210/public_sources.tbz2
wget https://developer.download.nvidia.com/embedded/L4T/r32-3-1_Release_v1.0/Sources/T210/public_sources.tbz2
</syntaxhighlight>
</syntaxhighlight>
Line 25: Line 37:
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>
Line 33: Line 45:


<syntaxhighlight lang="bash" style="background-color:cornsilk">
<syntaxhighlight lang="bash" style="background-color:cornsilk">
cd $JETSON_TX2_SOURCES/Linux_for_Tegra/source/public/
cd $JETSON_TX2_KERNEL_SOURCES
CROSS_COMPILE=${HOME}/toolchain_bin_${VERSION}/${TOOLCHAIN_DIR}/bin/$CC_PREFIX
 
KERNEL_OUT=$JETSON_TX2_SOURCES/Linux_for_Tegra/source/public/build
TOOLCHAIN_PREFIX=$HOME/l4t-gcc/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
KERNEL_MODULES_OUT=$JETSON_TX2_SOURCES/Linux_for_Tegra/source/public/modules
TEGRA_KERNEL_OUT=$JETSON_TX2_KERNEL_SOURCES/build
cd $JETSON_TX2_SOURCES/Linux_for_Tegra/source/public/
KERNEL_MODULES_OUT=$JETSON_TX2_KERNEL_SOURCES/modules
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
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>
</syntaxhighlight>


'''Download and extract
here you have to select:
== Set up helper environment variables ==
 
<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 images, dtbs and modules:
 
<syntaxhighlight lang="bash" style="background-color:cornsilk">
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
</syntaxhighlight>

Revision as of 22:47, 16 March 2020

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.

L4T 32.3.1 is used by JetPack 4.3 (You can get more information from jetpack-archive).

Build kernel

1. Download and install the Toolchain

NVIDIA recommends using the Linaro 7.3.1 2018.05 toolchain for L4T 32.3 (toolchain)

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 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/T210/public_sources.tbz2

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


3. Compile kernel and dtb

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:

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

Now compile the images, 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