ubuntu 20.04 RT kernel

1. Choose and download a kernel version and the real-time patch

You have to decide which kernel version to use. We recommend to choose a version as close as possible from the generic kernel corresponding to your Ubuntu version. At the time it was written, in Index of /pub/linux/kernel/projects/rt/5.15/ the last 5.15.x-rt kernel is in patch-5.15.70-rt50.patch.gz. If you choose a different version, simply substitute the numbers. Having decided on a version, use curl to download the source files:

$ mkdir rt-linux; cd rt-linux
$ curl -SLO https://www.kernel.org/pub/linux/kernel/v5.x/linux-5.15.70.tar.gz
$ curl -SLO https://www.kernel.org/pub/linux/kernel/projects/rt/5.15/older/patch-5.15.70-rt50.patch.gz

Decompress them with:

$ tar xvzf linux-5.15.70.tar.gz
$ gunzip patch-5.15.70-rt50.patch.gz 

 Extract the source code and apply the patch:

$ cd linux-5.15.70
$ patch -p1 < ../patch-5.15.70-rt50.patch

2. Configure and build the kernel

First, install the necessary dependencies:

$ sudo apt-get install build-essential bc curl ca-certificates fakeroot gnupg2 libssl-dev lsb-release libelf-dev bison flex

The next step is to configure your kernel: 

$ make oldconfig

This opens a text-based configuration menu. When asked for the Preemption Model, choose the Fully Preemptible Kernel:

Preemption Model
  1. No Forced Preemption (Server) (PREEMPT_NONE)
  2. Voluntary Kernel Preemption (Desktop) (PREEMPT_VOLUNTARY)
  3. Preemptible Kernel (Low-Latency Desktop) (PREEMPT)
> 4. Fully Preemptible Kernel (Real-Time) (PREEMPT_RT) (NEW) 

We recommend keeping all options at their default values. 

Note:

$ vi .config

replacing the line

CONFIG_SYSTEM_TRUSTED_KEYS="debian/canonical-certs.pem"
CONFIG_SYSTEM_REVOCATION_KEYS="debian/canonical-revoked-certs.pem"
CONFIG_DEBUG_INFO_BTF=y

 with

CONFIG_SYSTEM_TRUSTED_KEYS=""
CONFIG_SYSTEM_REVOCATION_KEYS=""
CONFIG_DEBUG_INFO_BTF=n

Afterwards, you are ready to compile the kernel. As this is a lengthy process, set the multi threading option -j to the number of your CPU cores:

$ fakeroot make -j4 deb-pkg

Finally, you are ready to install the newly created package. The exact names depend on your environment, but you are looking for headers and images packages without the dbg suffix. To install:

$ sudo dpkg -i ../linux-headers-5.15.70-rt50*.deb ../linux-image-5.15.70-rt50*.deb

Reboot the computer

3. Allow a user to set real-time permissions for its processes

After the PREEMPT_RT kernel is installed and running, add a group named realtime and add the user controlling your robot to this group:

$ sudo addgroup realtime
$ sudo usermod -a -G realtime $(whoami)

Afterwards, add the following limits to the realtime group in /etc/security/limits.conf:

@realtime soft rtprio 99
@realtime soft priority 99
@realtime soft memlock 102400
@realtime hard rtprio 99
@realtime hard priority 99
@realtime hard memlock 102400

 The limits will be applied after you log out and in again.

----------------------------------------------------------------------------------------------

RT patch: https://www.kernel.org/pub/linux/kernel/projects/rt/
Kernel source: https://www.kernel.org/pub/linux/kernel

1.

$ cd /usr/src/rt_kernal/

$ sudo su

$ xz -cd linux-5.4.182.tar.xz | tar xvf -

$ cd linux-5.4.182

$ xzcat ../patch-5.4.182-rt72.patch.xz | patch -p1

2.

$ cp /boot/config-*-generic .config

3. 

$ make menuconfig

4. 

$ make oldconfig

$ make modules_install

$ make install

5.

$ sudo vi /etc/default/grub

GRUB_TIMEOUT=10
GRUB_DEFAULT="1>2"

$ update-grub

  • 45
    点赞
  • 44
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值