-
Notifications
You must be signed in to change notification settings - Fork 21
Build the linux dfl kernel
One option for using the linux-dfl driver is to simply build the desired kernel from the linux-dfl repo and install it on your system. This should just work for recent distributions; for older distributions you may run into incompatibilities.
If you already have a kernel package from an OFS release, you can skip to "Install the kernel package".
Before you can build a kernel on your system, you will need to make sure that you have the necessary build packages. The necessary tools can be installed individually, or in some cases, by package group.
This page on kernel.org gives an overview of the tool versions required to build a kernel. The list of tools is a superset of what you need. Of particular interest is the minimum gcc version. One implication of this change is that the stock RHEL7/CentOS7 compiler cannot compile mainline kernels newer than version 5.7. The kernel build system will detect the old compiler and simply refuse to build without installing a newer compiler (eg. devtoolset-9).
Package names for the build tools can vary by distribution. The following links are provided as a reference for identifying the development packages that you need to build a kernel. You can ignore most of these content on these pages, but pay special attention to the preparation / prerequisite steps.
git clone https://github.com/OFS/linux-dfl
cd linux-dfl
git checkout fpga-ofs-dev-6.1-lts
Start with the configuration used by your existing kernel. In most cases, this file is available in /boot:
cp /boot/config-`uname -r` .config
Append the configuration parameters required to enable the linux-dfl driver:
cat configs/dfl-config >> .config
Customize the kernel version string to distinguish it as a DFL kernel, and to clearly reference the git source:
echo 'CONFIG_LOCALVERSION="-dfl"' >> .config
echo 'CONFIG_LOCALVERSION_AUTO=y' >> .config
Rebuild the configuration file. This command verifies module dependencies for the current kernel and builds a consistent configuration file. It begins with the configuration parameters from the .config file that you created and accepts the defaults for any unknown configuration parameters:
make olddefconfig
You may see some errors like this:
symbol value 'm' invalid for CHELSIO_IPSEC_INLINE
These errors indicate that the nature of the config has changed between the currently executing kernel and the kernel that you are building. The option "m" for a particular kernel module is no longer a valid option, and the default behavior is to simply turn the option off. However the option can likely be turned back on by setting it to 'y'. If you want to turn the option back on, you can change it to 'y' and re-run "make olddefconfig":
echo 'CONFIG_CHELSIO_IPSEC_INLINE=y' >> .config
make olddefconfig
If you build with CONFIG_LOCALVERSION_AUTO turned off, you may see a '+' character appended to the kernel version. This is an indication that there are commits on the branch beyond the last tagged version of the kernel. If the '+' character creates problems for you, then you can avoid it by setting LOCALVERSION= in your environment:
export LOCALVERSION=
If you would like to make additional changes to your config, the recommended way to do this is through the kernel build menu system:
make menuconfig
You may find that your kernel fails to build due to missing certificates for module signature verification:
make[5]: *** No rule to make target 'debian/canonical-certs.pem', needed by 'certs/x509_certificate_list'. Stop.
make[5]: *** No rule to make target 'debian/canonical-revoked-certs.pem', needed by 'certs/x509_revocation_list'. Stop.
In this case, clear the additional trusted and revocation keyrings:
scripts/config --set-str SYSTEM_TRUSTED_KEYS ''
scripts/config --set-str SYSTEM_REVOCATION_KEYS ''
Linux kernel builds take advantage of multiple processors to parallelize the build process. You can see how many processors are available to you with the nproc command, and then specify how many make threads you want to use with the -j option. Note that number of threads can exceed the number of processors. In this case, I am setting the number of threads to the number of processors in the system.
make -j `nproc`
sudo make -j `nproc` modules_install
sudo make -j `nproc` install
If you want to build a .rpm or .deb kernel package, then you can skip the previous three commands and instead do one of the following:
rpm-pkg: Build both source and binary RPM kernel packages
binrpm-pkg: Build only the binary kernel RPM package
deb-pkg: Build both source and binary deb kernel packages
bindeb-pkg: Build only the binary kernel deb package
If you are concerned about the size of the resulting package and binaries, you can significantly reduce the size of the package and object files by using the make variable INSTALL_MOD_STRIP. For example:
make -j `nproc` INSTALL_MOD_STRIP=1 binrpm-pkg
After building or downloading a binary kernel package, e.g., provided as part of an OFS release, you may install and set the kernel as default for the GRUB2 boot loader as follows.
sudo dnf install ~/rpmbuild/RPMS/x86_64/kernel*-6.1.30_dfl_01743_g76f172659f6a-1.x86_64.rpm
sudo grubby --set-default /boot/vmlinuz-6.1.30-dfl-01743-g76f172659f6a
sudo grubby --update-kernel=ALL --args='intel_iommu=on pci=realloc'
sudo apt install ../linux*_6.1.30-dfl-01743-g76f172659f6a-3_amd64.deb
sudo editor /etc/default/grub
# modify GRUB_DEFAULT to set default kernel
# modify GRUB_CMDLINE_LINUX to set kernel command-line arguments
sudo update-grub
See Manually Setting a Specific Kernel as the Default on the supported values for GRUB_DEFAULT
.