免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 989 | 回复: 0
打印 上一主题 下一主题

编译busybox [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-12-08 21:12 |只看该作者 |倒序浏览
1、编译busybox

交叉编译器: 3.4.1,我使用的是1.4.1版的BUSYBOX。
# tar jxvf busybox-1.4.1.tar.bz2
修改源码、配置、编译
-----------------------------------------------
# cd busybox-1.4.1
修改 Makefile
ARCH            ?= arm
CROSS_COMPILE   ?= /usr/local/arm/3.4.1/bin/arm-linux-
# make menuconfig
Busybox Settings --->
    Build Options --->
        
  • Build BusyBox as a static binary (no shared libs) //这样就省去了寻找共享库的麻烦
    Installation Options --->
            
  • Don't use /usr               
    Linux System Utilities --->
       
  • mdev                             //成功移植完2.6.19后,由于没有启动udev,造成/dev下没有     设备文件。也就是说所有的设备都没有挂接进来。最新的busybox已经包含了udev的简化版本即mdev,且使用非常简单。 要使用mdev还需要在root filesystem中做适当配置。
       
  • Support /etc/mdev.conf
       
  • Support command execution at device addition/removal
    Shells --->   
        Choose your default shell (ash) --->

       
    # make
    # make install

    这时会在你的编译目录下生成一个_install的目录,里面包含了生成的所有文件和目录结构。
    为mdev的运行准备环境
    -----------------------------------------------
        mdev需要改写/dev和/sys两个目录。所以必须保证这两个目录是可写的(一般会用到sysfs,tmpfs。所以要重新编译内核)。然后在你的启动脚本文件中加入/sbin/mdev –s

    linux-2.6.19 -- make menuconfig
    File systems --->
        Pseudo filesystems --->
            
  • sysfs file system support   
            
  • Virtual memory file system support (former shm fs)
            
  •    Tmpfs POSIX Access Control Lists

    编译busybox时遇到的问题:
    如果是静态编译的话
    Busybox Settings --->
        Build Options --->
            
  • Build BusyBox as a static binary (no shared libs)
    # make
    将会遇到下面问题:
    applets/applets.c:20:2: error: #warning Static linking against glibc produces buggy executables
    applets/applets.c:21:2: error: #warning (glibc does not cope well with ld --gc-sections).
    applets/applets.c:22:2: error: #warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400
    applets/applets.c:23:2: error: #warning Note that glibc is unsuitable for static linking anyway.
    applets/applets.c:24:2: error: #warning If you still want to do it, remove -Wl,--gc-sections
    applets/applets.c:25:2: error: #warning from top-level Makefile and remove this warning.
    make[1]: *** [applets/applets.o] Error 1
    这个警告的定义在applets/applets.c中。将这段警告注释掉就可以了。这段警告的意思是告诉你最好用uclibc编译,而不是用glibc因为glibc比较大,在嵌入式系统中,对空间占用要求较高,所以会有这样的要求。
    # vi /busybox-1.4.1/applets/applets.c +20
    注释掉20 -- 28行内容即可
    # vi applets/applets.c
    /*
    #if ENABLE_STATIC && defined(__GLIBC__) && !defined(__UCLIBC__)
    #warning Static linking against glibc produces buggy executables
    #warning (glibc does not cope well with ld --gc-sections).
    #warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400
    #warning Note that glibc is unsuitable for static linking anyway.
    #warning If you still want to do it, remove -Wl,--gc-sections
    #warning from top-level Makefile and remove this warning.
    #error Aborting compilation.
    #endif
    */
    miscutils/taskset.c:17: error: parse error before '*' token
    -----------------------------------------------

    最根本的解决办法是换一个libc库,可是现在还不知道哪个库最合适,唯有暂时将有问题的命令关掉
    Miscellaneous Utilities --->
        [ ] taskset
    Runit Utilities --->
        [ ] runsv   

    内核启动时遇到的问题:
    “could not run '/bin/sh': No such file or directory”
    解决方法:
    要这样配置:
    Shells --->   
        Choose your default shell (ash) --->      
    如果是这样配置的话,虽然可以生成ash,但不能生成sh,将会在内核启动时出现上面出现的问题:
    Shells --->   
        Choose your default shell (ash) --->
  • ash

    这样,编译完成之后,在busybox目录下会生成一个_install目录,里面有/bin和/sbin以及一个linuxrc文件!


    本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/56388/showart_438738.html
  • 您需要登录后才可以回帖 登录 | 注册

    本版积分规则 发表回复

      

    北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
    未成年举报专区
    中国互联网协会会员  联系我们:huangweiwei@itpub.net
    感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

    清除 Cookies - ChinaUnix - Archiver - WAP - TOP