NVIDIA Tegra
NVIDIA Tegra Linux Driver Package

Development Guide
28.1 Release


 
Kernel Customization
 
Obtaining the Kernel Sources with Git
Manually Downloading and Expanding Kernel Sources
Building the NVIDIA Kernel
Building External Kernel Modules
Kernel Boot Time Optimization
Display Configuration and Bringup
Building the AARCH 64 Toolchain and glibc
You can manually rebuild the kernel used for the L4T package. Internet access is required.
Obtaining the Kernel Sources with Git
Prerequisites
You have installed Git. Install Git with the following command:
$ sudo apt-get 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:
$ sudo ./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 expand them. If possible, it is recommended to instead sync with git.
To manually download and expand the kernel sources
1. In a browser, navigate to:
https://developer.nvidia.com/embedded/downloads
2. Locate and download the L4T Sources for your release.
3. Expand the TBZ2 file.
$ sudo tar -vxjf sources.tbz2
4. Manually expand the TBZ2 files in the resulting source directory.
Building the NVIDIA Kernel
Follow the steps in this procedure to build the NVIDIA kernel.
Prerequisites
You have downloaded the kernel source code
To build the Tegra Kernel
1. Export the following environment variables:
$ export CROSS_COMPILE=<crossbin>
$ export TEGRA_KERNEL_OUT=<outdir>
$ export ARCH=arm64
Where:
<crossbin> is the prefix applied to form the path to the toolchain for cross compilation targeting arm64, e.g., gcc.
The reference arm64 toolchain is:
<aarch64_toolchain_install>/bin/aarch64-unknown-linux-gnu-
This example requires GCC 4.8 or above. See Building the AARCH 64 Toolchain and glibc for information on how to obtain the reference toolchains.
<outdir> is the desired destination for the compiled kernel.
2. Execute the following commands to create the .config:
$ cd <myworkspace>/<kernel_source>
$ mkdir $TEGRA_KERNEL_OUT
Where:
<kernel_source> directory contains the kernel sources.
$ make O=$TEGRA_KERNEL_OUT <defconfig>
<myworkspace> is the parent of the Git root.
<defconfig> is:
Jetson TX1: tegra21_defconfig
Jetson TX2: tegra18_defconfig
3. Execute the following commands to build the kernel:
$ make O=$TEGRA_KERNEL_OUT zImage
4. Execute the following command to create the kernel device tree components:
$ make O=$TEGRA_KERNEL_OUT dtbs
5. Execute the following commands to build the kernel modules (and optionally install them)
$ make O=$TEGRA_KERNEL_OUT modules
$ make O=$TEGRA_KERNEL_OUT modules_install INSTALL_MOD_PATH=<your_destination>
6. Copy both the uncompressed (Image) and compressed (zImage) kernel images over the ones present in the following directory:
Linux_for_Tegra/kernel
7. Replace the contents of Linux_for_Tegra/kernel/dtb/ with the contents of:
$TEGRA__KERNEL_OUT/arch/arm64/boot/dts/
8. Archive the kernel modules created using the following command:
cd <modules_install_path>
tar --owner root --group root -cjf kernel_supplements.tbz2 lib/modules
Use the archive to replace the one in the kernel directory of the release:
Linux_for_Tegra/kernel/kernel_supplements.tbz2
Building External Kernel Modules
The procedures in this section describe how to build an out-of-tree kernel module against kernel headers included in the BSP.
The kernel headers are installed at: /usr/src/linux-headers-<kernel version>
To compile natively on the target system
1. Determine user space architecture with the following command:
getconf LONG_BIT
The command returns 64 for AARCH64.
2. In AARCH64 user space, prepare the kernel headers with the following commands:
$ cd /usr/src/linux-headers-`uname -r`
$ sudo make modules_prepare
3. Build the kernel module.
To cross-compile on another system
1. Uncompress the following kernel headers to a local directory:
<top>/Linux_for_Tegra/kernel/kernel_headers.tbz2
with the following commands:
cd <local src dir>
tar xpf <top>/Linux_for_Tegra/kernel/kernel_headers.tbz2
2. Set up the cross-compile toolchain with the following commands:
export CROSS_COMPILE=<crossbin>
export ARCH=arm64
Where <crossbin> completes path to the tool chain for cross compilation targeting arm64, e.g., gcc.
For this reference toolchain:
<aarch64_toolchain_install>/bin/aarch64-unknown-linux-gnu-
For a Linaro toolchain, the path is similar to the following:
<linaro_install>/aarch64-unknown-linux-gnu/bin/aarch64-unknown-linux-gnu-
See Building the AARCH64 Toolchains for downloading and building the reference toolchain.
3. Prepare the kernel headers with the following commands:
cd <local src dir>/linux-headers-<kernel version>
export ARCH=arm64
sudo make modules_prepare
4. Specify <local_source_directory>/linux-headers-<kernel version> as the kernel source path, with the following line in the make file:
make -C <local src dir>/linux-headers-<kernel version> M=$(PWD) modules
5. Build the kernel module.