修改源码、配置、编译
-----------------------------------------------
# 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) 成功移植完2.6.19后,由于没有启动udev,造成/dev下没有设备文件。也就是说所有的设备都没有挂接进来。最新的busybox已经包含了udev的简化版本即mdev,且使用非常简单。 要使用mdev还需要在root filesystem中做适当配置。
(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的目录,里面包含了生成的所有文件和目录结构。
为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
编译时遇到的问题(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
文章评论(0条评论)
登录后参与讨论