Skip to content

Building Linux tegra 4.9 from sources

Ilies CHERGUI edited this page Dec 18, 2022 · 1 revision

Introduction

This wiki page contains instructions to download and build kernel source code for Tegra, several parts of this wiki were based in the document: NVIDIA Jetson Linux Developer Guide 32.5 Release.

L4T 32.5 is used by JetPack 4.5.

Build Kernel

Please follow the instructions to build the kernel image and device tree.

1. Download and install the Toolchain

NVIDIA recommends using the Linaro 7.3.1 2018.05 toolchain for L4T 32.3.

Download the pre-built toolchain binaries from here

$ 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
  • Extract the toolchain:
$ sudo tar -C /opt -xf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz

2. Download the kernel sources

You can download the kernel sources via git or manually. It is recommended to use git.

2.1. Manually via wget

$ wget https://github.com/OE4T/linux-tegra-4.9/archive/oe4t-patches-l4t-r32.5.zip

If you get an issue, try with the following command:

$ wget https://github.com/OE4T/linux-tegra-4.9/archive/oe4t-patches-l4t-r32.5.zip --no-check-certificate

2.2. Using git

$ git clone -b oe4t-patches-l4t-r32.5 https://github.com/OE4T/linux-tegra-4.9.git

3. Compile kernel and dtb

Please follow these steps:

  • Set the shell variables and create the appropriate folders:
$ export TEGRA_KERNEL_OUT=`pwd`/images
$ export TEGRA_MODULES_OUT=`pwd`/modules
$ export TEGRA_HEADERS_OUT=`pwd`/headers
$ mkdir $TEGRA_KERNEL_OUT $TEGRA_MODULES_OUT $TEGRA_HEADERS_OUT   
  • If cross-compiling on a non-Jetson system, export the following environment variables:
$ export CROSS_COMPILE=/opt/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
$ export ARCH=arm64
$ export LOCALVERSION=-r32.5

Note: the last command export LOCALVERSION is optional.

$ cd linux-tegra-4.9
$ make O=$TEGRA_KERNEL_OUT mrproper
$ make O=$TEGRA_KERNEL_OUT tegra_defconfig 
$ make O=$TEGRA_KERNEL_OUT zImage -j$(nproc)
$ make O=$TEGRA_KERNEL_OUT dtbs -j$(nproc)
$ make O=$TEGRA_KERNEL_OUT modules -j$(nproc)
$ make O=$TEGRA_KERNEL_OUT modules_install INSTALL_MOD_PATH=$TEGRA_MODULES_OUT
$ make O=$TEGRA_KERNEL_OUT headers_install INSTALL_HDR_PATH=$TEGRA_HEADERS_OUT