Building kernel for Wireguard on Jetpack 5.1.3

Hello,

I am trying to install Wireguard in my Jetson Xavier with Jetpack 5.1.3 from another machine, but I know that the kernel must be rebuilt with proper configuration (Wireguard enabled). Thing is that I have been trying to do so in many ways, but nothing works. What I think it should work:

  1. With SDKManager, generate the directory with the Image, rootfs, and everything in my machine.
  2. Download Driver Package (BSP) Sources from Jetson Linux | NVIDIA Developer
  3. Edit the file Linux_for_Tegra/source/public/kernel/kernel-5.10/arch/arm64/configs/tegra_defconfig and add: “CONFIG_WIREGUARD=y”
  4. Build the kernel: ./nvbuild.sh -o $PWD/kernel_out
  5. Copy the files generated when building in my directory where is rootfs, as indicated in Kernel Customization — Jetson Linux<br/>Developer Guide 34.1 documentation
  6. From the directory where is the rootfs, flash to my Jetson.

Happens that the Image is not even replaced in /boot/Image, and the Wireguard module is not set.

I tried then to manually copy the Image generated to my Jetson, and the files generated in the drivers/net/wireguard/* to the Jetson. Then sudo depmod , but this error arised:
modprobe: ERROR: could not insert ‘wireguard’: Unknown symbol in module, or unknown parameter (see dmesg)
related to:

[  442.320227] wireguard: Unknown symbol curve25519_null_point (err -2)
[  442.320550] wireguard: Unknown symbol chacha20poly1305_encrypt_sg_inplace (err -2)
[  442.320811] wireguard: Unknown symbol chacha20poly1305_encrypt (err -2)
[  442.321147] wireguard: Unknown symbol chacha20poly1305_decrypt_sg_inplace (err -2)
[  442.321388] wireguard: Unknown symbol xchacha20poly1305_encrypt (err -2)
[  442.321570] wireguard: Unknown symbol xchacha20poly1305_decrypt (err -2)
[  442.321830] wireguard: Unknown symbol curve25519_base_point (err -2)
[  442.322091] wireguard: Unknown symbol chacha20poly1305_decrypt (err -2)
[  442.322627] wireguard: Unknown symbol curve25519_generic (err -2)
[  463.011248] wireguard: Unknown symbol curve25519_null_point (err -2)
[  463.011608] wireguard: Unknown symbol chacha20poly1305_encrypt_sg_inplace (err -2)
[  463.011953] wireguard: Unknown symbol chacha20poly1305_encrypt (err -2)
[  463.012361] wireguard: Unknown symbol chacha20poly1305_decrypt_sg_inplace (err -2)
[  463.012604] wireguard: Unknown symbol xchacha20poly1305_encrypt (err -2)
[  463.012772] wireguard: Unknown symbol xchacha20poly1305_decrypt (err -2)
[  463.012996] wireguard: Unknown symbol curve25519_base_point (err -2)
[  463.013220] wireguard: Unknown symbol chacha20poly1305_decrypt (err -2)
[  463.013536] wireguard: Unknown symbol curve25519_generic (err -2)

I think I am messing up doing manual copy.

We don’t actually have experience about this, we would suggest consult with the vendor to check how to enable it on K5.10(Jetpack 5) or K5.15(Jetpack 6).
or refer to How do I add wireguard manually? - Jetson & Embedded Systems / Jetson Xavier NX - NVIDIA Developer Forums to see if can help.

Regardless of the specific wireguard of this use case, we can’t get the generated Image in the jetson if it’s notby copying it manually.

We would expect that when a new kernel is compiled following Kernel Customization — Jetson Linux<br/>Developer Guide 34.1 documentation and the Image is placed in Linux_for_Tegra/kernel/Image and then we execute flash.sh without the -r option, the Image would be copied to the Jetson, but it is not.

Is there any specific step? The instructions are vague on how to use the Kernel after building it.
We would also like to generate a rootfs image that can be used to flash a dozen other jetsons we have.

Just some comments related to this: For a module to load you need to build that module against the kernel Image configuration. When you copy this new kernel Image in manually, what do you see from “uname -r”? Before you copy this Image file in, what is the old “uname -r” output? The suffix is the CONFIG_LOCALVERSION, so for example if your “uname -r” responds 5.15.136-tegra, then the kernel source version was 5.15.136, and the CONFIG_LOCALVERSION string was “-tegra”. This is the basic start: For your modules and Image to work together, they must use the same configuration (you can add modules without rebuilding the Image if config starts out matching; as soon as you change the Image, then all bets are off).

The other thing to understand is that editing a configuration for a kernel directly is usually a "bad idea"™ due to dependencies. When you enable a feature that has a dependency, then you must also build the module with that dependency, and if you don’t know about this, then you’ll find missing symbol errors when you try to plug in your module. If you start with a kernel that has an exact match to the running kernel Image, and then edit by adding modules using a dependency-aware editor, you would end up with all the modules you need and they would insert into that kernel. I use the nconfig make target, many people use the menuconfig editor make target. nconfig is exactly the same as menuconfig, except that it has symbol search available.