JetPack 6 Compiling Source Code

From RidgeRun Developer Wiki




Learning to build the BSP and OS components enables developers to customize the software for their specific project needs.

This section will guide you through the process of building the BSP and OS components for the NVIDIA Jetson Orin. For this section you are going to need Jetpack 6 for Orin AGX installed on your host computer.

Assumptions

  1. The build of the BSP/OS components source code will be performed by cross-compiling on a host computer running a Linux OS.
  2. Make sure the following dependencies are installed on your system:
  • wget
  • lbzip2
  • build-essential
  • bc
  • zip
  • libgmp-dev
  • libmpfr-dev
  • libmpc-dev
  • vim-common # For xxd

In Debian-based systems you can run the following:

sudo apt install wget lbzip2 build-essential bc zip libgmp-dev libmpfr-dev libmpc-dev vim-common

Downloading and compiling

Download the JetPack sources

You can obtain the JetPack 6 sources by doing the following:

1. Go to https://developer.nvidia.com/embedded/jetson-linux-archive and download the source files for your release.

2. Extract the .tbz2 file:

mkdir ${HOME}/nvidia-jetson
tar xf Jetson_Linux_R36.0.0_aarch64.tbz2 -C ${HOME}/nvidia-jetson/
sudo tar xpf Tegra_Linux_Sample-Root-Filesystem_R36.0.0_aarch64.tbz2 -C \
${HOME}/nvidia-jetson/Linux_for_Tegra/rootfs
cd ${HOME}/nvidia-jetson/Linux_for_Tegra

3. Download sources:


cd ${HOME}/nvidia-jetson/Linux_for_Tegra
sudo ./apply_binaries.sh
./source_sync.sh -k -t rel-36_eng_2023-10-04

Kernel build instructions

Once the sources have been downloaded, perform the following steps to build.

Install the Toolchain

First, download the Bootlin toolchain binaries from the the bootlin page.

After that do:

mkdir $HOME/l4t-gcc
cd $HOME/l4t-gcc
tar xf <path_to_toolchain_archive>

Build the kernel and the out-of-tree drivers

1. Get the sources from downloading the tar files.

mkdir -p ${HOME}/nvidia-jetson/build
tar -xjf kernel_src.tbz2 -C ${HOME}/nvidia-jetson/build
tar -xjf kernel_oot_modules_src.tbz2 -C ${HOME}/nvidia-jetson/build
tar -xjf nvidia_kernel_display_driver_source.tbz2 -C
${HOME}/nvidia-jetson/build

2. Export the following variables on the command-line:

export KERNEL_HEADERS=${HOME}/nvidia-jetson/build/kernel/kernel-jammy-src
export CROSS_COMPILE_AARCH64=</path/to/aarch64-cross-compiler>

3. Copy over the Makefiles “Makefile.kernel_oot_modules_src” and “Makefile.kernel_src” using the commands below. These two makefiles should be part of the released items for this release.

cp Makefile.kernel_oot_modules_src ${HOME}/nvidia-jetson/build/Makefile
cp Makefile.kernel_src ${HOME}/nvidia-jetson/build/kernel/Makefile

4. Build

cd ${HOME}/nvidia-jetson/build
make -C kernel clean
make clean
make -C kernel
make modules

5. Install (Optional): If you plan to install the NVIDIA out-of-tree drivers to a rootfs directory, use the following steps:

export INSTALL_MOD_PATH=</path/to/rootfs>
sudo -E make -C kernel install
sudo -E make modules_install


Build NVIDIA out-of-tree drivers only

build NVIDIA out-of-tree drivers only - 1. Get the sources from the downloaded tar files.

mkdir -p ${HOME}/nvidia-jetson/build
tar -xjf kernel_oot_modules_src.tbz2 -C ${HOME}/nvidia-jetson/build
tar -xjf nvidia_kernel_display_driver_source.tbz2 -C
${HOME}/nvidia-jetson/build

2. Export the following variables on the command-line:

export KERNEL_HEADERS=</path/to/Linux/headers>
export CROSS_COMPILE_AARCH64=</path/to/aarch64-cross-compiler>

3. Copy over the makefile “Makefile.kernel_src” using the command below. This makefile should be part of the released items for this release.

cp Makefile.kernel_src ${HOME}/nvidia-jetson/build/kernel/Makefile

4. Build

cd ${HOME}/nvidia-jetson/build
make clean
make modules

5. Install (Optional): If you plan to install the NVIDIA out-of-tree drivers to a rootfs directory, use the following steps:

export INSTALL_MOD_PATH=</path/to/rootfs>
sudo -E make modules_install