-
Notifications
You must be signed in to change notification settings - Fork 0
Build new Kernel on EdgeKit
Sometimes there are missing some kernel modules, which we need for development and further for deployment. For the development or adaption-phase of your use-case we would recommend this tutorial, to flexible build the adjusted kernel Image on the EdgeKit itself. For example if you need the Wireguard module.
This procedure needs some space left on the EdgeKit, make sure you have at least 20GB free. First of all we're creating a new folder in the home directory:
cd && mkdir kernel && cd kernel
Also we're installing some dependencies for this further steps:
sudo apt-get install libncurses5-dev libssl-dev
Now we have to download the kernel source files directly from NVIDIA, for that please check which Release you've installed on your EdgeKit with
cat /etc/nv_tegra_release:
e.g. Output: # R35 (release), REVISION: 3.1, GCID: 32827747, BOARD: t186ref, EABI: aarch64, DATE: Sun Mar 19 15:19:21 UTC 2023
The release (R35) and the revision (3.1) is necessary for downloading the correct source files with the following structure:
wget https://developer.nvidia.com/downloads/embedded/l4t/rXX_release_vYYY/sources/public_sources.tbz2/ -O public_sources.tar.gz
XX = release e.g. 35
YYY = revision with dot as seperation e.g. 3.1
So in this example we would have following command:
wget https://developer.nvidia.com/downloads/embedded/l4t/r35_release_v3.1/sources/public_sources.tbz2/ -O public_sources.tar.gz
After downloading the sources, we're extract them and enter the correct directory:
tar xvf public_sources.tar.gz
cd Linux_for_Tegra/source/public/
tar -xvjf kernel_src.tbz2
cd kernel/kernel-5.10
First of all we're taking the default kernel configuration as a basis with the following command:
sudo zcat /proc/config.gz > .config
Then we're switching to configuration mode (please change the path if you're configuring another kernel than the 5.10):
make ARCH=arm64 O=/home/edgekit/kernel/Linux_for_Tegra/source/public/kernel/kernel-5.10 menuconfig
Now we're gonna to activate the module, we want to have within the kernel (in this example Wireguard):
Device Drivers --->
[*] Network device support --->
[*] Network core driver support
<*> WireGuard secure network tunnel
Now we're gonna to build the kernel modules, this takes a while (1-2 hours).
make olddefconfig
make prepare
make modules_prepare
make -j4 Image && make -j4 modules
sudo make modules_install
If our kernel is build we have just an Image - file, which we need to replace on our EdgeKit. Herefore we make a backup of the old image file and copy the new file into the /boot/ directory:
mv /boot/Image /boot/Image_Backup
sudo cp arch/arm64/boot/Image /boot/Image
When testing a custom kernel, it's recommended to have a boot entry to boot from the original kernel. Otherwise we have to reflash the system, which takes longer. For this we take a look to the following file: /boot/extlinux/extlinux.conf
This file is responsible for booting the correct kernel with the chosen device-tree file.
You need to edit the file, the following way:
- Copy the block "LABEL primary" and rename it to "LABEL backup"
- Change in the block "Label backup" the LINUX parameter from
/boot/Imageto/boot/Image_Backup
The content of /boot/extlinux/extlinux.conf should look like the following:
root@edgekit-desktop:/home/edgekit# cat /boot/extlinux/extlinux.conf
TIMEOUT 30
DEFAULT primary
MENU TITLE L4T boot options
LABEL primary
MENU LABEL primary kernel
LINUX /boot/Image
FDT /boot/dtb/kernel_tegra194-p3668-0001-p3509-0000.dtb
INITRD /boot/initrd
APPEND ${cbootargs} root=PARTUUID=7ded6a89-c1c6-42d0-98ff-b05c6b04da91 rw rootwait rootfstype=ext4 console=ttyTCU0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0 video=efifb:off
LABEL backup
MENU LABEL backup kernel
LINUX /boot/Image_Backup
FDT /boot/dtb/kernel_tegra194-p3668-0001-p3509-0000.dtb
INITRD /boot/initrd
APPEND ${cbootargs} root=PARTUUID=7ded6a89-c1c6-42d0-98ff-b05c6b04da91 rw rootwait rootfstype=ext4 console=ttyTCU0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0 video=efifb:off
# When testing a custom kernel, it is recommended that you create a backup of
# the original kernel and add a new entry to this file so that the device can
# fallback to the original kernel. To do this:
#
# 1, Make a backup of the original kernel
# sudo cp /boot/Image /boot/Image.backup
#
# 2, Copy your custom kernel into /boot/Image
#
# 3, Uncomment below menu setting lines for the original kernel
#
# 4, Reboot
# LABEL backup
# MENU LABEL backup kernel
# LINUX /boot/Image.backup
# FDT /boot/dtb/kernel_tegra194-p3668-0001-p3509-0000.dtb
# INITRD /boot/initrd
# APPEND ${cbootargs}
With this configuration, we have two kernels, where we could boot from.
Now it's time to reboot the system. After rebooting the system you shall have all the kernel modules build in. No data from your user-space will be lost.
Greetings from Germany 👋