You might want to look at these, which apply to both cross compile and native compile. Beware that you can normally install kernels and modules without flashing (also, they were written for older hardware and system releases, but still apply):
- https://forums.developer.nvidia.com/t/problem-smb-jetson-nano/193640/11
- https://forums.developer.nvidia.com/t/how-to-use-hiddev-device-on-jetson-nano-4gb/254048/24
- Useful to add new boot entries instead of replacing with an experimental kernel (at least until tested):
https://forums.developer.nvidia.com/t/how-to-use-hiddev-device-on-jetson-nano-4gb/254048/24 - Another, but more simplified, kernel build note:
https://forums.developer.nvidia.com/t/jetpack-5-0-2-boot-from-sata-ssd-on-jetson-xavier-nx-error-dev-sda1-not-found/238718/25
Note that you can name an alternate output location for modules. If you’ve propagated the configuration (either by building the Image
target or modules_prepare
target), then you can accumulate all the modules in that empty directory. An example build script (native compile):
# --- Setting Up: -------------------------------------------------------
# DO NOT BUILD AS ROOT/SUDO!!! You might need to install source code as root/sudo.
mkdir -p "${HOME}/build/kernel"
mkdir -p "${HOME}/build/modules"
mkdir -p "${HOME}/build/firmware"
export TOP="/usr/src/sources/kernel/kernel-4.9"
export TEGRA_KERNEL_OUT="${HOME}/build/kernel"
export TEGRA_MODULES_OUT="${HOME}/build/modules"
export TEGRA_FIRMWARE_OUT="${HOME}/build/firmware"
export TEGRA_BUILD="${HOME}/build"
# --- Notes: ------------------------------------------------------------
# It is assumed kernel source is at "/usr/src/sources/kernel/kernel-4.9".
# Check if you have 6 CPU cores, e.g., via "htop".
# If you are missing cores, then experiment with "sudo nvpmodel -m 0, -m 1, and -m 2".
# Perhaps use "htop" to see core counts.
# Using "-j 6" in hints below because of assumption of 6 cores.
# -----------------------------------------------------------------------
# Compile commands start in $TOP, thus:
cd $TOP
# Do not forget to provide a starting configuration. Probably copy of "/proc/config.gz",
# to $TEGRA_KERNEL_OUT, but also perhaps via:
make O=$TEGRA_KERNEL_OUT nconfig
# If building the kernel Image:
make -j 6 O=$TEGRA_KERNEL_OUT Image
# If you did not build Image, but are building modules:
make -j 6 O=$TEGRA_KERNEL_OUT modules_prepare
# To build modules:
make -j 6 O=$TEGRA_KERNEL_OUT modules
# To build device tree content:
make -j 6 O=$TEGRA_KERNEL_OUT dtbs
# To put modules in "$TEGRA_MODULES_OUT":
make -j 6 O=$TEGRA_KERNEL_OUT INSTALL_MOD_PATH=$TEGRA_MODULES_OUT modules_install
# To put firmware and device trees in "$TEGRA_FIRMWARE_OUT":
make -j 6 O=$TEGRA_KERNEL_OUT INSTALL_FW_PATH=$TEGRA_FIRMWARE_OUT
One does not normally bother to build all of the targets, especially firmware. If all you are doing is adding a module, then you need to propagate configuration before build, but there is no need to build the main kernel should the base configuration start as a match to that (such as via tegra_defconfig
plus CONFIG_LOCALVERSION
, or via “/proc/config.gz
” and CONFIG_LOCALVERSION
), then you can build the modules and install them as a file copy.
rsync
is a reasonable way to copy modules. Flashing really is not needed though.
If you do flash, then modules must go to a subdirectory of “Linux_for_Tegra/rootfs/lib/modules/$(uname -r)/kernel
”. Note that this “uname -r
” is from the Jetson, and not from the host PC. When you see the “-tegra
” suffix on a kernel version like 5.10.104
, it means CONFIG_LOCALVERSION
was set to “-tegra
”, and this is the default. This is what determines the output of uname -r
, so if you compile a 5.10.104
kernel with CONFIG_LOCALVERSION
of “-tegra
”, then this is what that kernel would reply with from the uname -r
command: 5.10.104-tegra
.
Note that initrd
flash does change things. Install will probably need modification as the extlinux.conf
seems to get edits overwritten in some cases on the newer software.
Something I hope NVIDIA comments on is the source of any extlinux.conf
overwrite on the Jetson itself after hand editing that file (not from flashing).