1.准备工作
Ubuntu16.04.7基本内核版本是:Linux4.15.0-112-generic
Linux-4.14.134有相同版本的ipipe补丁,且版本相近
Ubuntu16.04.7下载地址:
https://mirrors.aliyun.com/ubuntu-releases/16.04.7/
下载:[ubuntu-16.04.7-desktop-amd64.iso]
Linux-4.14.134下载地址:
https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/
下载:[Linux-4.14.134.tar.gz]
i-pipe-4.14.134下载地址:
https://xenomai.org/downloads/ipipe/v4.x/x86/
下载:[ipipe-core-4.14.134-x86-8.patch]
xenomai-3.1下载地址:
https://xenomai.org/downloads/xenomai/stable/
下载:[xenomai-3.1.tar.bz2]
2.安装必要的组件
2.1初始准备
虚拟机上装好Ubuntu16.04.7,且安装VmwareTools
新安装Ubuntu16.04.7的用户需要更新其软件源:
打开软件源文件:
sudo gedit /etc/apt/source.list
将Ubuntu16.04阿里云软件源替换进去:
deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe
软件源地址为:https://developer.aliyun.com/mirror/ubuntu?spm=a2c6h.13651102.0.0.3e221b11crGtHk
更新软件源:
sudo apt-get update
2.2安装必要的工具
安装配置工具:
sudo apt-get install build-essential libncurses5-dev bison flex libssl-dev
sudo apt-get install kernel-package
3.准备Linux内核
3.1初始准备
桌面创建/xenomai文件夹,文件夹中包含/4.14.134文件夹和[xenomai-3.1.tar.bz2]
/xenomai/4.14.134文件夹中放入[Linux-4.14.134.tar.gz]和[ipipe-core-4.14.134-x86-8.patch]
将[Linux-4.14.134.tar.gz]和[xenomai-3.1.tar.bz2]分别提取到此处(解压缩)
3.2Linux内核打ipipe补丁
此时/xenomai/4.14.134文件夹下装有/linux-4.14.134文件夹和ipipe-core-4.14.134-x86-8.patch
在/xenomai/4.14.134/linux-4.14.134文件夹下打开终端打补丁:
../../xenomai-3.1/scripts/prepare-kernel.sh --ipipe=../ipipe-core-4.14.134-x86-8.patch --arch=x86_64
3.3配置内核
在/xenomai/4.14.134/linux-4.14.134文件夹下打开终端:
make menuconfig
内核配置可以参照:
https://www.doc88.com/p-23047317029295.html
内核配置:
processor type and features --->
Linux guest support ---> N
Processor family ---> Core2
Multi-core scheduler support ---> N
transparent Hugepage Support ---> N
Contiguous Memory Allocator ---> N
Allow for memory compaction ---> N
Page migration ---> N
Power management and ACPI options --->
Suspend to RAM and standby ---> N
Hibernation(aka ‘suspend to disk’) ---> N
CPU Frequency scaling --->N
ACPI ---> Processor --->N
CPU Idle --->N
Memory Management option --->
Xenomai/cobalt(New) --->
Sizes and static limits --->
Number of registry slots ---> 4096
Size of private heap(kb) ---> 4096
Size of shared heap(kb) ---> 4096
Maximum number of POSIX timers per process ---> 512
Drivers --->
RTnet --->
TCP/IP socket interface ---> Y
Drivers --->
New intel® PRO/1000 PCIe ---> Y
Realtek 8169 ---> Y
Add-Ons --->
Real-Time Capturing Support ---> Y
3.4编译内核
添加必要文件,没有这个文件会导致编译失败
在/xenomai/4.14.134/linux-4.14.134文件夹下打开终端:
sudo touch REPORTING-BUGS
编译内核时我们采用单独编译,那也就是说编译的平台不一定运行,而是在高性能的平台编译内核,将其打包;
再拿到需要的低配置或专用平台安装运行。
编译内核打包:
sudo make-kpkg --initrd --revision 2.0 --append-to-version -xeno20220422 kernel_image kernel_headers
编译完成后/xenomai/4.14.134文件夹中出现文件:
[linux-headers-4.14.134-xeno20200422_2.0_amd64.deb]
[linux-image-4.14.134-xeno20200422_2.0_amd64.deb]
4.编译和安装xenomai
我们在本机Ubuntu16.04.7上安装刚刚编译好的内核,当然也可以将上述两个文件拿到其他平台安装
打开终端:
sudo dpkg -i linux-headers-4.14.134-xeno20200422_2.0_amd64.deb
sudo dpkg -i linux-image-4.14.134-xeno20200422_2.0_amd64.deb
在/xenomai/xenomai-3.1文件夹下打开终端:
./configure --with-core=cobalt --enable-smp --enable-pshared
make
sudo make install
xenomai-3.1安装完毕
5.配置启动菜单
更改启动项:
sudo gedit /etc/default/grub
GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
#GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=80
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
更新:
sudo update-grub2