Skip to content

Building Linux tegra 5.10.x from sources

Ilies CHERGUI edited this page Feb 26, 2023 · 3 revisions

Introduction

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

L4T R35.2.1 is used by JetPack 5.1

Build Kernel

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

1. Download and install the Toolchain

NVIDIA recommends using the Bootlin 9.3 toolchain for L4T R35.2.1

Download the pre-built toolchain binaries from this link Bootlin Toolchain gcc 9.3

or use the following command line:

$ wget https://developer.nvidia.com/embedded/jetson-linux/bootlin-toolchain-gcc-93 -O aarch64--glibc--stable-final.tar.gz
  • Extract the toolchain:
$ sudo mkdir /opt/gcc-bootlin-9.3.0 
$ sudo tar -C /opt/gcc-bootlin-9.3.0 -xf aarch64--glibc--stable-final.tar.gz

2. Download the Linux kernel sources

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

2.1. Using wget

$ wget https://github.com/OE4T/linux-tegra-5.10/archive/refs/heads/oe4t-patches-l4t-r35.2.1.zip

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

$ wget https://github.com/OE4T/linux-tegra-5.10/archive/refs/heads/oe4t-patches-l4t-r35.2.1.zip --no-check-certificate

2.2. Using git

$ git clone -b oe4t-patches-l4t-r35.2.1 https://github.com/OE4T/linux-tegra-5.10.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-bootlin-9.3.0/bin/aarch64-buildroot-linux-gnu-
$ export ARCH=arm64
$ export LOCALVERSION=-r35.2.1

Note: the last command export LOCALVERSION is optional.

$ cd linux-tegra-5.10
$ make O=$TEGRA_KERNEL_OUT mrproper
$ make O=$TEGRA_KERNEL_OUT tegra_defconfig 
$ make O=$TEGRA_KERNEL_OUT Image -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

Testing the compiled kernel

There are some strategies in https://github.com/OE4T/meta-tegra/discussions/997. TODO: Update this section (help/volunteers appreciated)