How to install Real Time Kernel patch on Linux - GitMasterNikanjam/C_WiKi GitHub Wiki
https://www.acontis.com/en/building-a-real-time-linux-kernel-in-ubuntu-preemptrt.html
https://askubuntu.com/questions/1349568/installing-real-time-patch-for-ubuntu-20-04
Ubunto pro documentation
No OpenSSL sign-file signing_key.pem leads to error while loading kernel modules
https://stackoverflow.com/questions/51669724/install-rt-linux-patch-for-ubuntu
https://askubuntu.com/questions/1466874/installing-preempt-rt-kernel-on-ubuntu-20-04-5-lts-focal
Install Ubuntu on Real hardware.
create a directory in home dir with
mkdir ~/kernel
and switch into it with
cd ~/kernel
We can go with a browser to https://mirrors.edge.kernel.org/pub/linux/kernel and see if the version is there. You can download it from the site and move it manually from /Downloads to the /kernel folder, or download it using wget by right clicking the link using “copy link location”. Example:
wget https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/linux-x.x.x.tar.gz
unpack it with
tar -xzf linux-5.4.78.tar.gz
download rt_preempt patch matching the Kernel version we just downloaded over at http://cdn.kernel.org/pub/linux/kernel/projects/rt
wget http://cdn.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patch-5.4.78-rt44.patch.gz
unpack it with
gunzip patch-x.x.x-rtxx.patch.gz
Then switch into the linux directory with
cd linux-x.x.x/
and patch the kernel with the realtime patch
patch -p1 < ../patch-x.x.x-rtx.patch
We simply want to use the config of our Ubuntu installation, so we get the Ubuntu config with
cp /boot/config-x.x.x-x-generic .config
Open Software & Updates. in the Ubuntu Software menu tick the ‘Source code’ box
We need some tools to build kernel, install them with
sudo apt-get build-dep linux
sudo apt-get install libncurses-dev flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf fakeroot
sudo apt install build-essential git libssl-dev libelf-dev
To enable all Ubuntu configurations, we simply use
yes '' | make oldconfig
Then we need to enable rt_preempt in the kernel. We call
make menuconfig
and set the following
# Enable CONFIG_PREEMPT_RT
-> General Setup
-> Preemption Model (Fully Preemptible Kernel (Real-Time))
(X) Fully Preemptible Kernel (Real-Time)
# Enable CONFIG_HIGH_RES_TIMERS
-> General setup
-> Timers subsystem
[*] High Resolution Timer Support
# Enable CONFIG_NO_HZ_FULL
-> General setup
-> Timers subsystem
-> Timer tick handling (Full dynticks system (tickless))
(X) Full dynticks system (tickless)
# Set CONFIG_HZ_1000 (note: this is no longer in the General Setup menu, go back twice)
-> Processor type and features
-> Timer frequency (1000 HZ)
(X) 1000 HZ
# Set CPU_FREQ_DEFAULT_GOV_PERFORMANCE [=y]
-> Power management and ACPI options
-> CPU Frequency scaling
-> CPU Frequency scaling (CPU_FREQ [=y])
-> Default CPUFreq governor (<choice> [=y])
(X) performance
Save and exit menuconfig. Now we’re going to build the kernel which will take quite some time. (10-30min on a modern cpu)
make -j `nproc` deb-pkg
If appeared error relative to no git repository exist, then use this command instead of previous command:
make -j `nproc` bindeb-pkg
After the build is finished check the debian packages
ls ../*deb
../linux-headers-5.4.78-rt41_5.4.78-rt44-1_amd64.deb ../linux-image-5.4.78-rt44-dbg_5.4.78-rt44-1_amd64.deb
../linux-image-5.4.78-rt41_5.4.78-rt44-1_amd64.deb ../linux-libc-dev_5.4.78-rt44-1_amd64.deb
Then we install all kernel debian packages
sudo dpkg -i ../*.deb
Now the real time kernel should be installed. Reboot the system and check the new kernel version
sudo reboot
uname -a
Linux ros2host 5.4.78-rt44 #1 SMP PREEMPT_RT Fri Nov 6 10:37:59 CET 2020 x86_64 xx
If you not see new version of kernel after reboot, you should update grub.
Edit grub file by command:
sudo nano /etc/default/grub
you will see inside that file simmilar this:
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'
GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"
# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
comment GRUB_TIMEOUT_STYLE
and change GRUB_TIMEOUT
for your desired timeout in seconds.
reboot system and in advanced option see name of your certain kernel version name eg: "Ubuntu, with Linux 5.4.48-rt77"
change GRUB_DEFAULT
to "Ubuntu, with Linux 5.4.48-rt77" and again reboot system.
- Dont forget use
sudo update-grub
If you see this error:
make[2]: *** [debian/rules:6: build] Errore 2
dpkg-buildpackage: Errore: debian/rules build subprocess returned exit status 2
make[1]: *** [scripts/Makefile.package:77: deb-pkg] Errore 2
make: *** [Makefile:1464: deb-pkg] Errore 2
You can change your config file .config
1- Edit .config file, comment out CONFIG_DEBUG_INFO_BTF, and remove values from CONFIG_MODULE_SIG_KEY, CONFIG_SYSTEM_TRUSTED_KEYS, CONFIG_SYSTEM_REVOCATION_KEYS
2- If compilation fails again, comment out CONFIG_MODULE_SIG_FORCE and CONFIG_MODULE_SIG_ALL in the .config file.