Kernel Boot Time Optimization

NVIDIA® Jetson™ Linux (L4T) provides a generic boot kernel for development of your product. To decrease kernel boot time, customize the provided kernel based on the requirements of your product.
The kernel includes a default configuration that enables all supported hardware features and searches all available devices for boot scripts. This enables out-of-the box support for the widest possible variety of controllers, features, storage devices, and boot configurations.
This flexibility comes at a cost:
Some hardware support takes time to initialize
Enabling all software features, mostly over Advanced Peripheral Bus (APB), takes time
Scanning all attached storage and network devices takes time thereby delaying execution of the final operating system
In constrained or pre-configured systems, this flexibility may not be necessary; the system designer may know ahead of time which storage device contains the required files, or that certain devices do not need to be initialized by the kernel. To reduce system boot time, you can configure the kernel to respect these constraints.
For an NVIDIA® Jetson™ TX1 system running L4T with the default configuration, it takes 12 seconds from cold power-on to begin showing the login prompt. When the following optimization techniques are applied, that process can be reduced to approximately three seconds.

Device Tree Nodes

If you are not using any controller from the Jetson SoC, disable the Device Tree nodes for those device tree entries. The device tree directory is available at:
<top>/hardware/nvidia/platform/t18x/
<top>/hardware nvidia/soc/t18x
The DTB that is flashed is available at:
<top>/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-a00-00-base.dts

Real-Time Clock

Two Real-time Clocks (RTC) are enabled by default:
NVIDIA® Tegra® RTC
PMIC RTC
Enable one, both, or none, based on your development needs. Be aware of the following differences:
Tegra RTC is the fastest in response, but cannot work as a backup RTC when the system is turned off.
PMIC RTC can work as a backup RTC, however it is slow in response because of the transfer average to I2C.
If you do not shutdown the system, of if you are not concerned about backup time, then you do not need to enable RTC. Disabling RTC can speed up boot time.
To disable the RTC
1. Remove the following configuration from your tegra21_defconfig file.
CONFIG_RTC_DRV_MAX77620=y
2. Add the following configuration to the tegra21_defconfig file.
# CONFIG_RTC_HCTOSYS is not set
3. Set the Tegra RTC to disabled in the DTS file as follows:
rtc {
compatible = "nvidia,tegra-rtc";
reg = <0x00000000 0x00000003 0x00000002 0x0000009b>;
interrupts = <0x00000000 0x00000005 0x00000002>;
status = "disabled";
};

Environment Configuration

You can optimize boot time by modifying the environment configuration in the root file system.

Disable Console over UART

Console printing over UART is a major bottleneck in kernel boot time. To reduce the bottleneck, you can reduce the volume of console printing over UART by removing console=ttyS0 from the platform configuration file.
To reduce the volume of printing over UART, follow these instructions:
For NVIDIA® Jetson Nano™ devices: Edit the platform configuration file p3448-0000.conf to remove the specification console=ttyS0.
For NVIDIA® Jetson AGX Xavier™ series: Edit the platform configuration file p2972-0000.conf.com to remove the specification console=ttyTCU0.
For NVIDIA® Jetson™ TX2 series: Edit p2771-000.conf.common to remove the specification console=ttyS0. (This file is included by the platform configuration file, p2771-0000-devkit.conf for Jetson TX2 or p2771-3489-ucm1.conf for Jetson TX2i.)
After you do this you may still review the console logs over the framebuffer console.

Secondary Bootloader

You can remove U‑Boot as the secondary bootloader to remove boot time of u-boot. The following modifications are required before flashing:
1. Edit the common configuration file at:
<top>/tegra_for_linux/ p2771-000.conf
2. Set USE_UBOOT to 0.
# To configure whether to use U-Boot,
# do either of the following before running flash.sh:
# 1) Set environment variable USE_UBOOT to 0 or 1.
# 2) Edit the line below to set USE_UBOOT to 0 or 1.
if [ -z "${USE_UBOOT}" ]; then
USE_UBOOT=0;
fi;

Compile-Time Configuration

To reduce compile-time configuration, examine the generated configuration file to identify which configurations are required. Once the required configurations are defined, identify which ones to boot asynchronously. For those configurations, the drivers probe is executed asynchronously in a separate thread instead of the main initial thread.
Additionally, examine the required configurations and verify that they can be programmed as modules so that the drivers are loaded when it is called for use. When the drivers are not loaded, the kernel image is reduced, and more RAM space is available.
The following topics provide examples of each of these conditions.

Asynchronous Probe

The asynchronous probe feature is available, by default, from Kernel Version 3.18:
To move the driver to another thread
Add the probe_type in your driver as follows:
static struct platform_driver sdhci_tegra_driver = {
.driver = {
.name = "sdhci-tegra",
.of_match_table = sdhci_tegra_dt_match,
.pm = SDHCI_PLTFM_PMOPS,
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
},
.probe = sdhci_tegra_probe,
.remove = sdhci_tegra_remove,
.shutdown = sdhci_tegra_shutdown,
};

File System

To decrease boot time the file system, modify the following configurations to set them as modules:
CONFIG_FUSE_FS=m
CONFIG_VFAT_FS=m
CONFIG_NTFS_FS=m

Sound

Audio codec requires some time to initialize. To eliminate this initialization time, disable the audio configurations as follows:
# CONFIG_SND_SOC_TEGRA_ALT is not set
# CONFIG_SND_SOC_TEGRA_ALT_FORCE_CARD_REG is not set
# CONFIG_SND_SOC_TEGRA_T186REF_ALT is not set
# CONFIG_SND_SOC_TEGRA_T186REF_MOBILE_ALT is not set
 

Modularize Kernel Driver

To reduce boot time, modularize the drivers that are not required during boot, such as: HID, NET, QSPI, or USB.

Disable Debugging

To reduce boot time, disable debugging kernel hacks in the production configuration.
For example: FTRACE, TRACER, KMEMLEAK, etc.