You can manually rebuild the kernel used for the NVIDIA® Jetson™ Linux Driver Package (L4T). Internet access is required.
Obtaining the Kernel Sources with Git
Prerequisites
• You have installed Git. Install Git with the following command:
$ sudo apt install git-core
• Your system has the default Git port 9418 open for outbound connections.
To sync the kernel sources
• Get the kernel source by running the source_sync.sh script:
$ ./source_sync.sh
When prompted enter a ‘tag’ name, as provided in the release notes.
You can sync to any Linux tag you like. However, the tag provided in the release notes syncs the sources to the same source revision the release binary was built from. To see a list of the available release tags, use:
$ git tag –l tegra-l4t*
Manually Downloading and Expanding Kernel Sources
As an alternative, you can download the kernel source files and then manually extract them. If possible, it is recommended to instead sync with git.
To manually download and expand the kernel sources
2. Locate and download the L4T source files for your release.
3. Extract the TBZ2 file.
$ tar -xjf <board>-public_sources.tbz2
4. Extract the kernel source file.
$ cd public_sources/
$ tar –xjf kernel_src.tbz2
The kernel source is extracted to the kernel subdirectory.
Building the NVIDIA Kernel
Follow the steps in this procedure to build the NVIDIA kernel.
Prerequisites
• You have downloaded the kernel source code.
• You have installed the utilities required by the kernel build process.
Install the utilities with the command:
$ sudo apt install build-essential bc
To build the Jetson Linux Kernel
1. Set the shell variable with the command:
$ TEGRA_KERNEL_OUT=<outdir>
Where:
• <outdir> is the desired destination for the compiled kernel.
2. If cross-compiling on a non-Jetson system, export the following environment variables:
$ export CROSS_COMPILE=<cross_prefix>
$ export LOCALVERSION=-tegra
Where:
• <cross_prefix> is the the absolute path of the ARM64 toolchain without the gcc suffix. For example, for the reference ARM64 toolchain, <cross_prefix> is:
<toolchain_install_path>/bin/aarch64-linux-gnu-
See The L4T Toolchain for information on how to download and build the reference toolchains.
Note:
NVIDIA recommends using the Linaro 7.3.1 2018.05 toolchain.
3. Execute the following commands to create the .config file:
$ cd <kernel_source>
$ mkdir -p $TEGRA_KERNEL_OUT
$ make ARCH=arm64 O=$TEGRA_KERNEL_OUT tegra_defconfig
Where:
• <kernel_source> directory contains the kernel sources (e.g. kernel-4.9).
4. Execute the following commands to build the kernel including all DTBs and modules:
$ make ARCH=arm64 O=$TEGRA_KERNEL_OUT -j<n>
Where <n> indicates the number of parallel processes to be used. A typical value is the number of CPUs in your system.
5. Replace <release_packagep>/Linux_for_Tegra/kernel/Image with a copy of:
$TEGRA_KERNEL_OUT/arch/arm64/boot/Image
6. Replace the contents of Linux_for_Tegra/kernel/dtb/ with the contents of:
$TEGRA_KERNEL_OUT/arch/arm64/boot/dts/
7. Execute the following commands to install the kernel modules:
$ sudo make ARCH=arm64 O=$TEGRA_KERNEL_OUT modules_install \
INSTALL_MOD_PATH=<top>/Linux_for_Tegra/rootfs/
8. Optionally, archive the installed kernel modules using the following command:
$ cd <modules_install_path>
$ tar --owner root --group root -cjf kernel_supplements.tbz2 \
lib/modules
The installed modules can be used to provide the contents of /lib/modules/<kernel_version> on the target system.
Use the archive to replace the one in the kernel directory of the extracted release package prior to running apply_binaries.sh:
Linux_for_Tegra/kernel/kernel_supplements.tbz2
To sign kernel and kernel-dtb binary files for Jetson AGX Xavier
Applies to: Jetson Xavier NX and Jetson AGX Xavier series
To support Secureboot, kernel binary and kernel-dtb binary files must be signed with a key to generate signature files. You can sign such files proceeded by running the script l4t_sign_image.sh on your development system. This script is in the directory <release_package>/Linux_for_Tegra/:
• <keyfile> is an RSA key pair file (a .pem file). It provides values to fill key fields in the signature file. If the ‑‑key switch is not specified, key fields are filled with 0’s.
• If you built the NVIDIA kernel from source, use the same source tree when building out-of-tree kernel modules. When building out-of-tree modules, specify $TEGRA_KERNEL_OUT as kernel directory.
To prepare an NVIDIA kernel source tree that is not built
You can build out-of-tree modules that are compatible with a Linux kernel source tree without building the entire kernel image.
1. To extract the kernel source, set any required shell or environment variables, and create the .config file, follow the instructions provided in the following topics: