NVIDIA Jetson Orin NX- Compiling Source Code
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 NX. For this section you are going to need Jetpack 5.1.1 for Orin NX installed on your host computer, we assume that you got this installed following through our Getting Started and Flashing the board using GUI Installer sections.
Assumptions
- The build of the BSP/OS components source code will be performed by cross-compiling on a host computer running a Linux OS.
In Debian-based systems (Ubuntu like) you can run the following:
sudo apt update sudo apt install git \ wget \ quilt \ build-essential \ bc \ libncurses5-dev libncursesw5-dev \ rsync
Downloading and compiling
Download the JetPack sources
You can obtain the JetPack 5.1.1 DP sources by doing the following:
1. Go to https://developer.nvidia.com/embedded/jetson-linux-archive and download the source files for your release.
Get the source code from NVIDIA's official repository
cd wget https://developer.nvidia.com/downloads/embedded/l4t/r35_release_v3.1/sources/public_sources.tbz2/ -O public_sources.tbz2 tar -xjf public_sources.tbz2 Linux_for_Tegra/source/public/kernel_src.tbz2 --strip-components 3
This extracts the kernel source to the kernel/ subdirectory.
Export the Jetpack directory as the environment variable DEVDIR:
(In our case the nvidia directory is in the HOME directory, which in our case is /home/nvidia/ Remember that this directory is created by the sdk manager when you downloaded the sources and flashed your Jetson board).
export DEVDIR=~nvidia/nvidia/nvidia_sdk/JetPack_5.1.1_Linux_JETSON_NX_TARGETS/Linux_for_Tegra
And now create the sources directory and extract the kernel sources:
mkdir $DEVDIR/sources tar -xjf kernel_src.tbz2 -C $DEVDIR/sources
Kernel build instructions
Once the sources have been downloaded, perform the following steps in order to build.
Install the Toolchain
You will need to download the toolchain to compile the sources and extract it in a folder of preference. For this guide, we are going to use a new one called l4t-gcc:
mkdir $HOME/l4t-gcc cd $HOME/l4t-gcc wget -O toolchain.tar.xz https://developer.nvidia.com/embedded/jetson-linux/bootlin-toolchain-gcc-93 sudo tar -xf toolchain.tar.xz
Look at the wget command, we're using it to download the cross compiler using the link from the NVIDIA developer's dedicated webpage in the section "Downloads and Links" and into Tools category.
Build the kernel
- Establish the building paths and create output directories:
KERNEL_OUT=$DEVDIR/sources/kernel_out MODULES_OUT=$DEVDIR/sources/modules_out mkdir -p $KERNEL_OUT mkdir -p $MODULES_OUT
Export the cross compiler path:
export CROSS_COMPILE_AARCH64=$HOME/l4t-gcc/bin/aarch64-buildroot-linux-gnu-
Compile the kernel:
cd $DEVDIR/sources make -C kernel/kernel-5.10/ ARCH=arm64 O=$KERNEL_OUT LOCALVERSION=-tegra CROSS_COMPILE=${CROSS_COMPILE_AARCH64} tegra_defconfig make -C kernel/kernel-5.10/ ARCH=arm64 O=$KERNEL_OUT LOCALVERSION=-tegra CROSS_COMPILE=${CROSS_COMPILE_AARCH64} menuconfig make -C kernel/kernel-5.10/ ARCH=arm64 O=$KERNEL_OUT LOCALVERSION=-tegra CROSS_COMPILE=${CROSS_COMPILE_AARCH64} Image make -C kernel/kernel-5.10/ ARCH=arm64 O=$KERNEL_OUT LOCALVERSION=-tegra CROSS_COMPILE=${CROSS_COMPILE_AARCH64} dtbs make -C kernel/kernel-5.10/ ARCH=arm64 O=$KERNEL_OUT LOCALVERSION=-tegra CROSS_COMPILE=${CROSS_COMPILE_AARCH64} modules make -C kernel/kernel-5.10/ ARCH=arm64 O=$KERNEL_OUT LOCALVERSION=-tegra INSTALL_MOD_PATH=$MODULES_OUT modules_install