NVIDIA Jetson Orin - Compiling Source Code

From RidgeRun Developer Wiki


Previous: JetPack 5.0‎.2/Getting_Started/Components Index Next: JetPack_5.0.2/Flashing_Board









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 5.0.2 for Orin AGX installed on your host computer, we assume that you got this installed following through our Getting Started and Installing Jetpack sections.

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 5.0.2 DP sources by doing the following:

1. Go to Jetson Linux Archive and download the source files for your release. Important: Consider that JetPack-5.0.2 requires L4T-35.1, JetPack-5.1.2 requires L4T-35.4.1 and so on, you can check the JetPack/L4T correlation at JetPack-Archive. For this example we use the L4T-35.1 BSP

2. Extract the .tbz2 file:

tar -xjf public_sources.tbz2

3. Extract the kernel source file:

cd Linux_for_Tegra/source/public
JETSON_SOURCES=$PWD
tar -xjf kernel_src.tbz2

This extracts the kernel source to the kernel/ subdirectory.

Kernel build instructions

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

Install the Toolchain

  • First, download the Bootlin toolchain binaries] from the NVIDIA Jetson Linux home page.
  • Important same as for the BSP version, the L4T version is important, for JetPack-5.0.2 we use L4T-35.1, building L4T-35.1 with much newer compilers may cause issues, for example building JetPack-5.1.2 with l4t-gcc from L4T-36.3, causes builds to fail. For this example we download the Bootlin Toolchain gcc from L4T-35.1.
Go to the bottom of the page and click on the Bootlin Toolchain gcc option as shown in the image below:




After that do:

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

Build the kernel

  • Establish the building paths and create directories:
KERNEL_OUT=$JETSON_SOURCES/kernel_out
MODULES_OUT=$JETSON_SOURCES/modules_out
mkdir -p $KERNEL_OUT
mkdir -p $MODULES_OUT
  • Use the following command to install dependencies on Ubuntu:
sudo apt install libncurses-dev
  • Export environment variables:
export CROSS_COMPILE_AARCH64_PATH=$HOME/l4t-gcc
export CROSS_COMPILE_AARCH64=$HOME/l4t-gcc/bin/aarch64-buildroot-linux-gnu-
  • Compile kernel:
cd $JETSON_SOURCES
./nvbuild.sh -o $KERNEL_OUT
  • Install the modules
make -C $JETSON_SOURCES/kernel/kernel-5.10/ ARCH=arm64 O=$KERNEL_OUT LOCALVERSION=-tegra INSTALL_MOD_PATH=$MODULES_OUT modules_install



Previous: JetPack 5.0‎.2/Getting_Started/Components Index Next: JetPack_5.0.2/Flashing_Board