NVIDIA Tegra
NVIDIA Tegra Linux Driver Package

Development Guide
32.1 Release


 
Kernel Customization
 
Obtaining the Kernel Sources with Git
Manually Downloading and Expanding Kernel Sources
Building the NVIDIA Kernel
Preparing to Build External Kernel Modules
Building External Kernel Modules
How To Enable PMIC-WDT
Kernel Boot Time Optimization
Display Configuration and Bringup
The L4T Toolchain
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 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
1. In a browser, navigate to:
https://developer.nvidia.com/embedded/downloads
2. Locate and download the L4T Sources for your release.
3. Extract the TBZ2 file.
$ tar -xjf public_sources.tbz2
4. Extract the kernel source file.
$ cd 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 Tegra Kernel
1. Set the shell variable with the command:
$ TEGRA_KERNEL_OUT=<outdir>
Where:
<outdir> is the desired destination for the compiled kernel.
 
Note:
NVIDIA recommends using the Linaro 7.3.1 2018.05 toolchain.
2. If cross-compiling on a non-Tegra system, export the following environment variable:
$ export CROSS_COMPILE=<crossbin>
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-linux-gnu-
See The L4T Toolchain for information on how to download and build the reference toolchains.
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.
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 Linux_for_Tera/kernel/Image with:
$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=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
Preparing to Build External Kernel Modules
These procedures describe how to prepare a set of kernel headers, or a kernel source tree to allow building an out-of-tree kernel module.
To prepare the L4T kernel headers on a Tegra system
On an L4T system you can use the files in this directory to build out-of-tree modules without further action:
/usr/src/linux-headers-$(uname -r)-ubuntu18.04_aarch64
To build out-of-tree modules, specify the kernel directory as:
/usr/src/linux-headers-$(uname -r)-ubuntu18.04_aarch64
or
/lib/modules/$(uname -r)/build
To prepare the L4T kernel headers on a non-Tegra system
Extract the following archive and place it in a local directory with the commands:
$ cd <local_src_dir>
$ tar -xjf <top>/Linux_for_Tegra/kernel/kernel_headers.tbz2
You can use the files in this directory to build out-of-tree modules without further action:
<local_src_dir>/linux-headers-$(uname -r)-linux_x86_64
To build out-of-tree modules, specify the kernel directory as:
<local src dir>/linux-headers-$(uname -r)-linux_x86_64
To use a manually built NVIDIA kernel source tree
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:
Obtaining the Kernel Sources with Git
Manually Downloading and Expanding Kernel Sources
Building the NVIDIA Kernel
2. Execute the following command to prepare the kernel source tree for building out-of-tree kernel modules:
$ make ARCH=arm64 O=$TEGRA_KERNEL_OUT -j<n> modules_prepare
Where <n> indicates the number of parallel processes to be used. A typical value is the number of CPUs in your system.
When building out-of-tree modules, specify $TEGRA_KERNEL_OUT as the kernel directory.
Building External Kernel Modules
If cross-compiling, ensure that the CROSS_COMPILE environment variable is set as described in previous sections.
Execute the following commands to build an out-of-tree kernel module:
$ cd <path_to_module_source>
$ make ARCH=arm64 -C <kernel_directory> M=$(pwd)
How To Enable PMIC-WDT
To enable PMIC-WDT:
1. Change ODM data: set ODM data bits 17:16 to 0b10 before flashing in conf file. (This enables PMIC-WDT and disables Tegra-WDT.)
In the file sudo vim p2771-0000.conf.common, replace 0x1090000 with 0x10a0000.
2. Enter the command:
echo 0 > /sys/module/kernel/parameters/panic
3. Enter the command:
cat /dev/watchdog
or
echo c > /proc/sysrq-trigger
(The latter command causes the system to crash.)
4. Wait for two minutes. The device reboots. With this reboot, UART logs begin to appear in the mb2 logs:
[0000.203] I> pmic: reset reason (nverc) : 0x2