Chinaunix首页 | 论坛 | 博客
  • 博客访问: 144874
  • 博文数量: 17
  • 博客积分: 1400
  • 博客等级: 上尉
  • 技术积分: 295
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-19 16:50
文章存档

2011年(1)

2010年(1)

2008年(15)

我的朋友

分类: LINUX

2008-05-05 11:44:15

我也来做嵌入式 linux(连载二)
2007年05月10日 星期四 下午 04:33
昨天建好了工作空间,搭建好了交叉编译环境,今天来编译内核

———————————————————————————————————
第三章          内核编译
1、          编译
因为我打算新系统应该支持网桥,而且需要网桥下Netfilter的支持,所以先到sourceforge下载2.4.18内核的网桥补丁bridge-nf-0.0.8-bds-against-2.4.18.diff.gz。我下载的URL:

偷个懒,在Win2000下解压,然后拷贝到内核所在目录
给内核打补丁:
[root@skynet linux-2.4.18]# patch -p1 patching file include/linux/netfilter.h
patching file include/linux/netfilter_ipv4.h
patching file include/linux/skbuff.h
patching file net/bridge/br.c
patching file net/bridge/br_forward.c
patching file net/bridge/br_input.c
patching file net/bridge/br_private.h
patching file net/bridge/Makefile
patching file net/Config.in
patching file net/core/netfilter.c
patching file net/core/skbuff.c
patching file net/ipv4/ip_output.c
patching file net/ipv4/netfilter/ip_tables.c
patching file net/ipv4/netfilter/ipt_LOG.c
patching file net/bridge/br_netfilter.c

开始编译内核:
# make ARCH=i386 CROSS_COMPILE=i386-linux- menuconfig
根据实际情况选择,以前还没有在2.4.18下边做过支持网桥的测试,找了半天没有找到
netfilter (firewalling) support
这个东东,郁闷了,管它的,继续……

# make ARCH=i386 CROSS_COMPILE=i386-linux- clean dep

# make ARCH=i386 CROSS_COMPILE=i386-linux- bzImage

OK,编译完成,673K,稍微大了点,得想办法做到512以下才好,算了,等整个系统做完了,再回头来想办法做这个工作。

因为没有选择内核支持,建立/安装内核的步骤工作又省了……

2、          安装
先将编译好的压缩的内核映像、未压缩的内核映像、内核符号映射文件以及配置文件拷贝到${PRJROOT}/images中:
# cp arch/i386/boot/bzImage ${PRJROOT}/images/bzImage-2.4.18-rmk5
# cp vmlinux ${PRJROOT}/images/vmlinux-2.4.18-rmk5
# cp System.map ${PRJROOT}/images/System-2.4.18-rmk5
# cp .config ${PRJROOT}/images/2.4.18-rmk5

清理内核源码,让它恢复到初始状态:
# make ARCH=i386 CROSS_COMPILE=i386-linux- distclean

3、          测试内核
将bzImage-2.4.18-rmk5拷贝至boot目录下,编译lilo.conf
#vi /etc/lilo.conf
加入如下语句:

image=/boot/bzImage-2.4.18-rmk5
          label=linux-bridge
          root=/dev/hda1
          read-only
          append="root=/dev/hda1"
重新安装lilo:
#lilo
Added linux-bridge
Added linux *

重启系统试试……
还算好,一切顺利,系统启来了……
花费时间:30分钟

总结:
1、编译内核时,没有看到针对2.4.19时,网桥下那个netfilter (firewalling) support选项,是2.4.18本身就没有吗,还是补丁打得不对?没有经验,希望哪位大哥指正;

2、没有仔细根据目标机的实际硬件配置,来精简内核。希望等系统做完整了,能正常运行了,以后再慢慢来把内核精简了^


附,内核选择:
内核编译记录:
Code maturity level options                  不选
Loadable module support                  不选,不用模块支持,全部编译进内核,因为定位一个小型系统,功能非常简单,这样做,虽然扩展性差点,内核大点,不过可以省很多工作;
Processor type and features                  根据实际,选择处理器类型
General setup    --->;
  • Networking support
  • PCI support
    (Any)     PCI access mode
  • PCI device name database
  • System V IPC
  • Sysctl support
    (ELF) Kernel core (/proc/kcore) format
  • Kernel support for ELF binaries
  • Power Management support

    Memory Technology Devices (MTD)    --->;                  MTD设备,我用CF卡,不选

    Parallel port support    --->;                                          不选

    Plug and Play configuration    --->;                                  我的系统用不着即插即用,不选

    Block devices    --->;
  • Loopback device support  
  • RAM disk support
    (4096)     Default RAM disk size (NEW)
  •      Initial RAM disk (initrd) support  

    Multi-device support (RAID and LVM)    --->;    不选

    Networking options    --->;                 
    [ ]     Packet socket: mmapped IO                                                             
    [ ] Netlink device emulation
    [ ]     Network packet filtering debugging (NEW)  
    [ ] Socket Filtering
    [ ]     IP: kernel level autoconfiguration
    [ ]     IP: tunneling
    [ ] The IPX protocol
    [ ] Appletalk protocol support  
    [ ] DECnet Support
    QoS and/or fair queueing    --->; 不选

    ATA/IDE/MFM/RLL support    --->;                    用了默认的

    Telephony Support    --->;                  不选

    SCSI support    --->;                   不选

    Fusion MPT device support    --->;           不选

    I2O device support    --->;                     不选

    Network device support    --->;                    根据实际情况选择

    Amateur Radio support    --->;                   不选   

    IrDA (infrared) support    --->;                  不选

    ISDN subsystem    --->;                          不选

    Old CD-ROM drivers (not SCSI, not IDE)    --->;          不选

    Input core support    --->;                          不选

    Character devices    --->;  
  • Virtual terminal
  •      Support for console on virtual terminal
  • Standard/generic (8250/16550 and compatible UARTs) serial support
  •      Support for console on serial port

    Multimedia devices    --->;                   不选

    File systems    --->;
  • Kernel automounter version 4 support (also supports v3)
  • Virtual memory file system support (former shm fs)
  • /proc file system support
  • Second extended fs support

    Console drivers    --->;
  • VGA text console            调试时接显示器用

    剩下三个都不要
    Sound    --->;
    USB support    --->;  
    Kernel hacking    --->;
  • 补充:

    Networking options   --->;
    [ ] The IPX protocol
    [ ] Appletalk protocol support   
    [ ] DECnet Support
    这三个肯定是不选了,我是在以太网及tcp/ip网络中用的
    [ ]    IP: tunneling
    这个功能偶暂时用不着,就没有选
    [ ]    IP: kernel level autoconfiguration
    内核级的自动配置?不知是拿来做什么用的?查资料没有查到;
    [ ] Socket Filtering
    []Packet socket: mmapped IO
    这两个好像DHCP会用到的,选的时候忽略了……回头添上;
    [ ]    Network packet filtering debugging (NEW)  
    这个也用不上……
    [ ] Netlink device emulation
    这个是拿来做什么的?唔知了……

    阅读(1059) | 评论(0) | 转发(0) |
    给主人留下些什么吧!~~