Chinaunix首页 | 论坛 | 博客
  • 博客访问: 620591
  • 博文数量: 168
  • 博客积分: 1053
  • 博客等级: 少尉
  • 技术积分: 1187
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-30 17:20
个人简介

公众号【嵌入式er笔记】持续记录和分享C/C++、Linux、ARM、Android、IoT等技术相关知识,以及职场、生活经验和感悟。

文章分类

全部博文(168)

分类:

2012-12-13 10:55:45

1 解压缩linux内核及rtai源码

[root@haitao-desktop ~]# cd /usr/src

[root@haitao-desktop src]# tar jxvf linux-2.6.7.tar.bz2

[root@haitao-desktop src]# tar jxvf rtai-3.1.tar.bz2


2 针对linux-2.6.7rtai-3.1补丁

[root@haitao-desktop src]# cd linux-2.6.7

[root@haitao-desktop linux-2.6.7]# patch -p1 < ../rtai-3.1/rtai-core/arch/i386/patches/hal6-2.6.7.patch

patching file Documentation/adeos.txt

patching file Makefile

patching file adeos/Kconfig

patching file adeos/Makefile

patching file adeos/generic.c

patching file adeos/x86.c

patching file arch/i386/Kconfig

patching file arch/i386/kernel/Makefile

patching file arch/i386/kernel/adeos.c

patching file arch/i386/kernel/apic.c

patching file arch/i386/kernel/cpu/mcheck/p4.c

patching file arch/i386/kernel/entry.S

patching file arch/i386/kernel/i386_ksyms.c

patching file arch/i386/kernel/i8259.c

patching file arch/i386/kernel/io_apic.c

patching file arch/i386/kernel/irq.c

patching file arch/i386/kernel/nmi.c

patching file arch/i386/kernel/process.c

patching file arch/i386/kernel/signal.c

patching file arch/i386/kernel/smp.c

patching file arch/i386/kernel/smpboot.c

patching file arch/i386/kernel/time.c

patching file arch/i386/kernel/timers/timer_tsc.c

patching file arch/i386/kernel/traps.c

patching file arch/i386/mm/fault.c

patching file include/asm-i386/adeos.h

patching file include/asm-i386/io_apic.h

patching file include/asm-i386/mach-default/do_timer.h

patching file include/asm-i386/mach-default/irq_vectors.h

patching file include/asm-i386/mach-pc9800/do_timer.h

patching file include/asm-i386/mach-pc9800/irq_vectors.h

patching file include/asm-i386/mach-visws/do_timer.h

patching file include/asm-i386/mach-visws/irq_vectors.h

patching file include/asm-i386/smp.h

patching file include/asm-i386/system.h

patching file include/linux/adeos.h

patching file include/linux/init_task.h

patching file include/linux/preempt.h

patching file include/linux/sched.h

patching file init/main.c

patching file kernel/Makefile

patching file kernel/adeos.c

patching file kernel/exit.c

patching file kernel/fork.c

patching file kernel/panic.c

patching file kernel/printk.c

patching file kernel/sched.c

patching file kernel/signal.c

patching file kernel/sysctl.c

要分析x86系统上的RTAI实现,patch对于我们来说是最好的一个入口点了。


3、配置内核

[root@haitao-desktop linux-2.6.7]# cp /boot/config-2.6.9-22.EL .config

直接将rhas4发行版的config文件复制过来,这样省了我们不少的配置工作,后面就只要在此基础上进行少量的配置修改便可。

[root@haitao-desktop linux-2.6.7]# make menuconfig

Loadable module support

[*] Enable loadble module support

[*] Module unloading

[*] Forced module unloading

[ ] Module versioning support (EXPERIMENTAL)

[*] Automatic kernel module loading


Processor type and features

[*] Preemptible Kernel

[ ] Use register arguments (EXPERIMENTAL)


Device drivers -> Character devices

[M] Enable Real Time Clock Support


Adeos Support

<*> Adeos support (NEW)


Kernel hacking

[ ] Compile the kernel with frame pointers

4、编译Linux内核

[root@haitao-desktop linux-2.6.7]# make bzImage

[root@haitao-desktop linux-2.6.7]# make modules

[root@haitao-desktop linux-2.6.7]# make modules_install

呵呵,以上几步工作可是最费时的,还是泡杯咖啡、打开音乐先享受一番了;当然,要是你有受虐倾向的话,强烈建议死死盯着显示屏,包你满意 : p

5、安装新编译的linux内核

[root@haitao-desktop linux-2.6.7]# make install

这一步可算是劳苦功高了,看看/boot目录下是不是一切都为我们准备好了,包括initrd-2.6.7-adeos.imgvmlinuz-2.6.7-adeosSystem.map-2.6.7-adeos。而且,grub引导项也自动为我们添加了,当然对于引导项后面还要作一点小的修改。

[root@haitao-desktop linux-2.6.7]# df -h    

Filesystem 容量 已用 可用 已用% 挂载点

/dev/sda1 9.7G 5.3G 3.9G 58% /

none 125M 0 125M 0% /dev/shm

/dev/sda2 4.2G 160M 3.9G 4% /home
可知,/目录的挂载点是/dev/sda1,这在下面的引导项中root要用到。

[root@haitao-desktop linux-2.6.7]# vi /boot/grub/grub.conf

make install之后生成了如下的引导项:

title Red Hat Enterprise Linux AS (2.6.7-adeos)

root (hd0,0)

kernel /boot/vmlinuz-2.6.7-adeos ro root=LABEL=/ rhgb quiet

initrd /boot/initrd-2.6.7-adeos.img

将其修改为:(区别在root处)

title Red Hat Enterprise Linux AS (2.6.7-adeos)

root (hd0,0)

kernel /boot/vmlinuz-2.6.7-adeos ro root=/dev/sda1

initrd /boot/initrd-2.6.7-adeos.img

6、重启以使用新编译内核

[root@haitao-desktop linux-2.6.7]# reboot

引导时,选择“Red Hat Enterprise Linux AS (2.6.7-adeos)”项,呵呵,激动人心的时刻到来了,千万不要panic了,没关系,即便出现了我们再尝试解决问题就是。然而结果是好的,顺利进入系统之后,运行如下命令:

[root@haitao-desktop ~]# uname –a

Linux haitao-desktop 2.6.7-adeos #1 Wed Apr 23 03:09:26 CST 2008 i686 athlon i386 GNU/Linux

可见现在已经是使用我们新编译的内核2.6.7-adeos,当然在VMware里日期时间有些问题,懒得管了,继续下面我们的RTAI编译安装吧!


7、配置RTAI

[root@haitao-desktop rtai-3.1]# make menuconfig

General

(/usr/src/linux-2.6.7) Linux Source tree

[*] Enable source compatibility mode

[*] Enable extended configuration mode


一定要记得,linux源码树位置一定是指向自己新编译的内核/usr/src/linux-2.6.7,其它的就使用缺省配置吧,以后确实要用到什么,再重新配置就可以。记得最后要保存对配置文件所做的修改。

8、编译RTAI

[root@haitao-desktop rtai-3.1]# make


9、安装RTAI

[root@haitao-desktop rtai-3.1]# make install

安装目录有make menuconfig中已经指定了,我们使用的是缺省的/usr/realtime目录。


10、测试RTAI

[root@haitao-desktop rtai-3.1]# cd /usr/realtime/testsuite/kern/latency

[root@haitao-desktop latency]# ./run

[root@haitao-desktop latency]# ls

display latency_rt.ko run

[root@haitao-desktop latency]# ./run

*

*

* Type ^C to stop this application.

*

*


## RTAI latency calibration tool ##

# period = 100000 (ns)

# avrgtime = 1 (s)

# check overall worst case

# do not use the FPU

# start the timer

# timer_mode is oneshot


2008/04/23 08:00:06 min: -4498 max: 15130864 average: 154531

2008/04/23 08:00:07 min: -4498 max: 15749943 average: 161019

2008/04/23 08:00:08 min: -4498 max: 15749943 average: 131757

2008/04/23 08:00:09 min: -4498 max: 15749943 average: 100065

2008/04/23 08:00:10 min: -4498 max: 15749943 average: 112296

2008/04/23 08:00:11 min: -4498 max: 15749943 average: 134921

2008/04/23 08:00:12 min: -4498 max: 15749943 average: 150379

2008/04/23 08:00:12 min: -4498 max: 15749943 average: 150379


梦寐以久的RTAI是不是就跑起来了,是时候站起身来活动活动了,在电脑前面呆久了可不好 : - )







阅读(1024) | 评论(0) | 转发(0) |
0

上一篇:shell 特殊符号及条件判断

下一篇:EMC2

给主人留下些什么吧!~~