Kernel Customization

You can manually rebuild the kernel used for the NVIDIA® Jetson™ Linux. You must have Internet access for this.

Prerequisites

  • You have installed Git. You can install with the following command:

    $ sudo apt install git-core
    
  • Your system has the default Git port 9418 open for outbound connections.

  • You have installed the Linux kernel build utilities. You can install with the following command:

    $ sudo apt install build-essential bc
    
  • You have installed the toolchain. See Jetson Linux Toolchain for information about how to download and install the reference toolchain.

Obtaining the Kernel Sources

You can obtain the Jetson Linux kernel sources in the following ways:

  • Sync the sources using Git.

  • download the kernel source files and manually extract them.

NVIDIA recommends that you sync with Git.

To Sync the Kernel Sources with Git

To get the kernel source, run the source_sync.sh script:

$ cd <install-path>/Linux_for_Tegra/source
$ ./source_sync.sh -k -t <release-tag>

The correct release-tag is specified in the release notes. This tag name syncs the sources to the source revision from which the release binary was built.

To Manually Download and Expand the Kernel Sources

  1. In your browser, go to https://developer.nvidia.com/embedded/jetson-linux-archive.

  2. Locate and download the Jetson Linux source files for your release.

  3. Extract the .tbz2 file:

    $ tar xf public_sources.tbz2 -C <install-path>/Linux_for_Tegra/..
    
  4. Extract the kernel and the NVIDIA out-of-tree modules source files:

    $ cd <install-path>/Linux_for_Tegra/source
    $ tar xf kernel_src.tbz2
    $ tar xf kernel_oot_modules_src.tbz2
    $ tar xf nvidia_kernel_display_driver_source.tbz2
    

    This extracts the kernel source to the kernel/ subdirectory, and the NVIDIA out-of-tree kernel modules sources to the current directory.

Building the Jetson Linux Kernel

  1. Go to the build directory:

    $ cd <install-path>/Linux_for_Tegra/source
    
  2. If you are building the real-time kernel, enable the real-time configuration:

    $ ./generic_rt_build.sh "enable"
    
  3. Run the following commands to build the Jetson Linux kernel and its in-tree modules:

    $ export CROSS_COMPILE=<toolchain-path>/bin/aarch64-buildroot-linux-gnu-
    $ make -C kernel
    
  4. Run the following commands to install the kernel and in-tree modules:

    $ export INSTALL_MOD_PATH=<install-path>/Linux_for_Tegra/rootfs/
    $ sudo -E make install -C kernel
    $ cp kernel/kernel-jammy-src/arch/arm64/boot/Image \
      <install-path>/Linux_for_Tegra/kernel/Image
    

Building the NVIDIA Out-of-Tree Modules

  1. Go to the build directory:

    $ cd <install-path>/Linux_for_Tegra/source
    
  2. If you are building the real-time kernel, configure the following variable that pertains to the nvdisplay drivers:

    $ export IGNORE_PREEMPT_RT_PRESENCE=1
    
  3. Run the following commands to build:

    $ export CROSS_COMPILE=<toolchain-path>/bin/aarch64-buildroot-linux-gnu-
    $ export KERNEL_HEADERS=$PWD/kernel/kernel-jammy-src
    $ make modules
    
  4. Run the following commands to install:

    $ export INSTALL_MOD_PATH=<install-path>/Linux_for_Tegra/rootfs/
    $ sudo -E make modules_install
    
  5. To update the initramfs, run the following commands:

    $ cd <install-path>/Linux_for_Tegra
    $ sudo ./tools/l4t_update_initrd.sh
    

Note

If you are building natively on a target, to update the the initramfs directly on the target, run the sudo nv-update-initrd command.

Building the DTBs

  1. Go to the build directory:

    $ cd <install-path>/Linux_for_Tegra/source
    
  2. Run the following commands to build:

    $ export CROSS_COMPILE=<toolchain-path>/bin/aarch64-buildroot-linux-gnu-
    $ export KERNEL_HEADERS=$PWD/kernel/kernel-jammy-src
    $ make dtbs
    
  3. Run the following commands to install:

    $ cp kernel-devicetree/generic-dts/dtbs/* <install-path>/Linux_for_Tegra/kernel/dtb/
    

Note

If KERNEL_HEADERS points to a source directory rather than an exported headers directory, you will need to run make ARCH=arm64 defconfig scripts or equivalent in order to build dtc.

Signing and Encrypting the Kernel, the kernel-dtb, and the initrd Binary Files

To support Secure Boot, the kernel, kernel-dtb, and initrd binary files must be signed and encrypted with keys to generate encrypted binary files and signature files.

See the topic Secure Boot.

Using the Jetson Linux Real-Time Kernel Package

Starting with release 35.1, Real-Time Kernel support is provided with Developer-Preview quality for the following platforms:

  • Jetson Orin AGX

  • Jetson Orin NX and Nano

Real-Time Kernel Using OTA Update

The real-time (RT) kernel can be installed with a Debian package management-based OTA on Jetson devices running Jetson Linux or Jetson components on a host computer.

Installing the Real-Time Kernel Packages on a Jetson Device

  1. Open the apt source configuration file in a text editor, for example:

    $ sudo vi /etc/apt/sources.list.d/nvidia-l4t-apt-source.list
    
  2. Add the RT kernel repository:

    deb https://repo.download.nvidia.com/jetson/rt-kernel <release> main
    

    Where:

    • <release> is the release number of the minor release to which you want to update. For example, to update to release 36.3, replace <release> with r36.3. OTA updates install the latest version of the specified release.

  3. Save and close the source configuration file.

  4. Enter the following command:

    $ sudo apt update
    
  5. Install the RT kernel packages:

    $ sudo apt install nvidia-l4t-rt-kernel nvidia-l4t-rt-kernel-headers nvidia-l4t-rt-kernel-oot-modules nvidia-l4t-display-rt-kernel
    
  6. Reboot your Jetson device after the installation is finished:

    $ sudo reboot
    

Removing the Real-Time Kernel Packages on a Jetson Device

  1. Remove the RT kernel packages with the below command:

    $ sudo apt remove nvidia-l4t-rt-kernel nvidia-l4t-rt-kernel-headers nvidia-l4t-rt-kernel-oot-modules nvidia-l4t-display-rt-kernel
    
  2. Reboot your Jetson device:

    $ sudo reboot
    

Switch to a Different Kernel

Once you have installed the real-time kernel on your device, you may want to switch between the real-time kernel image and the original generic kernel image without re-installing or removing kernel packages. You can do this by editing /boot/extlinux/extlinux.conf and setting the DEFAULT property to specify the kernel you want to boot. Set DEFAULT to real-time for the real-time kernel, or to primary for the generic kernel.:

TIMEOUT 30
DEFAULT real-time

Note

The UEFI runtime services are enabled by default which may increase latency. We do not recommend using UEFI runtime services while running RT applications. Refer to commit ba7585a4a5580b4cba26ebe76050bd2ef1148948 for more information.