Chinaunix首页 | 论坛 | 博客
  • 博客访问: 556800
  • 博文数量: 114
  • 博客积分: 1620
  • 博客等级: 上尉
  • 技术积分: 1104
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-30 09:16
文章分类

全部博文(114)

文章存档

2016年(1)

2015年(2)

2014年(4)

2013年(9)

2012年(20)

2011年(78)

分类: 嵌入式

2011-04-22 20:32:51

交叉编译busybox1.15.2 并制作ramdisk

1.解压软件包

tar jxvf busybox-1.15.2.tar.tar

2.修改Makefile

     CROSS_COMPILE ?= arm_linux-

     ARCH = arm
     ##ARCH ?= $(SUBARCH)

3.make menuconfig

     Busybox Settings --->
         General Configuration --->
         去掉[ ] Use the devpts filesystem for Unix98 PTYs //为了使telnetd服务更方便使用,将这个选项去掉
      Busybox Settings --->
         Build Options --->
          选择 [*] Build shared libbusybox
          去掉[ ]Produce a binary for each applet, linked against libbusybox               
          去掉[ ]Produce additional busybox binary linked against libbusybox
                           
         (/usr/local/cross-tools/bin/arm_linux-) Cross Compiler prefix //设置交叉编译工具
      Busybox Settings --->
         Installation Options --->
          去掉 [ ] Don't use /usr                        // make install时,生成/usr 目录
         (../../Rootfs/rootfs_rita/) BusyBox installation prefix   //设置busybox的安装路径
       Busybox Settings --->
         Busybox Library Tuning --->
         选择[*]   vi-style line editing commands
         选择[*]   Fancy shell prompts        //为了设置PS1, 是/u,/h,/w等特殊字符生效,必须选上
   
       Coreutils --->
         去掉[ ] fsync                  
       Miscellaneous Utilities --->
         去掉[ ] ionice
         去掉[ ] watchdog
    
       Networking Utilities --->
         去掉[ ] ifenslave
   
      如果用inetd启动telnetd服务,则  
        Networking Utilities --->    
           去掉[ ]   Support standalone telnetd (not inetd only)
      如果直接启动telnetd服务,则
         Networking Utilities --->  
          选择[*]   Support standalone telnetd (not inetd only)
       Login/Password Management Utilities  
         去掉[ ]   Support for /etc/nologin
         去掉[ ]   Support for /etc/securetty     //使root用户能登录到板子上

4.make

5.make install

配置/etc/inittab ,内容如下:

console::sysinit:-/etc/rc
ttySL0::respawn:/sbin/getty -L ttySL0 115200 vt100
::restart:/sbin/init
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
::shutdown:/sbin/swapoff -a


板子启动时,出现如下出错信息:
*** 问题 1 ***
Warning: unable to open an initial console.
解决方法:   
     在/dev/目录下,增加两个设备:
      /dev/ttySL0
      /dev/console

*** 问题 2 ***
Kernel panic - not syncing: No init found. Try passing init= option to kernel.
解决方法:
因为这里使用的init程序是busybox中的命令,所以先用ldd命令查看busybox的相关库:
bash-2.05b# arm_linux-ldd busybox
        libcrypt.so.1 => /usr/local/cross-tools/target/lib/libcrypt.so.1 (0xdead1000)
        libc.so.6 => /usr/local/cross-tools/target/lib/libc.so.6 (0xdead2000)
        /lib/ld-linux.so.2 => /usr/local/cross-tools/target/lib/ld-linux.so.2 (0xdead3000)
很明显可以看出:
     busybox所需要的库为: libcrypt.so.1,libc.so.6,/lib/ld-linux.so.2
去/usr/local/cross-tools/target/lib目录下拷贝这三个库文件到ramdisk的/lib目录下;
如果,不知道/dev下下有哪些设备节点,可以使用如下命令,自动生成/dev目录下的设备节
     touch /etc/mdev.conf
     /sbin/mdev -s  
*** 问题 3 ***
/usr/sbin/thttpd: unknown user - 'root'
proftd 开启ftp服务出错:
解决方法:
需要库文件:
     libnss_dns.so.2   
     libnss_files.so.2
去/usr/local/cross-tools/target/lib目录下拷贝这两个库文件到ramdisk的/lib目录下
*** 问题 4 ***
     root用户不能登录
解决方法有两种
解决方法一
      在/etc/securetty中增加一行:
         ttySL0
解决方法二
     修改busybox配置:
     Login/Password Management Utilities
      去掉[ ]   Support for /etc/nologin
      去掉[ ]   Support for /etc/securetty
*** 问题 5 ***
   PS1变量设置的特殊字符不生效,如:
     在/root/.profile中,这样设置PS1:
         PS1="[\u@\h \w]# "
     其中,\u \h \w 等特殊字符分别表示的是当前用户、主机名和当前目录,
    但是发现在板子上并没有生效,而是原样显示上述字符:
         [\u@\h \w]\$
解决方法:
     修改busybox的配置
      
       Busybox Settings --->
         Busybox Library Tuning --->
         选择[*]   vi-style line editing commands
         选择[*]   Fancy shell prompts        //为了设置PS1, 是/u,/h,/w等特殊字符生效,必须选上
*** 问题 6 ***

ftp无法登录
C:\Documents and Settings\Administrator>ftp 192.168.0.100

Connected to 192.168.0.100.
220 ProFTPD 1.3.0 Server (RITA FTPD) [192.168.0.100]
User (192.168.0.100:(none)): admin
331 Password required for admin.
Password:
530 Login incorrect.
Login failed.
ftp>
ftp>
ftp>
ftp> by
421 No Transfer Timeout (300 seconds): closing control connection.

C:\Documents and Settings\Administrator>ftp 192.168.0.100
Connected to 192.168.0.100.
220 ProFTPD 1.3.0 Server (RITA FTPD) [192.168.0.100]
User (192.168.0.100:(none)): root
331 Password required for root.
Password:
530 Login incorrect.
Login failed.
ftp> user admin
331 Password required for admin.
Password:
530 Login incorrect.
Login failed.
ftp>
ftp>
ftp>
ftp>
原因:
     /etc/ftpusers 限定了root用户不能登录ftp,
   admin用户就可以登录ftp,用户:admin,密码:admin

C:\Documents and Settings\Administrator>ftp 192.168.0.100
Connected to 192.168.0.100.
220 ProFTPD 1.3.0 Server (RITA FTPD) [192.168.0.100]
User (192.168.0.100:(none)): admin
331 Password required for admin.
Password:
230 User admin logged in.
ftp>
*** 问题 7 ***
板子做telnet服务器,从客户端telnet到板子上时,无法登录
提示信息如下:
[root@Rootfs]# telnet 192.168.0.100
Trying 192.168.0.100...
Connected to 192.168.0.100.
Escape character is '^]'.
Connection closed by foreign host.
开启telnetd服务器的方式有两种:
第一种方式: 通过inetd启动telnetd服务
必须这样设置busybox配置
   Networking Utilities --->
       去掉 [ ]   Support standalone telnetd (not inetd only)
配置/etc/inetd.conf
       [root@RITA ~]# vi /etc/inetd.conf
       telnet stream tcp nowait root /usr/sbin/telnetd telnetd
运行命令:
/usr/sbin/inetd
第二种方式:直接运行telnetd,启动服务
必须这样设置busybox配置:
   Networking Utilities --->
   选择 [*]   Support standalone telnetd (not inetd only)
运行命令:
    /usr/sbin/telnetd
可能出现的问题
1)客户端登录不上,查看/var/log/message,得到如下信息:
cat /var/log/message
Nov 18 10:04:11 RITA daemon.err telnetd[1442]: bind: Address already in use
解决方法:
修改busybox的配置
Networking Utilities --->
       去掉 [ ]   Support standalone telnetd (not inetd only)
cat /var/log/message
2)如果出现如下信息
Nov 18 11:48:50 RITA daemon.err telnetd[1782]: can't find free pty
解决方法一:
修改busybox配置
     Busybox Settings --->
         General Configuration --->
         去掉[ ] Use the devpts filesystem for Unix98 PTYs
解决方法二:
   mkdir /dev/pts
     mount -t devpts devpts /dev/pts //devpts文件系统加载在/dev/pst
     mknod -m 666 /dev/ptmx c 5 2 //使用telnetd所必须的设备文件节点
    
     修改/etc/securetty,增加如下行:

    # psudo terminals used by telnet

       pts/0

       pts/1

       pts/2

       pts/3

       pts/4

       pts/5

       pts/6

       pts/7

经过上述修改后, 客户端应该可以telnet到板子上,信息如下:
在192.168.0.1上运行telnet:(板子ip:192.168.0.100)
在客户端运行命令:
telnet 192.168.0.100 即出现如下登录提示信息:
     Welcome to RITA!
     RITAlogin: root
     Password:
     [root@RITA ~]#
   
调试过程如下:
1525 root      2712 S    /usr/sbin/inetd
1557 root      2644 R    ps
[root@RITA /var/log]# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:49154           0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:49155           0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:23              0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN     
tcp        0      0 ::%1278820:80           ::%1300168:*            LISTEN     
[root@RITA /var/log]# kill 1525
[root@RITA /var/log]# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:49154           0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:49155           0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN     
tcp        0      0 ::%1278820:80           ::%1300168:*            LISTEN
[root@RITA /var/log]# /usr/sbin/inetd
[root@RITA /var/log]# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:49154           0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:49155           0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:23              0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN     
tcp        0      0 ::%1278820:80           ::%1300168:*            LISTEN  
[root@RITA ~]# netstat -lt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:49154           0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:49155           0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:netbios-ssn     0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:ftp             0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:telnet          0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:microsoft-ds    0.0.0.0:*               LISTEN     
tcp        0      0 ::%1278820:http         ::%1300168:*            LISTEN   
说明23号端口,即telnetd已经在监听 ,telet服务已经开启
阅读(2017) | 评论(0) | 转发(0) |
0

上一篇:telnetd 异常中断

下一篇:关于EXPORT_SYMBOL

给主人留下些什么吧!~~