为omap3530使用BusyBox构建linux文件系统及添加telnet服务

一、设备清单:

1.天漠出产的mini8100核心板,用的是omap3530芯片;

2.linux-2.6.37内核;

3. 1.21.1版本的Busybox;

4.10.04.3版本的ubuntu操作系统;

5.交叉编译工具:arm-2009q1版本的arm-none-linux-gnueabi

二、BusyBox构建文件系统过程

具体参考TI技术文档《Creating a Root File System for Linux on OMAP35x》和chinaunix博客<busybox加入telnet服务>一文http://blog.chinaunix.net/uid-23577224-id-2396417.html

 

首先在Busybox的目录下根据交差编译器来修改Makef文件:

164行: CROSS_COMPILE ?=arm-none-linux-gnueabi-

 

191行: ARCH ?= arm

 

1、新建一个目录来放置文件系统所需要的目录和文件

# mkdir /root/mkdir/rootfs

2、进入BUsyBox解压目录,为了构建BusyBox,在命令行简单输入make,编译应该会在几分钟内完成,当编译完成的时候,将BusyBox安装到target目录中:

~/busybox/busybox-1.21.1# make menuconfig

保存退出好:

~/busybox/busybox-1.21.1#make

~/busybox/busybox-1.21.1# make  CONFIG_PREFIX=/root/mkdir/rootfs    install

3、在新构建的文件系统rootfs目录下仅有3个二进制的子目录bin、sbin、usr和一个linuxrc到bin/busybox符号链接。在文件系统可以使用之前,还必须构建更多的目录,可以通过以下脚本文件构建:

~/mkrootfs/rootfs# vi build_mkdir

 编写以下命令到build_mkdir:

#!bin/sh

mkdir dev

mknod dev/console c 5 1

mkdir dev/pts

mkdir etc

mkdir etc/init.d

mkdir lib

mkdir mnt

mkdir opt

mkdir proc

mkdir root

mkdir sys

mkdir tmp

mkdir var

mkdir var/log

退出保存后,添加权限并运行该脚本后,生成相对于的目录。

4、在etc目录创建文件 etc/fstab

~/mkrootfs/rootfs# cd etc

~/mkrootfs/rootfs/etc# vi fstab

输入以下内容并保存:

proc      /proc         proc         defaults           0   0

none    /dev/pts    devpts     mode=0622    0   0

登陆工具使用 etc目录下的group,hosts,和 passwd文件用于登陆。现在,只需要root定义在group和passwd中,而hosts中只需要定义localhost。3个文件的内容显示在下面:

~/mkrootfs/rootfs/etc# vi group

root:x:0:root

~/mkrootfs/rootfs/etc# vi passwd

root::0:0:root:/:/bin/sh

~/mkrootfs/rootfs/etc# vi  hosts

127.0.0.1  localhost

5、由于busybox默认启动了shadow模式,因此要创建telnet需要的shadow文件,命令和输入内容如下,表示telnet远程登录的用户名为root,密码为123456:

~/mkrootfs/rootfs/etc# vi shadow

 

root:$1$3jZ93Mwq$oaeef6lWIuThavs8wD0Wh1:0:0:99999:7:::
 

6、创建etc/inittab文件,文件内容如下:

~/mkrootfs/rootfs/etc# vi inittab

 

::sysinit:/etc/init.d/rcS

 

# /bin/ash

#

# Start an "askfirst" shell on the serial port

ttyO2::askfirst:-/bin/ash

 

# Stuff to do when restarting the init process

::restart:/sbin/init

 

# Stuff to do before rebooting

::ctrlaltdel:/sbin/reboot

::shutdown:/bin/umount -a -r

::shutdown:/sbin/swapoff -a

 

 

注意:因为omap3530选了串口2为显示调试信息,所用ttyO2::askfirst:-/bin/ash 来等系统加载完rcS文件后,在串口超级终端上来输入命令;又因为用的是linux-2.6.37的内核,串口表示为ttyO2,不同于旧版的ttyS2。

7、创建rcS文件

~/mkrootfs/rootfs/etc# vi init.d/rcS 

 

#!/bin/sh
#   ---------------------------------------------
#   Common settings
#   ---------------------------------------------
HOSTNAME=OMAP3EVM

VERSION=1.0.0

hostname $HOSTNAME

#   ---------------------------------------------
#   Prints execution status.
#
#   arg1 : Execution status
#   arg2 : Continue (0) or Abort (1) on error
#   ---------------------------------------------
status ()
{
       if [ $1 -eq 0 ] ; then
               echo "[SUCCESS]"
       else
               echo "[FAILED]"

               if [ $2 -eq 1 ] ; then
                       echo "... System init aborted."
                       exit 1
               fi
       fi

}

#   ---------------------------------------------
#   Get verbose
#   ---------------------------------------------
echo ""
echo "    System initialization..."
echo ""
echo "    Hostname       : $HOSTNAME"
echo "    Filesystem     : v$VERSION"
echo ""
echo ""
echo "    Kernel release : `uname -s` `uname -r`"
echo "    Kernel version : `uname -v`"
echo ""


#   ---------------------------------------------
#   MDEV Support
#   (Requires sysfs support in the kernel)
#   ---------------------------------------------
echo -n " Mounting /proc             : "
mount -n -t proc /proc /proc
status $? 1

echo -n " Mounting /sys              : "
mount -n -t sysfs sysfs /sys
status $? 1

echo -n " Mounting /dev              : "
mount -n -t tmpfs mdev /dev
status $? 1

echo -n " Mounting /dev/pts          : "
mkdir /dev/pts
mount -t devpts devpts /dev/pts
status $? 1

echo -n " Enabling hot-plug          : "
echo "/sbin/mdev" > /proc/sys/kernel/hotplug
status $? 0

echo -n " Populating /dev            : "
mkdir /dev/input
mkdir /dev/snd

mdev -s
status $? 0

#   ---------------------------------------------
#   Disable power management
#   (Requires sysfs support in the kernel)
#   ---------------------------------------------
#echo -n " Disabling Power mgmt       : "
#echo -n "1" > /sys/power/cpuidle_deepest_state
#status $? 1

#   ---------------------------------------------
#   Turn off LCD after 1 hour of inactivity
#   (Requires sysfs support in the kernel)
#   ---------------------------------------------
#echo -n " Turn off LCD after 1 hour  : "
#echo -n "3600" > /sys/power/fb_timeout_value
#status $? 1


#   ---------------------------------------------
#   Mount the default file systems
#   ---------------------------------------------
echo -n " Mounting other filesystems : "
mount -a
status $? 0


#   ---------------------------------------------
#   Set PATH
#   ---------------------------------------------
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin


#   ---------------------------------------------
#   Start other daemons
#   ---------------------------------------------
echo -n " Starting syslogd           : "
/sbin/syslogd
status $? 0

echo -n " Starting telnetd           : "
/usr/sbin/telnetd
status $? 0

ifconfig eth0 192.168.1.111

#   ---------------------------------------------
#   Done!
#   ---------------------------------------------
echo ""
echo "System initialization complete."


#   ---------------------------------------------
#   Start demo app
#   ---------------------------------------------
#if [[ -x /etc/init.d/demo_start ]]; then
#       echo " Starting Demo Application..."
#       /etc/init.d/demo_start &
#       sleep 5
#fi

保存退出后更改权限:

~/mkrootfs/rootfs/etc# chmod 777 init.d/rcS 

8、添加需要的共享库到rootfs/lib

~/mkrootfs/rootfs/lib#  cp –r ~/arm-2009q1/arm-none-linux-gnueabi/libc/lib/*

~/mkrootfs/rootfs/lib#arm-none-linux-gnueabi-strip *

 

 

一个最小的可工作的文件系统就构建起来了。接着按照天漠的用户手册用工具mkfs.ubifs 和 ubinize来制作ubifs文件系统的镜像文件,通过tftp方式或者SD卡更新的方式把新的文件系统镜像烧写进omap3530.

sudo /root/tools/mkfs.ubifs -r /root/mkrootfs/rootfs -m 2048 -e 129024 -c 1996 -o ubifs.img
sudo /root/tools/ubinize -o ubi.img -m 2048 -p 128KiB -s 512 /root/tools/ubinize.cfg

 

omap3530成功运行后,根据eth0的ip地址再另外新建一个终端运行命令:

telnet 192.168.1.111

输入用户名root,密码123456就可以远程登录到omap3530的用户端。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值