Introduction
This article documents the process to build the NVIDIA L4T and Connect Tech board support package from source. Building from source must be done after making kernel modifications or adding kernel modules to be loaded at boot.
Prerequisites
You will need a cross compiler, the latest supported cross compiler can be found here:
You must create Linux_for_Tegra as normal for flashing, instructions available here:
https://connecttech.com/resource-center/kdb373/.
You must obtain sources for the desired L4T release, available upon request from Connect Tech Support. Extract the sources package into your Linux_for_Tegra directory.
Once this is complete you can make kernel modifications in Linux_for_Tegra/sources as necessary for your implementation.
Setup Environment
Navigate to Linux_for_Tegra and export the following environment variables. Your build directory can be anywhere and called anything but you’ll want a kernel and modules directory to pass to Make.
export CROSS_COMPILE=/opt/aarch64--glibc--stable-2020.08-1/bin/aarch64-buildroot-linux-gnu-
export LOCALVERSION=-tegra
export DEFCONFIG=cti_tegra_defconfig
export ARCH=arm64
export KERN_SRC=[L4T-DIRECTORY]/Linux_for_Tegra/sources/kernel/kernel-5.10
export KERN_OUT=[L4T-DIRECTORY]/build/kernel
export MOD_OUT=[L4T-DIRECTORY]/build/mod
Build the Kernel
Build the kernel image, kernel modules and dtbs, these will be exported to your build directory.
cd $KERN_SRC
make O=$KERN_OUT $DEFCONFIG
make LOCALVERSION=$LOCALVERSION O=$KERN_OUT Image -j${nproc}
make LOCALVERSION=$LOCALVERSION O=$KERN_OUT modules -j${nproc}
make LOCALVERSION=$LOCALVERSION O=$KERN_OUT dtbs -j${nproc}
make O=$KERN_OUT modules_install INSTALL_MOD_PATH=$MOD_OUT
# cd back to Linux_for_Tegra
cd ../../../
Package and Export
After you've build the kernel, package and export for flashing.
mkdir [L4T-DIRECTORY]/output
tar -C $MOD_OUT -cjf [L4T-DIRECTORY]/output/kernel_supplements.tbz2 lib
mkdir -p [L4T-DIRECTORY]/output/dtbs
cp $KERN_OUT/arch/arm64/boot/dts/nvidia/*.dtb [L4T-DIRECTORY]/output/dtbs
cp $KERN_OUT/arch/arm64/boot/*Image [L4T-DIRECTORY]/output
And install.
cp [L4T-DIRECTORY]/output/kernel_supplements.tbz2 kernel/
cp -r $MOD_OUT/lib/modules/ rootfs/lib/
mkdir -p kernel/dtb
cp [L4T-DIRECTORY]/output/*Image kernel/
cp -r [L4T-DIRECTORY]/output/dtbs/* kernel/dtb/
./flash.sh [profile] mmcblk0p1