//在Redhat9上安装RTLinux3.2 >>>> dslab 杨红刚
//更多文章见:http://dslab.lzu.edu.cn/
使用的文件:
rtlinux-3.2-wr.tar.bz2:从风河公司网站免费注册后下载 http://www.rtlinuxfree.com/
linux-2.4.28.tar.bz2 : 可以从兰大开源社区镜像站下载 ftp://mirror.lzu.edu.cn/kernel.org/v2.6/
环境:
处理器:Intel(R) Pentium(R) 4 CPU 2.80GHz
操作系统发行版:RedHat9
----------------------------------------------------------
1. 创建工作目录,解压文件
# mkdir rtlinux
# cd rtlinux
将rtlinux-3.2-wr.tar.bz2, linux-2.4.28.tar.bz2 复制到当前目录
# tar -jxf rtlinux-3.2-wr.tar.bz2
# tar -jxf linux-2.4.28.tar.bz2
2. 编译linux
# cd linux-2.4.28
//给内核打补丁
//补丁测试
# patch -p1 --dry-run <../rtlinux-3.2-wr/patches/kernel_patch-2.4.28-rtl3.2-rc1 //选择对应的补丁版本
如果没有什么错误那么就可以执行如下的命令,打上补丁
# patch -p1 <../rtlinux-3.2-wr/patches/kernel_patch-2.4.28-rtl3.2-rc1
实际上,有个问题:
...
patch: **** malformed patch at line 2061: *+/
...
修改补丁文件
# vim ../rtlinux-3.2-wr/patches/kernel_patch-2.4.28-rtl3.2-rc1
将2061行的 *+/ 修改为 +*/
再重复上面的打补丁的过程
//配置内核
# cp /boot/config-2.4.20-8 .config //将系统上已有的配置文件拷贝过来
# make menuconfig
注意选择Processor family,我的为:Pentium-4
USB support
USB HIDBP Keyboard (basic) support 选上
USB HIDBP Mouse (basic) support 选上
我的鼠标键盘都是 usb接口
其他的默认即可
# make dep
# make bzImage //生成内核镜像
# make modules //生成模块
出现如下错误
...
dn_neigh.c:584: `THIS_MODULE' undeclared here (not in a function)
dn_neigh.c:584: initializer element is not constant
dn_neigh.c:584: (near initialization for `dn_neigh_seq_fops.owner')
make[2]: *** [dn_neigh.o] Error 1
make[2]: Leaving directory `/home/joseph/wf/rtlinux/an/linux-2.4.28/net/decnet'
make[1]: *** [_modsubdir_decnet] Error 2
make[1]: Leaving directory `/home/joseph/wf/rtlinux/an/linux-2.4.28/net'
make: *** [_mod_net] Error 2
在 ./net/decnet/dn_neigh.c 添加
#include
重新生成模块
# make modules_install //模块安装
# cp arch/i386/boot/bzImage /boot/vmlinuz-2.4.28-rtl3.2-rc1
# cp System.map /boot/System.map-2.4.28-rtl3.2-rc1
# cd /boot
# mkinitrd initrd-2.4.28-rtl3.2-rc1.img 2.4.28-rtl3.2-rc1
//如果有提示 mkinitrd 不能用,你要把 /sbin 添加到PATH中
# vim ~/.bashrc
添加内容: PATH=/sbin:$PATH
export PATH
# source ~/.bashrc //让设置生效]
//修改grub引导
#vim grub/menu.lst
增加如下内容:
title Red Hat Linux (2.4.28-rtl3.2-rc1-Joseph-Yang)
root (hd0,1)
kernel /vmlinuz-2.4.28-rtl3.2-rc1 ro root=LABEL=/
initrd /initrd-2.4.28-rtl3.2-rc1.img
# reboot //重新引导,如果没有问题就可以启动你新编译的内核了
3. RTLinux编译安装
# cd rtlinux-3.2-wr
# make menuconfig
出现如下错误:
ls: No: 没有那个文件或目录
ls: directory: 没有那个文件或目录
ls: for: 没有那个文件或目录
ls: rtlinux: 没有那个文件或目录
ls: 3.2/include/asm: 没有那个文件或目录
ls: No: 没有那个文件或目录
ls: directory: 没有那个文件或目录
ls: for: 没有那个文件或目录
ls: rtlinux: 没有那个文件或目录
ls: 3.2/include/asm: 没有那个文件或目录
schedulers//Makefile:8: ../rtl.mk: 没有那个文件或目录
ls: No: 没有那个文件或目录
ls: directory: 没有那个文件或目录
ls: for: 没有那个文件或目录
ls: rtlinux: 没有那个文件或目录
ls: 3.2/include/asm: 没有那个文件或目录
ls: No: 没有那个文件或目录
ls: directory: 没有那个文件或目录
ls: for: 没有那个文件或目录
ls: rtlinux: 没有那个文件或目录
ls: 3.2/include/asm: 没有那个文件或目录
ls: No: 没有那个文件或目录
ls: directory: 没有那个文件或目录
ls: for: 没有那个文件或目录
ls: rtlinux: 没有那个文件或目录
ls: 3.2/include/asm: 没有那个文件或目录
ls: No: 没有那个文件或目录
ls: directory: 没有那个文件或目录
ls: for: 没有那个文件或目录
ls: rtlinux: 没有那个文件或目录
ls: 3.2/include/asm: 没有那个文件或目录
ls: No: 没有那个文件或目录
ls: directory: 没有那个文件或目录
ls: for: 没有那个文件或目录
ls: rtlinux: 没有那个文件或目录
ls: 3.2/include/asm: 没有那个文件或目录
Makefile:526: warning: overriding commands for target `install'
schedulers//Makefile:56: warning: ignoring old commands for target `install'
Makefile:600: warning: overriding commands for target `clean'
schedulers//Makefile:6: warning: ignoring old commands for target `clean'
make: *** No rule to make target `../rtl.mk'. Stop.
解决方法是:在 rtlinux-3.2-wr目录下创建linux-2.4.28目录的符号链接:
# cd rtlinux-3.2-wr
# ln -s ../linux-2.4.28 linux //符号链接名为linux
# make menuconfig
采用默认配置,保存即可
# make dep
出现如下的提示:
rm -f .depend
make .depend
make[1]: Entering directory `/home/joseph/wf/rtlinux/an/rtlinux-3.2-wr'
gcc -Wall -O2 -o scripts/mkdep scripts/mkdep.c
Kernel version 2.4.28-rtl3.2-rc1
for x in `find . -name Makefile`; do /
F=`echo $x|sed 's/Makefile$//g'`; /
(cd $F; $RTL/scripts/mkdep *.c *.h *.S > .depend 2>/dev/null); /
done
xargs: environment is too large for exec
make[1]: *** [.depend] Error 1
make[1]: Leaving directory `/home/joseph/wf/rtlinux/an/rtlinux-3.2-wr'
make: *** [dep] Error 2
我没有做任何处理,直接执行
# make
...
Now do "sh scripts/insrtl" to install the modules
# make install
# make regression
有如下提示:
...
./scripts/regression.sh
make: execvp: ./scripts/regression.sh: 权限不够
make: *** [regression] Error 127
# chmod +x ./scripts/regression.sh
# make regression
...
./scripts/regression.sh
----------------------------
- Installing basic modules -
----------------------------
Testing multiple loads of rtl.o... [ OK ]
Testing multiple loads of rtl_time.o... [ OK ]
Testing multiple loads of rtl_sched.o... [ OK ]
Testing multiple loads of rtl_posixio.o... [ OK ]
Testing multiple loads of rtl_fifo.o... [ OK ]
Testing RTLinux fifos... [ OK ]
Testing thread wait times... [ OK ]
Testing that Linux time progresses... [ OK ]
Testing that Linux time is monotonically increasing... [ OK ]
Testing ping flood... [ OK ]
Testing floating-point support... [ OK ]
Removing rtl_sched.o... [ OK ]
Testing periodic timer... [ OK ]
Testing oneshot timer... [ OK ]
# rtlinux start
...
Scheme: (-) not loaded, (+) loaded
(+) mbuff
(+) rtl_fifo
(+) rtl
(+) rtl_posixio
(+) rtl_sched
(+) rtl_time
# rtlinux stop
rmmod: rtl is in use
Scheme: (-) not loaded, (+) loaded
(-) mbuff
(-) rtl_fifo
(-) rtl
(-) rtl_posixio
(-) rtl_sched
(-) rtl_time
4. 应用例子
# cd examples/hello
# rtlinux start
# insmod hello.o
Warning: loading hello.o will taint the kernel: no license
See http://www.tux.org/lkml/#export-tainted for information about tainted modules
Module hello loaded, with warnings
#lsmod
Module Size Used by Tainted: P
hello 1160 0 (unused)
rtl_sched 30752 0 [hello]
rtl_fifo 10752 0 (unused)
rtl_posixio 8052 0 [rtl_fifo]
rtl_time 7020 0 [hello rtl_sched rtl_posixio]
rtl 20752 0 [hello rtl_sched rtl_fifo rtl_posixio rtl_time]
mbuff 7852 0 (unused)
parport_pc 19204 1 (autoclean)
lp 8548 0 (autoclean)
parport 36512 1 (autoclean) [parport_pc lp]
autofs 12244 0 (autoclean) (unused)
8139too 17224 1
mii 3992 0 [8139too]
ehci-hcd 21064 0 (unused)
usb-ohci 21864 0 (unused)
usbcore 78816 1 [ehci-hcd usb-ohci]
ext3 71460 2
jbd 51492 2 [ext3]
--------------------------------------------------------------------------------------------------
注意:你在运行例子程序时如果发现有类似的提示:
/bin/sh: line 1: scripts/insrtl: 权限不够
只要给相应的文件添加可执行权限即可
# chmod +x scripts/insrtl