Real-Time kernel setup

To install Ubuntu real-time kernel, you have two choices :

  • Ubuntu Pro

Official guide for Real-Time Linux

14 February 2023 : Canonical today announced the general availability of Real-time Ubuntu 22.04 LTS.

Real-time Ubuntu contains the PREEMPT_RT as describe in the following sentence :

Real-time Ubuntu is an Ubuntu 22.04 LTS kernel with the PREEMPT_RT patches integrated by Canonical. It relies on the Linux Foundation’s upstream project’s 5.15-rt patch set, maintained by Canonical’s Joseph Salisbury.25 Real-time Ubuntu with the out-of-tree PREEMPT_RT patches entered general availability in February 2023.26 By minimising the non-preemptible critical sections in kernel code, the kernel is more preemptive than mainline. Real-time Ubuntu reduces kernel latencies as required by the most exacting workloads by prioritising critical tasks, and helps ensure a time-predictable task execution. By minimising response latency, Real-time Ubuntu aims to ensure time-sensitive applications receive prompt processing by providing deterministic responses to external events.

Ubuntu Pro helps customers and companies to deal with real-time solution requirements. As it’s dedicated to companies, it’s free under the following limits :

Canonical will provide a free tier for personal and small-scale commercial use in line with the company’s community commitment and mission to ease open source access and consumption.

Concerning our case, it might be possible to get the free version as we fit inside ‘community commitment and mission to ease open source access and consumption’.

In the case of personal use or small company, it’s limited to 5 machines per account. Otherwise, we need to get in touch with Canonical customers service to get an offer. As I download the pdf file above, they already contacted me. I didn’t reply. Let me know if you want me to get in touch with them.

Advantages

It’s very fast and don’t require any prior knowledge on kernel compilation.

Having Ubuntu Pro means that we can have support from Canonical.

Drawbacks

It requires to create a Canonical account the contract term for personal use might be broke depending on the project you are working on.

Furthermore, depending on Canonical’s strategic decision we might get blocked at some point if they want to get us pay for the service.

  • Compile kernel by yourself

Another possibility to work around with real time kernel installation is to build it from source.

Advantages

Liberty to install it without having to create a Ubuntu Pro account.

Free to choose the kernel version you want.

Free for long-term

Drawbacks

Need to have some knowledge of Linux and compilation tools.

Time consuming.

Real-time kernel installation from source

sudo apt update
sudo apt install make gcc libncurses-dev libssl-dev flex libelf-dev bison
wget https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/linux-5.15.96.tar.gz
wget https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/5.15/older/patch-5.15.96-rt61.patch.xz
xz -d patch-5.15.96-rt61.patch.xz
tar -xzf linux-5.15.96.tar.gz
cd linux-5.15.96
patch -p1 <../patch-5.15.96-rt61.patch

Then you need to set the configuration of the kernel :

make menuconfig

Activate “Fully Preemptible Kernel (Real-Time)” option from “General setup” / “Preemption Model” then SAVE and EXIT.

image.png

Now you can compile the kernel

make all -j20 #build the kernel and the modules

https://www.acontis.com/en/building-a-real-time-linux-kernel-in-ubuntu-preemptrt.html

You should get the following message when the compilation is done :

Kernel: arch/x86/boot/bzImage is ready  (#2)

You can now run :

sudo make modules_install
sudo make install

Using your current Debian kernel configuration as a starting point

Alternatively, you can use the configuration from a Debian-built kernel that you already have installed by copying the /boot/config-* file to .config and then running make oldconfig to only answer new questions.

If you do this, ensure that you modify the configuration to set:

CONFIG_SYSTEM_TRUSTED_KEYS = ""
CONFIG_SYSTEM_REVOCATION_KEYS = ""

otherwise the build may fail:

make[4]: *** No rule to make target 'debian/certs/test-signing-certs.pem', needed by 'certs/x509_certificate_list'.  Stop.
make[4]: *** Waiting for unfinished jobs....

Troubleshooting

  • vmlinux
BTF: .tmp_vmlinux.btf: pahole (pahole) is not available
Failed to generate BTF for vmlinux
Try to disable CONFIG_DEBUG_INFO_BTF
make: *** [Makefile:1219: vmlinux] Error 1

Solved by doing :

 sudo apt install dwarves

https://ubuntu.com/real-time

https://www.acontis.com/en/ubuntu-linux-realtime-howto.html

https://ubuntu.com/blog/real-time-kernel-technical

https://www.theregister.com/2023/02/20/ubuntu_realtime_capable_edition/

https://www.acontis.com/en/building-a-real-time-linux-kernel-in-ubuntu-preemptrt.html

https://www.youtube.com/watch?v=1RAtZCkVMZs


Copyright © CNRS-AIST JRL, CNRS LIRMM 2015-2024