准备工作
apt-get install qt3-apps-dev build-essential kernel-package vim
apt-get install libncurses5-dev (meke menuconfig要调用的)
Step1 下载源码并解压到/usr/src目录下
Get the kernel source (version 2.6.32-21.32) from Ubuntu repository
# apt-get install linux-source-2.6.32=2.6.32-21.32
# wget https://www.rtai.org/RTAI/rtai-3.8.tar.bz2
# tar xjvf linux-source-2.6.32.tar.bz2
# tar xjvf rtai-3.8.tar.bz2
# ln -s linux-source-2.6.32 linux
# cd linux
(实际上我使用的是2.6.35的内核+rtai-3.9)
Step2 打patch
# patch –p1 –b< ../rtai-3.9/base/arch/x86/patches/hal-linux-2.6.35.9-x86-2.8-04.patch
Step3 配置
# make menuconfig
Code maturity level options-> 不选
General Setup->
Support for paging of anonymous memory(swap)选
System V IPC选
BSD Process Accounting选
Loadable Module Support ->
选上Automatic kernel module loading
Processor type and features->
选上Math emulation
去掉Use register arguments
选上Compact VDSO support
Power management options->
Button改成M
Fan改成M
Processor改成M
Thermal Zone改成M
Kernel Hacking –>
去掉Compile the kernel with frame pointers
Step4 编译内核
完成后,先去配置/usr/src/linux-source-2.6.32/linux-source-2.6.35/ubuntu/omnibook /Makefile文件。
不然会出现ld: /ubuntu/omnibook/sections.lds: No such file: No such file or directory错误
在根用户下打开该Makefile文件,将其中的PWD=$(shell pwd)剪切到ifeq ($(KERNELRELEASE),) 前面。然后保存。
If you are using an older RTAI patch you may get the following error: include/linux/ipipe.h:76:2: error: #error "CONFIG_NR_CPUS is too large, please lower it."To fix this disable sparse irq numbering (CONFIG_SPARSE_IRQ=n):Processor type and features ---> Support sparse irq numbering ---> disabled
方法一:手动编译并安装
make clean
make -j4 (-j4是让处理器分成四个线程来编译内核,速度快,推荐CPU好的使用)
make modules_install
make install
生成initrd并修改grub相关文件
# mkinitramfs -o ...
# update-grub
# vi /boot/grub/grub.cfg
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Ubuntu, with Linux 2.6.35.4+rtaitestwensitest' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set e900ef3d-fe04-413b-aaa1-54b61c68430b
linux /boot/vmlinuz-2.6.35.4+rtaitestwensitest root=UUID=e900ef3d-fe04-413b-aaa1-54b61c68430b ro quiet splash
initrd /boot/initrd.img-2.6.35.4+rtaitestwensitest
}
menuentry 'Ubuntu, with Linux 2.6.35.4+rtaitestwensitest (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set e900ef3d-fe04-413b-aaa1-54b61c68430b
echo 'Loading Linux 2.6.35.4+rtaitestwensitest ...'
linux /boot/vmlinuz-2.6.35.4+rtaitestwensitest root=UUID=e900ef3d-fe04-413b-aaa1-54b61c68430b ro single
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-2.6.35.4+rtaitestwensitest
}
方法二:使用ubuntu自带的工具
make-kpkg clean
make-kpkg --initrd --append_to_version rati39 kernel_image kernel_headers
其中--initrd必需要,不然生成不了initrd文件
--append生成多重镜像,也就是在启动菜单里看到的选项
rati39是你自己取的镜像的名字,必须以数字结尾,镜像名字不能大写。
编号内核后,就会显示linux-2.6.20.1rati39最后两项是生成镜像包和头文件包
make完之后,会在上一层目录看到两个deb包
dpkg –i *.deb
可以去/boot目录下看看Vmlinuz、initrd、System.map文件是否都在
最后,reboot
=================================================================================================
RTAI安装
# cd /usr/src/rtai-3.9
# make menuconfig
# make && make install
添加modprobe支持
# mkdir /lib/modules/2.6.32.11+drm33.2.openairinterface/rtai # cp -r /usr/realtime/modules/* /lib/modules/2.6.32.11+drm33.2.openairinterface/rtai/ # depmod -a # export PATH=/usr/realtime/bin:$PATH
Add the following lines at the end of /etc/modules (this loads the rtai modules needed by openair) :
rtai_smi
rtai_fifos
rtai_sem
rtai_math
rtai_sched
rtai_hal
In order to execute it at each terminal launch :
# vim /root/.bashrc Add what follows, to the end of the file # export PATH=/usr/realtime/bin:$PATH
测试
# cd /usr/realtime/testsuite/kern/latency
# ./run