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文件!