Chinaunix首页 | 论坛 | 博客
  • 博客访问: 946707
  • 博文数量: 261
  • 博客积分: 10026
  • 博客等级: 上将
  • 技术积分: 3420
  • 用 户 组: 普通用户
  • 注册时间: 2009-02-24 12:10
个人简介

https://smart888.taobao.com/ 立观智能监控

文章分类

全部博文(261)

文章存档

2011年(1)

2010年(4)

2009年(256)

我的朋友

分类: LINUX

2009-05-05 14:09:13

按网上linux系统移植.pdf一文修改

下载 busybox

busybox­1.1.0/tmp 目录当中,并解压

1. busybox-1.1.3的修改:

在编译busybox-1.1.3,arm-toolchains-3.3.2 编译busybox-1.1.3 ,静态链接, 出现如下问题:
/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文件中可以修改交叉编译器。
BUSYBOX1.2.0
好像是不支持LINUX2.4内核的,如果选支持LINUX2.4内核,在选上INSMODRMOD的时候,就会编译出错
 
发现的确如此, 去掉了支持2.4内核模块时, 3.4.1 静态编译busybox 1.2.1 顺利,动态链接编译时也顺利,
但用动态链接做成的文件系统是否能成功   挂载运行, 还没有试。

 

2.构造目标板的根目录及文件系统

将在这里构建根文件系统,创建基础目录结构存放交叉编译后生成的目标应用程序

BUSYBOXTINYLOGIN),存放库文件等。

[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.编译busybox1.1.0

3.1 进入解压后的目录,配置 Busybox

[arm@localhost busybox­1.1.0]$ make menuconfig

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/3.3.2/bin/arm­linux­) Cross Compiler prefix

/* 指定交叉编译工具路径 */

 

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   //编译busybox1.1.3时我没看到bin/sh的生成

 

[* ]   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 option                              

  [ ]   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­1.1.0]$make

 

……………………………………….

[arm@localhost busybox­1.1.3]$make install

make instll (将生成 bin,sbin两个文件夹和一个linuxrc文件.

将编译好的命令安装到指定的目录上。

4Copy相关库文件到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-2.3.2.so   ld-linux.so.2   库后

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.2.3.2.so 库后

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/2.6.14.7: No such file or directory

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-2.3.2.so  libnss_files.so.2

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 ,具体请看文件。

阅读(2443) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~