https://smart888.taobao.com/ 立观智能监控
分类: LINUX
2009-05-05 14:09:13
按网上linux系统移植.pdf一文修改
下载 busybox
从 、 busybox1.1.0到/tmp 目录当中,并解压
1. busybox-
在编译busybox-
/opt/busybox-1.1.3/util-linux/util-linux.a(mount.o)(.text+0x5fc): In function `singlemount':
: undefined reference to `del_loop'
collect2: ld returned 1 exit status
make[1]: *** [busybox_unstripped] 错误 1
make: *** [all] 错误 2
在busybox 的mail list里面搜到
[1.1.2] missing build deps for mount
Bernhard Fischer rep.nop at aon.at
Wed Apr 12 01:32:01 PDT 2006
* Previous message: [1.1.2] missing build deps for mount
* Next message: [1.1.2] missing build deps for mount
* Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Apr 11, 2006 at 04:31:12PM -0700, Andre wrote:
>I get the following while trying to build 1.1.2 (and 1.1.1)
> LINK busybox_unstripped
>/home/andre/busybox-1.1.2/util-linux/util-linux.a(mount.o): In
>function `singlemount':
>mount.c:(.text+0x420): undefined reference to `del_loop'
>collect2: ld returned 1 exit status
>
>CONFIG_MOUNT=y
>CONFIG_UMOUNT=y
what's your gcc -v and version of binutils?
You don't seem to have CONFIG_FEATURE_MOUNT_LOOP nor CONFIG_LOSETUP set,
so loopFile should be 0, thus the compiler should have optimized away
the call to del_loop()..
AFAICS from a quick glance, all should be well (modulo toolchain
surprises), so the snippet below should really not be needed.
Alternatively we could stub out the bodies of set_loop and del_loop et
al, but i don't like this.
Index: util-linux/mount.c
===================================================================
--- util-linux/mount.c (revision 14831)
+++ util-linux/mount.c (working copy)
@@ -351,7 +351,7 @@
// If mount failed, clean up loop file (if any).
- if (rc && loopFile) {
+ if (ENABLE_FEATURE_MOUNT_LOOP && rc && loopFile) {
del_loop(mp->mnt_fsname);
if (ENABLE_FEATURE_CLEAN_UP) {
free(loopFile);
故去掉busybox-1.1.3/util-linux/mount.c下面的这么一段, 就编译成功了.
352 // If mount failed, clean up loop file (if any).
353
354 /*if (rc && loopFile) {
355 del_loop(mp->mnt_fsname);
356 if (ENABLE_FEATURE_CLEAN_UP) {
357 free(loopFile);
358 free(mp->mnt_fsname);
359 }
360 }*/
>>最近在华恒论坛上发现一个帖子:
做BUSYBOX的时候,还是获得了一丁点经验
make menuconfig的时候,有个交叉编译器的选项的,在其config.in文件中可以修改交叉编译器。
BUSYBOX
发现的确如此, 去掉了支持2.4内核模块时, 用3.4.1 静态编译busybox 1.2.1 顺利,动态链接编译时也顺利,
但用动态链接做成的文件系统是否能成功 挂载运行, 还没有试。
2.构造目标板的根目录及文件系统
将在这里构建根文件系统,创建基础目录结构. 存放交叉编译后生成的目标应用程序
(BUSYBOX,TINYLOGIN),存放库文件等。
[arm@localhost myproject]# mkdir my_rootfs
[arm@localhost myproject]# pwd
/home/myproject/
[arm@localhost myproject]# cd my_rootfs
[arm@localhost my_rootfs]#
1.2 在 my_rootfs 中建立 Linux 目录树
[arm@localhost my_rootfs]#mkdir bin dev etc home lib mnt proc sbin sys tmp root usr var
[arm@localhost my_rootfs]#mkdir mnt/etc
[arm@localhost my_rootfs]#mkdir usr/bin usr/lib usr/sbin
[arm@localhost my_rootfs]#touch linuxrc
[arm@localhost my_rootfs]#tree
| bin
| dev
| etc
| home
| lib
| linuxrc /* 此文件为启动脚本,是一 shell 脚本文件。本文后面有专门介绍 */
| mnt
| ` etc
| proc
| sbin
| sys
| tmp
| var
| root
` usr
| bin
| lib
` sbin
权限参照你的 linux 工作站即可,基础目录介绍参见本文参考资料(未尾)。
需要说明的一点就是 etc 目录存放配置文件,这个目录通常是需要修改的,所以在 linuxrc 脚本当中将 etc 目录
挂载为 ramfs 文件系统,然后将 mnt/etc 目录中的所有配置文件拷贝到 etc 目录当中,这在下一节的 linuxrc 脚本
文件当中会有体现。
3.编译busybox
3.1 进入解压后的目录,配置 Busybox
[arm@localhost busybox
Busybox Settings >
General Configuration >
[*] Support for devfs
Build Options >
[ ] Build BusyBox as a static binary (no shared libs)
/* 将 busybox 编译为静态连接,少了启动时找动态库的麻烦 ,但不能DNS了(即ping www地址时找不到服务了),故在此我选择动态连接*/
[*] Do you want to build BusyBox with a Cross Compiler?
(/usr/local/arm/
/* 指定交叉编译工具路径 */
Installation Options --->
[ ] Don't use /usr //说明是否也按装到usr目录下,不选表也按装到usr目录下
Applets links (as soft-links) --->
(/home/myproject/creat_rootfs/my_rootfs) BusyBox installation prefix
/* 指定busybox编译后按装路径 */
Busybox Library Tuning ---> //可不管
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 //编译busybox
[* ] command line editing //在shell中命令的自动补全和命令可编辑还是挺方便的。这些功能在busybox1.5以前shell的'command line editing'项在shell的选项内,但是从1.5开始这个选项已经移到'Busybox Settings -> Busybox Library Tuning'中了,如果要在1.5以后的版本中修改相应的选项要在新的地方修改。
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 >
[ ] Enable IPv6 support
[ ] arping
[ ] dnsd
[ ] ether-wake
[ ] fakeidentd
[*] ftpget
[*] ftpput
[*] hostname
[*] httpd
[ ] Support using httpd only from inetd
[*] Enable Basic http Authentication
[ ] Support MD5 crypted passwords for http Authentication
[ ] Support reloading the global config file using hup signal
[ ] Enable support -u
[ ] Support loading additional MIME types at run-time
[*] Support Common Gateway Interface (CGI)
[ ] Enable support for running scripts through an interpreter
[ ] Support the REMOTE_PORT environment variable for CGI
[*] Enable the -e option for shell script CGI simplification.
--- ifconfig
[*] Enable status reporting output (+7k)
[ ] Enable slip-specific options "keepalive" and "outfill"
[ ] Enable options "mem_start", "io_addr", and "irq"
[*] Enable option "hw" (ether only)
[ ] Set the broadcast automatically
[*] ifupdown
[ ] Use ip applet //使用IP程序
[*] Use busybox ifconfig and route applets
[*] Enable support for IPv4
[ ] Enable support for IPv6
[ ] Enable support for IPX
[ ] Enable mapping support
[*] inetd /* * 支持 inetd 超级服务器 * inetd 的配置文件为/etc/inetd.conf 文件,
* "在该部分的 4: 相关配置文件的创建"一节会有说明*/
[*] Support echo service
[*] Support discard service // * 支持丢失服务
[*] Support time service
[*] Support daytime service
[*] Support chargen service
[ ] Support RPC services
[ ] ip
[ ] ipcalc
[ ] ipaddr
[ ] iplink
[ ] iproute
[ ] iptunnel
[ ] nameif
[ ] nc
[*] netstat
[ ] nslookup
[*] ping
[*] Enable fancy ping output
--- route
[ ] telnet
[ ] telnetd
[*] tftp
[*] Enable "get" command
[*] Enable "put" command
[ ] Enable "blocksize" command
[ ] Enable debug
[ ] traceroute
[ ] vconfig
[ ] wget
udhcp Server/Client --->
[*] udhcp Server (udhcpd)
[*] udhcp Client (udhcpc)
[ ] Lease display utility (dumpleases)
[ ] Log udhcp messages to syslog (instead of stdout)
[ ] Compile udhcp with noisy debugging messages
[ ] zcip
其它为相关命令根据须要选择,在此我将所有的都选上了。
3.2.编译并安装 Busybox
[arm@localhost busybox
……………………………………….
[arm@localhost busybox
make instll (将生成 bin,sbin两个文件夹和一个linuxrc文件.
将编译好的命令安装到指定的目录上。
4.Copy相关库文件到lib目录下(参考我的文件系统),下面介绍busybox使用相关库:
VFS: Mounted root (cramfs filesystem) readonly.
Mounted devfs on /dev
Freeing init memory: 88K
Failed to execute /linuxrc. Attempting defaults...
Kernel panic - not syncing: No init found. Try passing init= option to kernel.
添加ld-
re-create the /etc/mtab entries
/bin/mount: error while loading shared libraries: libm.so.6: cannot open shared object file: No such file or directory
/sbin/init: Kernel panic - not syncing: Attempted to kill init!
error while loading shared libraries: libm.so.6: cannot open shared object file: No such file or directory
添加libm.so.6 libm.
re-create the /etc/mtab entries
Reading data from NAND FLASH without ECC is not recommended
mount:
Cannot read /etc/fstab: No such file or directory
/etc/init.d/rcS: line 7: /usr/etc/profile: No such file or directory
in rcS
cardmgr[189]: cannot access /lib/modules/
cardmgr[189]: chdir to /etc/pcmcia failed: No such file or directory
Bummer, could not run '/usr/etc/rc.local': No such file or directory
Please press Enter to activate this console.
Reading data from NAND FLASH without ECC is not recommended
id: unknown gid 0 //须添加libnss_files-
id: unknown uid 0
ln: /dev/touchscreen/0: No such file or directory
/$
文件系统中执行顺序说明:
在文件系统中,配置文件主要存放在 /etc 目录里面。开机从 /linuxrc 脚本运行的话需要在内核传递参数里设置 init=/linuxrc ,因为默认是启动 /sbin/init 初始化脚本的( busybox 编译安装以后生成的 linuxrc 文件是指向 /bin/busybox 的符号文件,应该把它删掉,自己重写脚本)。在我做的文件系统里采用这种方法,所以设置 init=/linuxrc 。 如果不采用 linuxrc 的话就会执行 /sbin/init 脚本( busybox init ),它会去分析 /etc/inittab 脚本(如果没有的话就使用它默认的来代替,一般没必要自己为它编写这个脚本,用它默认的就行),然后会执行 /etc/init.d/rcS 命令(在我制作的文件系统里就把配置都写入了这个文件)。 在rcS文件中将调用etc/fstab挂载相应文件,rcS完成后转回分析etc/inittab脚本,然后会执行/usr/etc/rc.local,在rc.local第一句将调用 /usr/etc/profile文件。最后又回到/etc/inittab脚本去运行sbin/init后启动sh终端。
至于 rcS 、rc.local这个目录的编写主要是安排哪些目录挂载哪些次级文件系统,比如 /proc 要挂载 proc 文件系统、 /sys 要挂载 sysfs 、 /dev/shm 要挂载 tmpfs 、 /tmp 要挂载 ramfs 等等。此外,还可以让内核重新挂载根文件系统也行,具体可以参考 rcS 这个脚本里面的内容,我的是参考友善的那个来写的。另外,可以在这个脚本里执行一些命令,比如设置 ip 地址、建立符号链接(我为 usb 设备的挂载特意建立了 /dev/sda1 的符号链接)、设置主机名等等。 Busybox init 还会调用 /etc/profile 来设置 PATH ,具体请看文件。