0% found this document useful (0 votes)
86 views

RT Preempt Patch Linux

This document outlines the steps to install a real-time patched Linux kernel on Ubuntu 16.04. It involves downloading Ubuntu 16.04, downgrading the kernel to 4.14, setting up grub to boot the new kernel, obtaining the kernel source code and applying a real-time patch, compiling and installing the patched kernel, and testing the system for improved real-time performance. Configuration changes are recommended during compilation to optimize the kernel for real-time applications.

Uploaded by

lilepytof
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views

RT Preempt Patch Linux

This document outlines the steps to install a real-time patched Linux kernel on Ubuntu 16.04. It involves downloading Ubuntu 16.04, downgrading the kernel to 4.14, setting up grub to boot the new kernel, obtaining the kernel source code and applying a real-time patch, compiling and installing the patched kernel, and testing the system for improved real-time performance. Configuration changes are recommended during compilation to optimize the kernel for real-time applications.

Uploaded by

lilepytof
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

RT-Preempt patch Linux

EtienneAr
April 2019

This document will present what I did to install (patch) real-time Linux.

1 Ubuntu 16.04
1.1 Download and install Ubuntu
I did the install, by downloading Ubuntu 16, and creating a live USB stick. Then I followed the Live USB
instructions.

wget http://releases.ubuntu.com/16.04/ubuntu-16.04.6-desktop-amd64.iso

#Choose the correct device which will be the output (a.k.a ’of’) to create
Live USB.
lsblk

sudo dd if=ubuntu-16.04.6-desktop-amd64.iso of=/dev/sdb status=progress &&


sync

1.2 (optional) Setup ssh connection

# On the freshly installed machine


sudo apt-get install openssh-server
sudo service ssh start

After this step everything can be done remotely :

# On another machine (connected to the same network ...)


ssh login@ip

From now on, everything will be done on the freshly installed machine (either by typing
physically on it, or by using a ssh conneciton).

1.3 Downgrading to kernel 4.14


wget https://kernel.ubuntu.com/˜kernel-ppa/mainline/v4.14.109/linux-headers
-4.14.109-0414109_4.14.109-0414109.201903271718_all.deb
wget https://kernel.ubuntu.com/˜kernel-ppa/mainline/v4.14.109/linux-headers
-4.14.109-0414109-generic_4.14.109-0414109.201903271718_amd64.deb
wget https://kernel.ubuntu.com/˜kernel-ppa/mainline/v4.14.109/linux-image-

1
unsigned-4.14.109-0414109-generic_4.14.109-0414109.201903271718_amd64.
deb
wget https://kernel.ubuntu.com/˜kernel-ppa/mainline/v4.14.109/linux-modules
-4.14.109-0414109-generic_4.14.109-0414109.201903271718_amd64.deb

sudo dpkg -i linux-headers-4.14.109-0414109_4.14.109-0414109.201903271718


_all.deb
sudo dpkg -i linux-headers-4.14.109-0414109-generic_4
.14.109-0414109.201903271718_amd64.deb
sudo dpkg -i linux-modules-4.14.109-0414109-generic_4
.14.109-0414109.201903271718_amd64.deb
sudo dpkg -i linux-image-unsigned-4.14.109-0414109-generic_4
.14.109-0414109.201903271718_amd64.deb

1.4 Setup grub :


Grub can let you select (at boot time) which kernel you want to use. It can be very useful if you want to
try several kernels, patched and not patched. If it is not setup correctly, here is how you can do it :

# Modify grub to boot on one kernel automatically


sudo vim /etc/default/grub
# Modify GRUB_DEFAULT=0 to GRUB_DEFAULT="Advanced options for Ubuntu>
Ubuntu, with Linux 4.14.109-0414109-generic"
# The second part (after ’>’) can be found in the menu entry.
# /!\ To do after a first sudo update-grub :
grep menuentry /boot/grub/grub.cfg

#If grub does not appear at boot time, you need to :


# place "#" symbol at the start of line GRUB_HIDDEN_TIMEOUT=0

sudo update-grub

sudo reboot

1.5 (optional) Get the system info (before changing the kernel too much)

mkdir info
cd info

uname -a > uname.txt


sudo cat /proc/cpuinfo > cpuinfo.txt
lspci > lspci.txt

1.6 (optional/Recommended) Test real-time capabilities


This software will test how your OS handles real time. You should launch it, run some other app while it’s
running and save the result to compare it later after patching your OS.

2
git clone git://git.kernel.org/pub/scm/utils/rt-tests/rt-tests.git
cd rt-tests
git checkout stable/v1.0

sudo apt-get install build-essential libnuma-dev

make
sudo ./cyclictest -a -t -n -p99

1.7 Get kernel and patch source code


sudo passwd root
su

mkdir -p /usr/src/kernels
cd /usr/src/kernels

wget http://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.14.109.tar.gz
wget https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/4.4/patch
-4.14.109-rt57.patch.xz

1.8 Extract code and apply patch


tar xf linux-4.14.109.tar.xz
mv linux-4.14.109 linux-4.4.177-rt57
cd linux-4.14.109-rt57

xz -d ../patch-4.14.109-rt57.patch.xz
patch -p1 <../patch-4.14.109-rt57.patch

cp /boot/config-4.15.x-xxx-generic .config

### You may need this to make the config menu


apt-get install libncurses5-dev

# ’minimum’ configuration
make defconfig

# configure the kernel


make menuconfig
# The main setting to change is :
# * Processor type and features -> Preemption Model : Fully Preemptible
Kernel (RT)
# * ACPI -> (disable) Hibernation
# * Networking -> (disable) Radio Amateur
# * Networking > Wireless -> (disable) powersave
# * Device drivers -> (disable) Macintosh
# * Device drivers > Network > Ethernet driver support -> (disable) every

3
unecessary brand
# * Device drivers > Network > Wireless lan (see list)
# * Device drivers > Network -> (disable) USB
# ... Better settings can be done ...

(a) (b) (c)

Figure 1: List of the recommended drivers for Wireless Network devices

Remark: A lot of optimization can be done during the ’make menuconfig’ step, by disabling everything
that is not necessary.

1.9 Compile
### In my case, I need these to compile ###
apt-get install libsdl1.2-dev libssl-dev

make -j8 #8 is my number of cores


make modules_install install

1.10 Reboot
reboot

4
1.11 Checks
uname -a
sudo cat /proc/cpuinfo
lspci

sudo ./cyclictest -a -t -n -p99

1.12 (Optionnal) Test with ESPNOW Echo code

git clone https://github.com/thomasfla/Linux-ESPNOW.git


cd Linux-ESPNOW/ESPNOW_lib/

make

### Then the usual before testing ###


sudo ifconfig wlan0 down
sudo iwconfig wlan0 mode monitor
sudo ifconfig wlan0 up
sudo iwconfig wlan0 channel 10

sudo ./bin/exec wlan0

2 Miscellaneous
2.1 Remove an installed kernel :
#Current kernel
uname -r
#DO NOT REMOVE IT

dpkg --list ’linux-image-*’


sudo apt-get purge linux-image-x.x.x-x-generic
sudo update-grub2

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy