在Linux下为嵌入式Linux内核编译busybox

笔者所用的是一块ARM9 Atmel 9200的开发板,Linux内核为2.4.27, 交叉编译器为2.95.3,编译环境为RedHat9 Linux下。

1、从http://www.busybox.net/downloads下载到busybox,笔者下载的为busybox1.1.3,下载后解压到一个目录下,如 /tmp 目录下;

2、进入解压后的目录,输入make menuconfig 进行编译配置,基本的配置如下:
Busybox Settings >                                                              
          General Configuration >                                                
                     [*] Support for devfs                                       
          Build Options >                                                        
                     [*] Build BusyBox as a static binary (no shared libs)       
                           /* 将busybox编译为静态连接,少了启动时找动态库的麻烦 */     
                     [*] Do you want to build BusyBox with a Cross Compiler?     
                       (/usr/local/arm/3.3.2/bin/armlinux)                       
                       Cross Compiler prefix                                     
                          /* 指定交叉编译工具路径 */                                
          Init Utilities >                                                       
                    [*] init                                                     
                    [*] Support reading an inittab file                          
                         /* 支持init读取/etc/inittab配置文件,一定要选上 */          
          Shells >                                                               
                    Choose your default shell (ash) >                            
                        /* (X) ash 选中ash,这样生成的时候才会生成bin/sh文件          
                         * 看看我们前头的linuxrc脚本的头一句:                       
                         * #!/bin/sh 是由bin/sh来解释执行的*/                       
                    [*] ash                                                      
          Coreutils >                                                            
                    [*] cp                                                       
                    [*] cat                                                      
                    [*] ls                                                       
                    [*] mkdir                                                    
                    [*] echo (basic SuSv3 version taking no options)             
                    [*] env                                                      
                    [*] mv                                                       
                    [*] pwd                                                      
                    [*] rm                                                       
                    [*] touch                                                    
         Editors >                                                               
                    [*] vi                                                       
         Linux System Utilities >                                                
                    [*] mount                                                     
                    [*] umount                                                   
                    [*] Support loopback mounts                                  
                    [*] Support for the old /etc/mtab file                       
         Networking Utilities >                                                  
                    [*] inetd                                                    
                       /* 支持inetd超级服务器inetd的配置文件为/etc/inetd.conf文件,   
                        * "在该部分的4: 相关配置文件的创建"一节会有说明*/             

3、编译并安装Busybox
[arm@localhost busybox1.1.3]$make TARGET_ARCH=arm CROSS=/usr/local/arm/2.85.3/bin/arm-linux- PREFIX=/root/arm_9200/rdmnt/ all install

CROSS 为交叉编译器的路径。
PREFIX指明安装路径:就是我们根文件系统所在路径。
* 这里需要注意一点的是,只要install busybox,我们根文件系统下先前建好的linuxrc就会被覆盖为一同名二进
制文件。所以要事先备份我们自己的linuxrc,在安装完busybox后,将linuxrc复制回去就好。
* 如果在编译的过程中出现错误,这可能是某些支持问题,可以在配置的时候把相关的选项去掉试试。
* 如果出现找不到内核版本号的编译错误,可以有两种方法解决:(1)把你的内核源码中的version.h文件拷贝到交叉编译器的包含文件的linux目录下(该方法笔者试验成功);(2)该方法来源于论坛上面的一位朋友,做法为删掉#include <linux/version.h>换成#define UTS_RELEASE "2.4.27"  #define LINUX_VERSION_CODE 132123

 
安装TFTP服务器端和客户端 root@yuanxh-desktop:/# sudo apt-get install tftp tftpd openbsd-inetd C,修改配置文件使用TFTP根目录 root@yuanxh-desktop:/home/yuanxh/at91_works# vi /etc/inetd.conf 在/etc/inetd.conf新行中填入以下内容 tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /tftpboot D,启动服务 root@yuanxh-desktop:/home/yuanxh/at91_works# /etc/init.d/openbsd-inetd restart E,测试服务 root@yuanxh-desktop:/home/yuanxh# touch /tftpboot/aaa root@yuanxh-desktop:/home/yuanxh# vi /tftpboot/aaa root@yuanxh-desktop:/home/yuanxh# tftp 192.168.1.100 tftp> get aaa tftp> quit root@yuanxh-desktop:/home/yuanxh# cat aaa 2,用命令配置NFS服务 A,安装NFS服务器端 root@yuanxh-desktop:/home/yuanxh# apt-get install nfs-kernel-server nfs-common portmap B,配置访问目录及权限 root@yuanxh-desktop:/home/yuanxh/at91_works# mkdir /nfsboot root@yuanxh-desktop:/home/yuanxh/at91_works# chmod 777 /nfsboot root@yuanxh-desktop:/home/yuanxh/at91_works# touch /nfsboot/yuanxh root@yuanxh-desktop:/# vi /etc/exports 在/etc/exports新行中填入以下内容 /nfsboot 192.168.1.0/24(rw,sync) C,启动服务 root@yuanxh-desktop:/# exportfs -ra root@yuanxh-desktop:/# /etc/init.d/portmap restart root@yuanxh-desktop:/# /etc/init.d/nfs-common restart root@yuanxh-desktop:/# /etc/init.d/nfs-kernel-server restart D,测试服务 root@yuanxh-desktop:/# mount 192.168.1.100:/nfsboot /mnt root@yuanxh-desktop:/home/yuanxh# ll /mnt root@yuanxh-desktop:/home/yuanxh# rm -rf /mnt/yuanxh root@yuanxh-desktop:/home/yuanxh# showmount root@yuanxh-desktop:/home/yuanxh# df root@yuanxh-desktop:/home/yuanxh# umount /mnt root@yuanxh-desktop:/home/yuanxh# ll /nfsboot
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值