交叉编译器: 3.3.2
# wget -c http://www.busybox.net/downloads/busybox-1.7.0.tar.bz2
# tar jxvf busybox-1.7.0.tar.bz2

修改源码、配置、编译
-----------------------------------------------
# cd busybox-1.7.0
# vi Makefile +176
ARCH            ?= arm
CROSS_COMPILE   ?= /usr/local/arm/3.3.2/bin/arm-linux-

# make menuconfig
Busybox Settings --->
    Build Options --->
        [*] Build BusyBox as a static binary (no shared libs) //(1)
    Installation Options --->
        [*] Don't use /usr               //(2)

Linux System Utilities --->
    [*] mdev                             //(3)
    [*] Support /etc/mdev.conf
    [*] Support command execution at device addition/removal

Shells --->   
    Choose your default shell (msh) ---> //(4)

(1) 这个选项是一定要选择的,这样才能把busybox编译成静态链接的可执行文件,运行时才独立于其他函数库.否则必需要其他库文件才能运行,在单一个linux内核不能使他正常工作。
(2)
这个选项也一定要选,否则make
install后,busybox将安装在原系统的/usr下,这将覆盖掉系统原有的命令.选择这个选项后,make
install后会在busybox目录下生成一个叫_install的目录,里面有busybox和指向他的链接.
(3) 如果没有启动udev,造成/dev下没有设备文件。也就是说所有的设备都没有挂接进来。最新的busybox已经包含了udev的简化版本即mdev,且使用非常简单。 要使用mdev还需要在rootfs中做适当配置。

vi rootfs/etc/init.d/rcS
---------------------------
mount -t tmpfs mdev /dev
mkdir /dev/pts
mount -t devpts devpts /dev/pts
mount -t sysfs sysfs /sys
mount -a
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s

配置linux kernel
-----------------------------------------------
    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

(4) 由于ash功能不够强大,不能支持tab补齐,历史纪录等等的高级功能,所以使用busybox里面的msh代替ash.

因为busybox主要应用于对空间要求非常严格的嵌入式系统,所以它推荐使用uclibc而不鼓励使用glibc,如果你没有安装uclibc,而且在
build Options也选择了Build BusyBox as a static binary(no shared
libs),那肯定无法编译通过的,当然如果你之前build
Options选择的是动态编译的话就不会有这样的问题出现了。假设你是第一种情况,我们可以这样解决:把applets/applets.c开头的几行
warning注释掉

# 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
*/

# make
# make install
这时会在你的编译目录下生成一个_install的目录,里面包含了生成的所有文件和目录结构。

编译时遇到的问题(1):
-----------------------------------------------
如果busybox编译成static linking
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比较大,busybox在寸土寸金的嵌入式系统中运用比较多,所以会有这样的要求。

# vi /busybox-1.7.0/applets/applets.c +20
注释掉20 -- 28行内容即可

miscutils/taskset.c:17: error: parse error before '*' token
-----------------------------------------------
最根本的解决办法是换一个libc库,可是现在还不知道哪个库最合适,唯有暂时将有问题的命令关掉
Miscellaneous Utilities --->
    [ ] taskset

runit/runsv.c: In function `gettimeofday_ns':
-----------------------------------------------

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 (none) --->
        [*] ash

最新文章

  1. 网站banner写法
  2. 大数的除法 不使用BigInteger Java实现
  3. LeetCode(131)Palindrome Partitioning
  4. java内存泄漏
  5. 【CodeForces 504A】Misha and Forest
  6. Grunt之项目脚手架
  7. nginx负载均衡的实现
  8. 成功获取并更改中兴F660光猫的超级用户密码解除四台限制
  9. android从应用到驱动之—camera(2)---cameraHAL的实现
  10. 最大二位子数组和问题(homework-02)
  11. New Lantern Version Available Upgrade Lantern for improved blocking resistance!
  12. 如何用extjs显示一个已经存在的页面
  13. Qwt 折线图 波形图 柱状图示例效果
  14. 获取oracle sql语句中绑定变量值的方法
  15. redis安装方法
  16. XLSTransformer生成excel一个简单的演示示例文件
  17. Base64图片编码优化
  18. Unity资源打包学习笔记(二)、如何实现高效的unity AssetBundle热更新
  19. 数据分组分析—-groupby
  20. oracle service name sid , 用户 和 表空间

热门文章

  1. 1z0-052 q209_10
  2. spring task:annotation-driven 定时任务
  3. vs2013没有代码提法的一种解决办法
  4. Android拍照+方形剪裁——附代码与效果图
  5. eclipse JRE(unbound)问题
  6. 3、eclipse 查看原始类出现The jar file rt.jar has no source attachment解决方法
  7. 【cookie】cookie和session的终极区别
  8. caffe与MATLAB连接踩的坑
  9. 使用springboot遇到的的异常
  10. RHCE7 管理II-6ACL的使用