Out-of-tree kernel modules
This guide builds a hello-world kernel module against the NVIDIA L4T kernel, packages it in an extension and loads it on a Jetson Orin Nano. It was run on one Orin Nano developer kit with avocado-cli 1.2.0, release 2026 on the edge channel (feed snapshot 226) and kernel 6.8.12-l4t-r39.2.1-1021.21. Other boards, snapshots and kernels were not tried.
For the general flow of compiling code into an extension, see Cross-compilation. This page covers what differs on the L4T kernel.
Development packages
The feed carries a development package pair for each kernel. For the L4T kernel they are:
| Package | Provides | Needed by |
|---|---|---|
kernel-devsrc-6.8.12-l4t-r39.2.1-1021.21 | The kernel build directory, at /usr/lib/modules/<kver>/build | Every module |
kernel-nvidia-oot-dev-6.8.12-l4t-r39.2.1-1021.21 | Module.symvers and headers under /usr/include/nvidia-kernel-oot | A module that uses symbols from NVIDIA's out-of-tree code |
The package names carry the kernel version. List them with the runtime's package manager:
avocado runtime dnf --runtime dev -- repoquery --showduplicates 'kernel-devsrc*' 'kernel-nvidia-oot-dev*'
On snapshot 226 this lists the L4T pair (kernel-devsrc-...r0.7, kernel-nvidia-oot-dev-...39.2.1-r0.12), their -rt variants, and the development packages of the Yocto 6.18 kernels. A listing without --showduplicates showed the same eleven packages.
A plain module built with only kernel-devsrc installed. The module loaded on the board in this guide was built with both packages installed. A module that uses NVIDIA's out-of-tree symbols needs kernel-nvidia-oot-dev and KBUILD_EXTRA_SYMBOLS=.../usr/include/nvidia-kernel-oot/Module.symvers. That case was not built or loaded here.
Install them as target packages under the compile section's packages:. The CLI installs them into the target sysroot before the compile script runs.
Pin the kernel exactly
Without a kernel: block the Orin Nano runtime resolved the Yocto 6.18.52 kernel on this feed. Select the L4T kernel with an exact version:
kernel:
package: kernel-image
version: '6.8.12-l4t-r39.2.1-1021.21'
Keep the top-level block, which governs the rootfs, initramfs, extension sysroots and the SDK target sysroot, and repeat it under the runtime if you set cmdline_extra there, as in the next sections. See How package and version select a kernel.
version: "6.8.*" resolved the -rt kernel, 6.8.12-l4t-r39.2.1-1021.21-rt. The CLI excludes the packages of the kernels you did not select, so avocado install then failed to find the standard kernel-devsrc package with All matches were filtered out by exclude filtering. An exact version fixed it.
The project
runtimes:
dev:
extensions:
- avocado-ext-dev
- avocado-ext-sshd-dev
- avocado-bsp-{{ avocado.target.board }}
- hello-ko
kernel:
package: kernel-image
version: '6.8.12-l4t-r39.2.1-1021.21'
extensions:
hello-ko:
types:
- sysext
version: '0.1.0'
packages:
hello-ko-bin:
compile: hello-ko-build
install: hello-ko-install.sh
sdk:
packages:
nativesdk-make: '*'
nativesdk-gcc: '*'
nativesdk-glibc-dev: '*'
nativesdk-libgcc-dev: '*'
nativesdk-binutils: '*'
nativesdk-bc: '*'
nativesdk-flex: '*'
nativesdk-bison: '*'
nativesdk-libelf1: '*'
packagegroup-cross-canadian-avocado-{{ avocado.target }}: '*'
sdk:
compile:
hello-ko-build:
compile: hello-ko-compile.sh
packages:
kernel-devsrc-6.8.12-l4t-r39.2.1-1021.21: '*'
kernel-nvidia-oot-dev-6.8.12-l4t-r39.2.1-1021.21: '*'
hello-ko/hello.c:
#include <linux/module.h>
#include <linux/init.h>
static int __init hello_init(void)
{
pr_info("hello-ko: loaded\n");
return 0;
}
static void __exit hello_exit(void)
{
pr_info("hello-ko: unloaded\n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Out-of-tree hello module");
hello-ko/Makefile:
obj-m += hello.o
hello-ko-compile.sh:
#!/bin/bash
set -euo pipefail
KVER=6.8.12-l4t-r39.2.1-1021.21
KDIR="$OECORE_TARGET_SYSROOT/usr/lib/modules/$KVER/build"
_CROSS="$CROSS_COMPILE"
# The SDK sets flags for userspace builds; kbuild brings its own.
unset CC CXX CPP LD AR AS NM STRIP OBJCOPY OBJDUMP READELF RANLIB CFLAGS CXXFLAGS CPPFLAGS LDFLAGS KCFLAGS
ARGS=(ARCH=arm64 CROSS_COMPILE="$_CROSS" HOSTCC=x86_64-avocadosdk-linux-gcc)
# kernel-devsrc ships sources, not the host tools kbuild runs, so build them first.
make -C "$KDIR" "${ARGS[@]}" modules_prepare
make -C "$KDIR" "${ARGS[@]}" M="$PWD/hello-ko" modules
hello-ko-install.sh:
#!/bin/bash
set -euo pipefail
KVER=6.8.12-l4t-r39.2.1-1021.21
install -D -m 0644 hello-ko/hello.ko "$AVOCADO_BUILD_EXT_SYSROOT/usr/lib/modules/$KVER/extra/hello.ko"
The host compiler name x86_64-avocadosdk-linux-gcc is for an x86-64 SDK container. These errors, in order, showed what each host package and flag is for:
| Error during the build | Fix |
|---|---|
scripts/basic/fixdep: No such file or directory | Run modules_prepare: kernel-devsrc ships fixdep.c, not the built tool |
gcc: command not found | Install nativesdk-gcc and name its binary in HOSTCC |
sys/types.h: No such file or directory | Install nativesdk-glibc-dev and nativesdk-libgcc-dev |
DESTDIR: unbound variable in the install script | Install into $AVOCADO_BUILD_EXT_SYSROOT |
The sysext's release file gets AVOCADO_ON_MERGE="depmod" because the extension contains kernel modules, so the module is indexed when the extension merges.
Build and provision
avocado install
avocado build
Provisioning writes the board. This one erases the NVMe SSD (the flash log shows Flash arguments: --erase-nvme) and needs the board in USB recovery mode, as described in Get started on Jetson.
avocado provision dev --profile tegraflash
The first boot can hang at TPM SRK Setup
The first image built for this guide booted the new kernel and then stopped at A start job is running for TPM SRK Setup (no limit), with a hung-task trace from the OP-TEE fTPM driver. It never reached a login prompt. The meta-avocado recipe systemd-jetson-masks adds drop-ins that bound this unit, but the packages in feed snapshots 226 (edge) and 714 (next) ship only the getty preset, so the drop-ins were not in the image.
Until a snapshot carries them, a project can mask the two units from the kernel command line, which applies before any extension merges. Put cmdline_extra in the runtime's kernel: block:
runtimes:
dev:
kernel:
package: kernel-image
version: '6.8.12-l4t-r39.2.1-1021.21'
cmdline_extra: 'systemd.mask=systemd-tpm2-setup.service systemd.mask=systemd-tpm2-setup-early.service'
The build log printed Kernel cmdline extended from project config with both masks, and both appear in the header of the built boot.img. With this setting the board reached the login prompt and systemctl is-enabled systemd-tpm2-setup.service printed masked-runtime. This is a workaround. It skips the SRK setup for the whole image, so check that nothing in your project depends on the fTPM before you use it.
Load the module on the board
On the board's serial console, as root:
uname -r
modprobe hello
lsmod | grep hello
dmesg | tail -1
modinfo -F vermagic hello
The output was:
6.8.12-l4t-r39.2.1-1021.21
hello 12288 0
[ 147.056978] hello-ko: loaded
6.8.12-l4t-r39.2.1-1021.21 SMP preempt mod_unload modversions aarch64
modprobe found the module by name, so insmod with the path to the .ko was not needed. The vermagic string carries the running kernel's version.