User Tools

Site Tools


software:linux_real_time

Rtlinux

About Real-Time Linux

Installation

Prerequisites

In order to successfully build and install the Real-Time Linux kernel, several requirements must be met.

  1. A copy of the vanilla kernel source needs to be obtained. The kernel archive can be downloaded from The Linux Kernel Archives or any other kernel.org mirror server. A major kernel version without extra patches is preferred, i.e. 2.6.15 instead of 2.6.15.6.
  2. The Realtime Preemption patch is required. The RT-Preempt version should fit the kernel version used. The appropriate RT-Preempt version is available for download from RT-Preempt Patch. It is highly recommended to choose the kernel version labeled “Latest Stable” by the Open Source Automation Development Lab OSADL. The “Latest Stable” version of the PREEMPT_RT Linux kernel indicates that - although thoroughly tested - there are no known problems that might prevent this kernel from being used in industrial products. The recommended “Latest Stable” PREEMPT_RT kernel version is given here (patch-3.12.40-rt55 at the time of writing).
  3. A Linux distribution of choice should be installed on the computer, if not already present. Ubuntu is recommended. DVD image can be downloaded from Ubuntu download and installed following instructions provided here.

Patching the kernel

Downloaded kernel and patch archives need to be unpacked. It can be done either using any available GUI archive manager or via command line:

$ tar -jxvf linux-<kernel_version>.tar.bz2
$ bunzip2 patch-<patch_version>.bz2

After positioning inside the unpacked kernel source directory, assuming both archives were extracted in the same parent directory, the kernel can be patched with patch level p1:

$ cd linux-<kernel_version>
$ patch -p1 <../patch-<kernel_version>

Configuring the kernel

Before compiling freshly patched kernel, it needs to be properly configured. It is recommended to copy configuration file of the existing distribution:

$ cp /boot/config-`uname -r` .config

This will reduce the number of necessary configuration changes and help avoiding hardware specific options configuration issues. Real-time related options can be configured by invoking the text based kernel configuration menu (requires the ncurses libraries):

$ make menuconfig

Recommended configuration settings, gathered from several sources, are listed below:

  1. Preemption Model should be Fully Preemptible Kernel (RT)
  2. If 64-bit kernel is not selected under Kernel konfiguration, HPET (High Precision Event Timer) Timer Support should be enabled.
  3. Timer frequency should be set to 1000Hz
  4. It is advisable to disable all Power management and ACPI options. However, since rt patch 2.6.18-rt6 activated ACPI option is required to enable high precision timer. Only ACPI Support option should be activated and all other sub-modules like fan, processor or button have to be deactivated as they cause higher latencies.
  5. Debug, trace and diagnostic tools may either increase the kernel size or cause higher latencies. All related options should be disabled unless needed.
  6. Check for stack overflows option should be disabled.
  7. CPU Frequency scaling and all governor options except 'performance' governor should be disabled. Default CPUFreq governor should be set to performance.

Screenshots of all other relevant options (determined through multiple build and installation attempts) are given here TODO fix the link.

Building and installing the kernel

Once all the options are properly configured and saved, the new kernel can be compiled:

$ make -j <jobs>

Number of processes created can be specified with <jobs>. Parameter should be equal to twice the number of cores of the processor used, as this will speed up kernel compilation considerably. Compiled kernel can be installed with:

$ make modules_install install

After system reboot, the newly installed kernel becomes part of the boot menu. GRUB boot loader can be modified with Grub Customizer to make real-time kernel default or to remove the old kernel from the boot menu.

Checking the Kernel

Successfully installed kernel version should contain the tags PREEMPT and RT:

$ uname -v
#1 SMP PREEMPT RT Tue Mar 31 22:14:03 EDT 2015

Resources

Tutorials

Downloads

Other

software/linux_real_time.txt · Last modified: 2017/05/12 09:29 (external edit)