NVIDIA Jetson Orin - JetPack 5.0.2 - Building the Kernel, Modules and DTBs

From RidgeRun Developer Wiki



Follow Us On Twitter LinkedIn Email Share this page


Previous: JetPack_5.0.2/Compiling_Code/Obtaining_Sources Index Next: JetPack_5.0.2/Flashing_Board








Once the kernel sources have been obtained, the next step is to configure and compile the kernel, kernel modules, and device tree blobs (DTBs). This process ensures that the build artifacts match the JetPack 5.0.2 release.

Installing the Toolchain

Jetson kernels are built on the host PC using cross-compilation. For JetPack 5.0.2, NVIDIA recommends the Bootlin GCC 9.3 toolchain for AArch64.

  1. Download and install the toolchain:
    cd ~/Downloads
    wget https://developer.nvidia.com/embedded/jetson-linux/bootlin-toolchain-gcc-93
    mkdir -p $HOME/l4t-gcc
    tar -xvf bootlin-toolchain-gcc-93 -C $HOME/l4t-gcc --strip-components=1
  2. Add the toolchain to your PATH:
    export PATH=$PATH:$HOME/l4t-gcc/bin

Env setup

Export the required environment variables so that the build process knows where the sources, toolchain, and outputs are located.

# Define the location of the sources directory
export DEVDIR=$HOME/nvidia/nvidia_sdk/JetPack_5.0.2_Linux_JETSON_AGX_ORIN_TARGETS/Linux_for_Tegra/sources

# Define the cross-compiler
export CROSS_COMPILE=$HOME/l4t-gcc/bin/aarch64-buildroot-linux-gnu-

# Define the output directory for the compiled kernel
export TEGRA_KERNEL_OUT=$HOME/nvidia/nvidia_sdk/JetPack_5.0.2_Linux_JETSON_AGX_ORIN_TARGETS/kernel-5.10_out

# Define the rootfs path where modules will be installed
export TEGRA_MODULES_OUT=$HOME/nvidia/nvidia_sdk/JetPack_5.0.2_Linux_JETSON_AGX_ORIN_TARGETS/Linux_for_Tegra/rootfs

# Define architecture and kernel suffix
export ARCH=arm64
export LOCALVERSION=-tegra

Building

  1. Run the default NVIDIA kernel configuration:
    make -C $DEVDIR/kernel/kernel-5.10/ ARCH=$ARCH O=$TEGRA_KERNEL_OUT tegra_defconfig
  2. Compile the kernel image:
    make -C $DEVDIR/kernel/kernel-5.10/ ARCH=$ARCH O=$TEGRA_KERNEL_OUT -j$(nproc)
  3. Build the Device Tree Blobs (DTBs):
    make -C $DEVDIR/kernel/kernel-5.10/ ARCH=$ARCH O=$TEGRA_KERNEL_OUT dtbs
  4. Build the kernel modules:
    make -C $DEVDIR/kernel/kernel-5.10/ ARCH=$ARCH O=$TEGRA_KERNEL_OUT modules
  5. Install the kernel modules into the target rootfs:
    sudo make -C $DEVDIR/kernel/kernel-5.10/ ARCH=$ARCH O=$TEGRA_KERNEL_OUT \
        INSTALL_MOD_PATH=$TEGRA_MODULES_OUT modules_install LOCALVERSION=$LOCALVERSION

After completing these steps, the following outputs will be available:

  • The kernel image (Image) under $TEGRA_KERNEL_OUT/arch/arm64/boot/.
  • The compiled device tree blobs under $TEGRA_KERNEL_OUT/arch/arm64/boot/dts/nvidia/.
  • The kernel modules installed into the target rootfs under $TEGRA_MODULES_OUT/lib/modules/.

Deploying

  1. Backup the binaries that come installed by default in JetPack:
    BKUP_DATE=`date "+%Y_%m_%d_%H_%M_%S"`
    mv $JETPACK/kernel/Image{,.$BKUP_DATE}  
    mv $JETPACK/kernel/kernel_supplements.tbz2{,.$BKUP_DATE}
    mv $JETPACK/kernel/dtb{,.$BKUP_DATE}
  2. Copy the new kernel and DTBs to the expected locations:
    cd $TEGRA_KERNEL_OUT
    cp ./arch/arm64/boot/Image $JETPACK/kernel/
    cp -r ./arch/arm64/boot/dts $JETPACK/kernel/dtb
  3. Update the kernel supplements archive with the rebuilt modules:
    cd $TEGRA_MODULES_OUT
    tar --owner root --group root -cjf $JETPACK/kernel/kernel_supplements.tbz2 lib/modules

At this point, the $JETPACK/kernel/ directory contains:

  • The new kernel image (Image).
  • The new device tree blobs (dtb/).
  • An updated kernel_supplements.tbz2 archive with the rebuilt modules.

These files will be automatically included the next time you flash the device with flash.sh or SDK Manager.

Known issues

We found the following errors during the BSP build using JetPack 5.0-DP and 5.0.1-DP:

Missing osi_core.h

Error message:

fatal error: osi_core.h: No such file or directory

Fix:

ln -s ${JETPACK}/sources/kernel/nvethernetrm \
      ${JETPACK}/sources/kernel/nvidia/drivers/net/ethernet/nvidia/nvethernet

Missing dtsi file

Error message:

fatal error: t234-common-cvm/tegra234-cvm-p3701.dtsi: No such file or directory

Fix:

mkdir $JETPACK/sources/hardware/nvidia/platform/t23x/common/kernel-dts
mv $JETPACK/sources/hardware/nvidia/platform/t23x/common/t234* \
   $JETPACK/sources/hardware/nvidia/platform/t23x/common/kernel-dts



Previous: JetPack_5.0.2/Compiling_Code/Obtaining_Sources Index Next: JetPack_5.0.2/Flashing_Board