UBuntu 16.04 RTAI实时系统环境安装配置
UBuntu 16.04 RTAI实时系统环境安装配置
针对ubuntu 系统实时性改造先前已进行说明,此处不再赘述。此次是针对RTAI内核进行编译测试,RTAI作为3大开源linux软实时内核,其性能要高于Preempt-rt,但由于并非随linux主线内核更新,所以存在一定滞后,庆幸的是RTAI也一直在维护,相比xenomai更有优势。RTAI最新版本更新于2021年5月(RTAI-5.3),保守起见此次选用RTAI-5.1版本进行安装测试。考虑到系统层面对实时影响,推荐使用低版本系统,不过本次安装配置流程已在UBuntu18.04上测试通过,且编译运行正常。
【系统环境】:
- 操作系统:ubuntu16.04/ubuntu18.04
- Kernel: Linux-4.9.80
- Path : RTAI-5.1
[TOC]
1.下载ubuntu 4.9.80内核补丁链接
0001-base-packaging.patch
0002-UBUNTU-SAUCE-add-vmlinux.strip-to-BOOT_TARGETS1-on-p.patch
0003-UBUNTU-SAUCE-tools-hv-lsvmbus-add-manual-page.patch
0004-UBUNTU-SAUCE-no-up-disable-pie-when-gcc-has-it-enabl.patch
0005-dh_builddeb-switch-to-Zgzip-to-avoid-dpkg-bug-on-lar.patch
0006-debian-changelog.patch
0007-configs-based-on-Ubuntu-4.9.0-11.12.patch
linux-image-4.9.80-040980-generic_4.9.80-040980.201802031730_amd64.deb
2.下载linux-4.9.80内核文件链接
linux-4.9.80.tar.gz
3.下载RTAI-5.1源码链接
tar Jxf rtai-5.1.tar.bz2
4.通用内核打补丁
1 | cd linux-4.9.80/ |
5.获取通用内核.config配置文件,以此为配置项基础,进行内核修改裁减.
//返回上一层目录
cd ../
dpkg -x linux-image-4.9.80-040980-generic_4.9.80-040980.201802031730_amd64.deb ./configs
//拷贝系统配置文件到linux-4.9.80内核源码目录下
cp ./configs/boot/config-4.9.80-040980-generic ./linux-4.9.80/.config
按照rtai-5.1/README.CONF_RMRKS文档内容要把CONFIG_AUDITSYSCALL改成no,但与v4.4.115内核不同的是v4.9.80中CONFIG_AUDITSYSCALL变量被改成无法修改了,所以要改动一下:
打开v4.9.80/init/Kconfig找到
1 | config AUDITSYSCALL |
修改为:
1 | config AUDITSYSCALL |
6.配置内核
For making the Linux kernel work with RTAI you should check the following settings in the kernel configuration dialog.
This list is updated for RTAI 5.1. For other RTAI versions read /usr/local/src/rtai/README.CONF_RMRKS !
“General setup”:
- Disable “Enable sytem-call auditing support” (AUDITSYSCALL)
- Important: set “Stack Protector buffer overflow detection” (at the bottom of the menu) to “Regular(CC_STACKPROTECTOR_REGULAR) - or even “None” (CC_STACKPROTECTOR_NONE) if the latency test crashes.
“Procesor type an features”:
- Disable “Support x2apic” if present (X86_X2APIC)
Maximum number of CPUs (NR_CPUS), optional, if you want to disable hyperthreading and to reduce the output of RTAI tests in the kernel messages. - Disable “Multi-core scheduler support” (SCHED_MC) (in order to be able to disable CPU frequency scaling, for kernel >= 4.14)
- Enable “Interrupt pipeline” (IPIPE)
- Disable “Support x2apic” if present (X86_X2APIC)
“Power management and ACPI options”:
- In “ACPI (Advanced Configuration and Power Interface) Support”:
- Disable “Processor” (ACPI_PROCESSOR)
- Disable “CPU Frequency scaling” (CPU_FREQ) (sometimes you need to disbale this first in order to be able to disable ACPI_PROCESSOR)
- In “CPU Idle”:
- Disable “CPU idle PM support” (CPU_IDLE)
- In “ACPI (Advanced Configuration and Power Interface) Support”:
“Device Drivers”:
- In “Staging drivers”:
- Deselect “Data acquisition support (comedi)” (COMEDI)
- In “Staging drivers”:
“Kernel hacking”:
- In “Compile-time checks and compiler options”: - Disable “Compile the kernel with debug info” (DEBUG_INFO) Disabling debugging information makes the kernel much smaller. So unless you know that you need it disable it.
- Disable “Tracers” (FTRACE)
Leave the configuration dialog by pressing “Exit” until you are asked “Save kernel config?”. Select “Yes”.
Then the new kernel is being compiled - be patient.
7.编译
make -j8 LOCALVERSION=-rtai-5.1 deb-pkg
8.切换到上一层目录安装
cd ../
sudo dpkg -i linux-image-4.9.80-rtai-5.1_4.9.80-rtai-5.1-1_amd64.deb
sudo dpkg -i linux-headers-4.9.80-rtai-5.1_4.9.80-rtai-5.1-1_amd64.deb
sudo reboot //启动新内核
8.新内核下编译安装rtai用户库及驱动
cd rtai-5.1
make menuconfig
- General —>
- (/opt/rtai-5.1_v4.9.80) Installation directory
- (/usr/src/linux-headers-4.9.80-rtai-5.1+) Linux source tree
- Machine –>
- (4)Number of CPUs(SMP-only)
- Add-ons —>
- [*] Real-Time Driver Model over RTAI
- (128) Number of RTDM file descriptors
- [*] Enable select multiplexing for RTDM services
make
sudo make install
cd /opt/rtai-5.1_v4.9.80/modules
sudo insmod rtai_hal.ko
sudo insmod rtai_sched.ko //如果到这儿没死机就说明rtai安装成功了
sudo insmod rtai_fifos.ko
sudo insmod rtai_sem.ko
sudo insmod rtai_shm.ko
sudo insmod rtai_rtdm.ko