Linux16.04上安装Xenomai补丁

Linux16.04上安装Xenomai补丁

一、前期准备

预安装工具包

安装gcc软件包
sudo apt install gcc
安装git软件包
sudo apt install git
安装界面编程库
sudo apt install libncurses5-dev
安装make工具包
sudo apt install make
安装词法语法分析包
sudo apt-get install flex bison
安装SSL工具包
sudo apt install libssl-dev
安装ELF工具包
sudo apt install libelf-dev
安装自动化config工具包
sudo apt install automake

准备文件

1、linux内核。
下载链接:https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/linux-4.19.114.tar.gz
2、xenomai补丁。
下载链接:https://gitlab.denx.de/Xenomai/xenomai/-/wikis/home
3、ipipe补丁。
下载链接:https://xenomai.org/downloads/ipipe/v4.x/x86/ipipe-core-4.19.114-cip24-x86-12.patch

/下载 会得到三个文件

压缩文件,提取解压出来
在这里插入图片描述

将ipipe-core-4.19.114-cip24-x86-12.patch移动到linux-4.19.114下面

在这里插入图片描述

将这两个文件移到/usr/src/pkg4路径下,具体路径看个人习惯。

二、安装过程

进入linux-4.19.114打开终端
在这里插入图片描述

ipipe补丁

在$linux-4.19.114路径下,使用xenomai文件下scripts文件下的prepare-kernel.sh脚本,打补丁

lgw@pc:/usr/src/pkg4/linux-4.19.114$../xenomai-3.1/scripts/prepare-kernel.sh  --linux=/usr/src/pkg4/linux-4.19.114 --ipipe=ipipe-core-4.19.114-cip24-x86-12.patch --arch=x86_64 

内核配置

lgw@pc:/usr/src/pkg4/linux-4.19.114$ sudo make menuconfig

General setup —>
Preemption Model (Preemptible Kernel (Low-Latency Desktop)) —>
(X) Low-Latency Desktop

Processor type and features —>
Processor family (Core 2/newer Xeon) —>
(X) Core 2/newer Xeon
[*] Multi-core scheduler support
[ ] CPU core priorities scheduler support

Power management and ACPI options —>
CPU Frequency scaling —>
[ ] CPU Frequency scaling
[*] ACPI (Advanced Configuration and Power Interface) Support —>
< > Processor
CPU Idle —>
[ ] CPU idle PM support

Memory Management options —>
[ ] Contiguous Memory Allocator
[ ] Transparent Hugepage Support
[ ] Allow for memory compaction
[ ] Page migration

Microsoft Hyper-V guest support —>
< > Microsoft Hyper-V client drivers

注:
在这里卡了很久,不知道是版本不一样还是什么原因,
会出现没有**Memory Management options —>**选项的情况
Xenomai会出现下面报错

*** WARNING! Page migration (CONFIG_MIGRATION) may increase ***
*** latency. ***

编译

在$linux-4.19.114路径下,进行编译。会长达一个半小时左右,耐心等待。。。

lgw@pc:/usr/src/pkg4/linux-4.19.114$ sudo make-kpkg --initrd --revision 02 --append-to-version -xeno20210725 kernel_image kernel_headers

编译结束,出现报错:
install: 无法获取’REPORTING-BUGS’ 的文件状态(stat): 没有那个文件或目录
并且出现只生成了一个image.deb包,生成headers.deb失败的情况。
解决办法:在linux-4.19.114下创建一个’REPORTING-BUGS’ 的文件夹

lgw@pc:/usr/src/pkg4/linux-4.19.114$ touch REPORTING-BUGS

再次进行编译
等待。。。
问题解决啦,成功生成两个 .deb文件
在这里插入图片描述

安装内核image和headers

lgw@pc:/usr/src/pkg4$ sudo dpkg -i linux-headers-4.19.114-xeno20210725_02_amd64.deb linux-image-4.19.114-xeno20210725_02_amd64.deb

查看安装是否成功

dpkg -l |grep linux-image
dpkg -l |grep linux-headers

附加内容,如果需要删除内核 ,使用的语句:

sudo dpkg --purge <uname>
example: sudo dpkg --purge linux-image-4.19.114-xeno20210725

编译安装xenomai

这样安装是安装在本机的

lgw@pc:/usr/src/pkg4/xenomai-3.1$ ./configure --with-core=cobalt --enable-smp --enable-pshared
lgw@pc:/usr/src/pkg4/xenomai-3.1$ make
lgw@pc:/usr/src/pkg4/xenomai-3.1$ sudo make insatll

追加xenomai root用户权限

sudo addgroup xenomai --gid 1234
sudo usermod -a -G xenomai $USER

配置启动菜单

sudo gedit /etc/default/grub

具体配置内容有:

GRUB_DEFAULT=“Advanced options for Ubuntu>Ubuntu, with Linux 5.4.105-xenomai-3.1.x”
GRUB_TIMEOUT=3
GRUB_DISTRIBUTOR=lsb_release -i -s 2> /dev/null || echo Debian
GRUB_CMDLINE_LINUX_DEFAULT=“quiet splash xenomai.allowed_group=1234”
GRUB_CMDLINE_LINUX=""

sudo update-grub

三、检验安装是否成功

重启电脑

并在高级选项中,选择linux-4.19.114-xeno20210725 内核启动

查看内核版本

lgw@pc:~$ uname -a 

Linux pc 4.19.114-xeno20210725 #1 SMP Sun Jul 25 21:54:46 CST 2021 x86_64 x86_64 x86_64 GNU/Linux

lgw@pc:~$ dmesg | grep Xenomai

[ 1.027948] [Xenomai] scheduling class idle registered.
[ 1.027949] [Xenomai] scheduling class rt registered.
[ 1.027975] [Xenomai] SMI-enabled chipset found, but SMI workaround disabled
[ 1.027999] I-pipe: head domain Xenomai registered.
[ 1.028888] [Xenomai] allowing access to group 1234
[ 1.028927] [Xenomai] Cobalt v3.1

测试xenomai

先为CPU加负载,不能空载进行测试,需要把负载加进去

sudo apt-get install stress
stress -v -c 8 -i 10 -d 8
注释:
-v显示信息
-c 8 创建8个任务进行开方 
-i 10
-d 8 读写内存文件的操作

在工控机下进行测试,运行latency

lgw@pc:/usr/xenomai/bin$ sudo ./latency

[sudo] lgw 的密码:
== Sampling period: 100 us
== Test mode: periodic user-mode task
== All results in microseconds
warming up…
RTT| 00:00:01 (periodic user-mode task, 100 us period, priority 99)
RTH|----lat min|----lat avg|----lat max|-overrun|—msw|—lat best|–lat worst
RTD| 0.407| 0.752| 26.167| 0| 0| 0.407| 26.167
RTD| 0.257| 0.813| 49.475| 0| 0| 0.257| 49.475
RTD| 0.327| 0.979| 34.103| 0| 0| 0.257| 49.475
RTD| 0.239| 0.793| 28.664| 0| 0| 0.239| 49.475
RTD| 0.162| 0.908| 21.347| 0| 0| 0.162| 49.475
RTD| 0.245| 0.826| 26.866| 0| 0| 0.162| 49.475
RTD| 0.124| 0.739| 38.876| 0| 0| 0.124| 49.475
RTD| 0.411| 0.712| 40.310| 0| 0| 0.124| 49.475
RTD| 0.402| 0.713| 42.715| 0| 0| 0.124| 49.475
RTD| 0.155| 0.703| 35.108| 0| 0| 0.124| 49.475
RTD| -0.148| 0.706| 34.084| 0| 0| -0.148| 49.475
RTD| 0.316| 0.698| 26.084| 0| 0| -0.148| 49.475
RTD| 0.222| 0.689| 32.548| 0| 0| -0.148| 49.475
RTD| 0.408| 0.735| 33.268| 0| 0| -0.148| 49.475
RTD| -0.082| 0.729| 31.051| 0| 0| -0.148| 49.475
RTD| 0.159| 0.698| 43.361| 0| 0| -0.148| 49.475
RTD| 0.100| 0.739| 31.175| 0| 0| -0.148| 49.475
RTD| 0.189| 0.703| 21.755| 0| 0| -0.148| 49.475
RTD| 0.282| 0.785| 45.651| 0| 0| -0.148| 49.475
RTD| 0.206| 0.725| 33.648| 0| 0| -0.148| 49.475
RTD| -0.022| 0.726| 31.233| 0| 0| -0.148| 49.475
RTT| 00:00:22 (periodic user-mode task, 100 us period, priority 99)
RTH|----lat min|----lat avg|----lat max|-overrun|—msw|—lat best|–lat worst
RTD| 0.112| 0.887| 33.053| 0| 0| -0.148| 49.475
RTD| 0.214| 0.875| 25.408| 0| 0| -0.148| 49.475
RTD| 0.233| 0.697| 29.339| 0| 0| -0.148| 49.475
RTD| 0.308| 0.841| 41.140| 0| 0| -0.148| 49.475
RTD| 0.060| 0.703| 32.912| 0| 0| -0.148| 49.475
RTD| 0.171| 0.691| 29.985| 0| 0| -0.148| 49.475
RTD| 0.261| 0.681| 31.464| 0| 0| -0.148| 49.475
RTD| 0.255| 0.713| 40.136| 0| 0| -0.148| 49.475
RTD| 0.198| 0.853| 30.723| 0| 0| -0.148| 49.475
RTD| 0.260| 1.046| 37.206| 0| 0| -0.148| 49.475
RTD| 0.207| 1.051| 45.729| 0| 0| -0.148| 49.475
RTD| 0.406| 1.898| 48.546| 0| 0| -0.148| 49.475
RTD| 0.275| 1.036| 38.506| 0| 0| -0.148| 49.475
RTD| 0.255| 0.796| 24.666| 0| 0| -0.148| 49.475
RTD| 0.406| 1.410| 41.136| 0| 0| -0.148| 49.475
RTD| -0.121| 1.020| 40.668| 0| 0| -0.148| 49.475
^Z
[2]+ 已停止 sudo ./latency

四、参考链接

Ubuntu 18.04/16.04安装xenomai3.1实时内核过程详解
链接: https://kunaly.blog.csdn.net/article/details/109684400.
xenomai3.1+linux 构建linux实时操作系统-基于X86_64和arm
链接: https://blog.csdn.net/qq_22654551/article/details/106038163.
Ubuntu18.04安装xenomai3.1.x实时系统笔记
链接: https://blog.csdn.net/guimotion/article/details/115483150.
【超级详细步骤】Xenomai内核配置选项解决Xenomai/cobalt (NEW)下多种警告的问题
链接: https://blog.csdn.net/weixin_44991673/article/details/106668796.
B站Up主工控小包总(上海翌控科技)的视频,具体讲怎么安装xenomai的视频
链接: https://www.bilibili.com/video/BV1wg4y1z7C2?from=search&seid=8933797624426885751.

  • 3
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值