基于IQ80321和arm-linux的软件开发指南 (zz)

来源:互联网 发布:冷光美牙仪的危害 知乎 编辑:程序博客网 时间:2024/04/29 22:01

1 概述

1.1 目的和范围
  说明在INTEL IQ80321开发板上面运行ARM LINUX的过程,包括在主机上建立交
叉编译环境、编译内核、制作根文件系统和引导目标机的方法步骤。
1.2 背景
  单位:华中科技大学信息存储系统重点实验室
   武汉东湖存储技术有限公司
  项目:RAID控制器(RDC)
  RDC核心软件在x86平台、Redhat Linux环境下开发。产品化阶段需要首先移植
到IQ80321平台。计划于2004年7月底完成移植。
1.3 软硬件环境
主机(host)
目标机(target)
硬件环境
PC
Intel IQ80321
操作系统
Redhat Linux 9.0
arm-linux
  
1.4 参考资料
[1] Intel IQ80321 I/O Processor Evaluation Platform Board Manual. Docume
nt Number: 273521-006, November 7, 2002.
[2] RedBoot User's Guide. Document Version 1.5m, July 2001.
[3] The Linux MTD, JFFS HOWTO. (work in progress) v 1.16 2001/08/13.
http://ftp.linux.org.uk/pub/people/dwmw2/mtd/cvs/mtd/mtd-jffs-HOWTO.txt
[4] Intel IQ80321 Development Kit:
 

http://www.intel.com/design/IIO/docs/dvtl_iop321.htm
[5] ARM Linux:
http://www.intel.com/design/IIO/docs/dvtl_iop321.htm
[5] ARM Linux:
dvtl_iop321.htm
[5] ARM Linux:
http://www.arm.linux.org.uk/
[6] BusyBox:
http://www.busybox.net/
[7] JFFS:
http://developer.axis.com/software/jffs/
[8] JFFS2:
http://sources.redhat.com/jffs2/
[9] MTD:
http://www.linux-mtd.infradead.org/
[10] “一步一步的制作 arm-linux 交叉编译环境”,
http://embdev.gotdns.org/articles/toolchain.html
[11] 董晓明.LiPS详细设计说明书(Linux系统裁减指南).2003.6.
[12] Wookey, Chris Rutter, Jeff Sutherland, and Paul Webb. The GNU Toolc
hain for ARM targets HOWTO.
http://www.aleph1.co.uk/armlinux/docs/toolch
ain/toolchHOWTO.pdf
[13]
  



2 交叉编译环境

2.1 概述
  (参考资料[12])
  The toolchain actually consists of a number of components. The main
one is the
  compiler itself gcc, which can be native to the host or a cross-comp
iler. This is
  supported by binutils, a set of tools for manipulating binaries. The
se components are all
  you need for compiling the kernel, but almost anything else you comp
ile also needs the
  C-library glibc. As you will realise if you think about it for a mom
ent, compiling the
  compiler poses a bootstrapping problem, which is the main reason why
generating a
  toolset is not a simple exercise.

2.2 准备
2.2.1 目录结构说明
/root/
以root用户登录,HOME目录,也是当前目录
arm/
与此项工作有关的文件都放在这个目录下面
arm-toolchain/
在这里安装编译生成的ARM工具链(toolchain)
boot/
存放编译生成的内核映像文件
同时把TFTP服务器的根设置在这里
build/
在这里编译,会生成许多临时文件和目标文件
fakeroot/
用于目标机远程NFS挂载的根文件系统
src/
存放软件包的源代码,包括Linux内核源代码
tars/
存放各个软件包的压缩包
  
  我们为建立交叉编译环境的过程写了一个Makefile(相当于实现批处理),下面是Makefile中的一些定义。
  TOPDIR =/root/arm
  PREFIX =$(TOPDIR)/arm-toolchain
  BUILDPATH =$(TOPDIR)/build
  SRCPATH =$(TOPDIR)/src
  TARPATH =$(TOPDIR)/tars
  KERNELPATH =$(SRCPATH)/linux
2.2.2 定义环境变量
  在~/.bashrc文件中追加如下几行(注意:注销、重新登录后才能生效):
  export TARGET=arm-linux
  export PREFIX=/root/arm/arm-toolchain
  export PATH=$PREFIX/bin:$PATH
  或者直接在命令行给出定义。
2.2.3 选择内核版本
  我们现在使用的Linux内核版本为linux-2.4.21-rmk1-ds0-dj9.这也是Intel官
方网站上为IQ80321开发板提供下载的内核版本。本文档以该版本为例。
  有关arm-linux和rmk补丁(Russell King维护)的更多信息(包括最新进展)
请参考这个网站和邮件列表:
  
http://www.arm.linux.org.uk/
  linux-arm-kernel@lists.arm.linux.org.uk
  在决定你的项目使用哪个Linux内核版本的时候,一定要考虑该版本内核是否已经发布了对应的rmk和ds补丁。
  In order to build the entire Linux kernel source with the supplied p
atch, you must have the base kernel, the ARM Linux patch, the Montavista
DS patch. The annotation of the filenaming as follows: patch-2.4.X-rmkY
-dsZ-djV means you must have:
  1. Linux-2.4.X kernel source
  2. patch-2.4.X-rmkY to patch on top
  3. patch-2.4.X-rmkY-dsZ to patch on top of #2
  4. patch-2.4.X-rmkY-dsZ-djV to patch on top of #3
  
2.2.4 下载源代码包
项目
URL
linux 内核
ftp://ftp.kernel.org/pub/linux/kernel/v2.4/
rmk 补丁
ftp://ftp.arm.linux.org.uk/pub/armlinux/kernel/v2.4/
ds 补丁
ftp://source.mvista.com/pub/ds-patches/2.4/
http://csociety.ecn.purdue.edu/~deepak/patches/2.4/
iop 补丁
ftp://source.mvista.com/pub/xscale/iop3xx/2.4/
linux-2.4.21
ftp://ftp.kernle.org/pub/linux/kernel/v2.4/linux-2.4.21.tar.gz
patch-2.4.21-rmk1.bz2
ftp://ftp.arm.linux.org.uk/pub/armlinux/kernel/v2.4/patch-2.4.21-rmk1.bz
2
patch-2.4.21-rmk1-ds0.bz2
ftp://aiedownload.intel.com/df-support/7060/eng/patch-2_4_21-rmk1-ds0.bz
2
ftp://source.mvista.com/pub/xscale/iop3xx/2.4/patch-2.4.21-rmk1-ds0.bz2
patch-2.4.21-rmk1-ds0-dj9.bz2
ftp://aiedownload.intel.com/df-support/7183/eng/patch-2.4.21-rmk1-ds0-dj
9.bz2
ftp://source.mvista.com/pub/xscale/iop3xx/2.4/patch-2.4.21-rmk1-ds0-dj9.
bz2
binutils-2.14.tar.gz
ftp://ftp.gnu.org/gnu/binutils/binutils-2.14.tar.gz
gcc-core-2.95.3.tar.gz
ftp://ftp.gnu.org/gnu/gcc/gcc-2.95.3/gcc-core-2.95.3.tar.gz
gcc-g++2.95.3.tar.gz
ftp://ftp.gnu.org/gnu/gcc/gcc-2.95.3/gcc-g++-2.95.3.tar.gz
glibc-2.2.4.tar.gz
ftp://ftp.gnu.org/gnu/glibc/glibc-2.2.4.tar.gz
glibc-linuxthreads-2.2.4.tar.gz
ftp://ftp.gnu.org/gnu/glibc/glibc-linuxthreads-2.2.4.tar.gz
  
2.3 安装
  注意:行首的”#”表示注释。行尾的”/”表示续行。
2.3.1 安装linux头文件
# 解压缩,打补丁
# 解压缩tar.gz包:tar zxfv filename.tar.gz
# 或者 gzip -dc filename.tar.gz | tar xf -
# 解压缩tar.bz2包:tar jxfv filename.tar.bz2
# 或者 bzip2 -dc filename.tar.bz2 | tar xf -
# 打tar.gz格式补丁:gzip -dc patchfile.tar.gz | patch -p1
# 打tar.bz2格式补丁:bzip2 -dc patchfile.tar.bz2 | patch -p1
[root@lips root]# cd $TOPDIR/src
[root@lips src]# tar zxfv $TOPDIR/tars/linux-2.4.21.tar.gz
[root@lips src]# cd linux-2.4.21
[root@lips linux-2.4.21]# bzip2 -dc $TOPDIR/tars/patch-2.4.21-rmk1.bz2 |
patch -p1
[root@lips linux-2.4.21]# bzip2 -dc $TOPDIR/tars/patch-2.4.21-rmk1-ds0.b
z2 | patch -p1
[root@lips linux-2.4.21]# bzip2 -dc $TOPDIR/tars/patch-2.4.21-rmk1-ds0-d
j9.bz2 | patch -p1
[root@lips linux-2.4.21]# cd ..
[root@lips src]# mv linux-2.4.21 linux-2.4.21-rmk1-ds0-dj9
[root@lips src]# ln -s linux-2.4.21-rmk1-ds0-dj9 linux
[root@lips src]# cd linux
[root@lips linux]# make mrproper
# 修改Makefile
# 把ARCH和CROSS_COMPLIE的定义修改如下:
ARCH = arm
CROSS_COMPLIE = $(PREFIX)/bin/arm-linux-
# 查看 linux/arch/arm/def-configs 目录下面的文件名,表示已经支持的板子
# 用 make ARCH=arm XXX_config 来产生默认配置
# 注意这里要在板子名称后面加上 "_config"
[root@lips linux]# make iq80321_config
*** Default configuration for iq80321 installed
*** Next, you may run 'make oldconfig'
[root@lips linux]# yes "" | make oldconfig
[root@lips linux]# make include/linux/version.h
# 复制头文件
[root@lips linux]# mkdir -p $PREFIX/$TARGET/include
[root@lips linux]# cp -dpR include/linux/ $PREFIX/$TARGET/include/
[root@lips linux]# cp -dpR include/asm-arm/ $PREFIX/$TARGET/include/asm
[root@lips linux]# cd $PREFIX/$TARGET/
[root@lips arm-linux]# ln -s include sys-include
  
2.3.2 编译安装binutils
# 解压缩
[root@lips arm]# cd src
[root@lips src]# tar zxfv $TOPDIR/tars/binutils-2.14.tar.gz
# 编译
[root@lips src]# mkdir –p $TOPDIR/build/binutils
[root@lips src]# cd $TOPDIR/build/binutils/
[root@lips binutils]# $TOPDIR/src/binutils-2.14/configure /
--target=$TARGET /
--prefix=$PREFIX
[root@lips binutils]# make all; make install
# 输出 binutils 的路径到环境变量中
[root@lips binutils]# export PATH=$PREFIX/bin:$PATH
  
2.3.3 编译安装gcc的c编译器
# 解压缩
# 注意:为什么不用 all-in-one 的 gcc-2.95.3.tar.gz 呢?
# all-in-one 的 gcc 包里面有 chill, fortran, java 等语言的编译器,虽然在
下面 configure 时指定 -enable-languages=c,但编译时还是把所有的都编译一便
,这不是我们需要的,而且它也总会有错误。因此我们只编译 C 语言的编译器。后
面第二次编译的时候也是这个问题,我们只编译 C 和 C++ 的编译器。
[root@lips binutils]# cd $TOPDIR/src
[root@lips src]# tar zxfv $TOPDIR/tars/gcc-core-2.95.3.tar.gz
# 修改 gcc 的 t-linux 文件
# 在 t-linux 文件中的 TARGET_LIBGCC2_CFLAGS 上加上 __gthr_posix_h 和 inh
ibit_libc
# 这里使用了 sed 工具来直接编辑文件,是为了方便用脚本实现整个过程
# sed ‘s/被替换的字符串/新字符串/’
# < 和 > 在 shell 中表示重定向
# 也就是说sed所处理的内容从 t-lingux.orig 文件输入
# 结果输出到 t-linux-core 文件中去
[root@lips src]# cd gcc-core-2.95.3/gcc/config/arm
[root@lips arm]# mv t-linux t-linux.orig
[root@lips arm]# sed 's/TARGET_LIBGCC2_CFLAGS =/TARGET_LIBGCC2_CFLAGS =
-D__gthr_posix_h -Dinhibit_libc/' < t-linux.orig > t-linux-core
[root@lips arm]# cp t-linux-core t-linux
# 编译
[root@lips arm]# mkdir $TOPDIR/build/gcc-core
[root@lips arm]# cd $TOPDIR/build/gcc-core/
[root@lips gcc-core]#
[root@lips gcc-core]# $TOPDIR/src/gcc-2.95.3/configure /
--target=$TARGET /
--prefix=$PREFIX /
--enable-languages=c /
--disable-shared /
--disable-threads
[root@lips gcc-core]# make all install
  
2.3.4 编译安装glibc
# 解压缩
[root@lips gcc-core]# cd $TOPDIR/src/
[root@lips src]# tar zxfv $TOPDIR/tars/glibc-2.2.4.tar.gz
[root@lips src]# cd glibc-2.2.4/
[root@lips glibc-2.2.4]# tar zxfv $TOPDIR/tars/glibc-linuxthreads-2.2.4.
tar.gz
# 编译
[root@lips glibc-2.2.4]# mkdir $TOPDIR/build/glibc
[root@lips glibc-2.2.4]# cd $TOPDIR/build/glibc
[root@lips glibc]# CC=$TARGET-gcc AR=$TARGET-ar RANLIB=$TARGET-ranlib /
$TOPDIR/src/glibc-2.2.4/configure /
$TARGET /
--prefix=$PREFIX/$TARGET /
--enable-add-ons
[root@lips glibc]# make all install
  
2.3.5 编译安装gcc的c, c++编译器
# 恢复 t-linux 文件
[root@lips glibc]# cd $TOPDIR/src/gcc-2.95.3/gcc/config/arm/
[root@lips arm]# cp t-linux.orig t-linux
# 解压缩
[root@lips arm]# cd $TOPDIR/src/
[root@lips src]# tar zxfv $TOPDIR/tars/gcc-g++-2.95.3.tar.gz
# 编译
[root@lips src]# mkdir $TOPDIR/build/gcc-g++
[root@lips src]# cd $TOPDIR/build/gcc-g++/
[root@lips gcc-g++]# $TOPDIR/src/gcc-2.95.3/configure /
--target=$TARGET /
--prefix=$PREFIX /
--enable-languages=c,c++ /
--with-included-gettext
[root@lips gcc-g++]# make all install
  
2.4 使用交叉编译环境
  [参考ARM Linux 2.4, linux/Documentation/arm/README ]
   If you wish to cross-compile, then alter the following lines in th
e top
   level make file:
   ARCH = <whatever>
   with
   ARCH = arm
   and
   CROSS_COMPILE=
   to
   CROSS_COMPILE=<your-path-to-your-compiler-without-gcc>
   eg.
   CROSS_COMPILE=arm-linux-
  
  上述过程完成之后,为了便于其他开发人员使用交叉编译环境,我们可以将必
要的文件打包备份,复制到其他主机上即可成为一个交叉开发环境。如下几个目录
是必需的:
  $TOPDIR/arm-toolchain --> arm-toolchain-2.4.21-rmk1.tgz
  $TOPDIR/src/linux --> linux-2.4.21-rmk1-ds0-dj9.tar.gz
  Makefile 中相应位置需要根据实际情况(上面两个包解开在哪个目录)做一些
修改:
  ARCH = arm
  CROSS_COMPLIE = /root/arm/tool-chain/bin/arm-linux-
  LD = $(CROSS_COMPILE)ld
  CC = $(CROSS_COMPILE)gcc
  KERNELPATH = /root/arm/src/linux




3 内核

3.1 概述
  kernel
3.2 编译内核步骤
# 配置内核
# 复制缺省的内核配置文件
[root@lips gcc-g++]# cd $TOPDIR/src/linux
[root@lips linux]# cp arch/arm/def-configs/iq80321 .config
[root@lips linux]# make menuconfig
# 一般来说不需要修改缺省配置
# 根据具体情况可以考虑加上或者去掉某些选项
# 支持 initrd 机制
Block devices --->
<*> Loopback device support
[*] Initial RAM disk (initrd) support
Character devices --->
<*> Enhanced Real Time Clock Support
# 可以去掉这些选项,目前没有用
Multi-device support (RAID and LVM) --->
[ ] Multiple devices driver support (RAID and LVM)
< > Include IDE/ATA-2 DISK support
< > Include IDE/ATAPI CDROM support
# 修改 Makefile
# 如果在前面步骤(安装linux头文件)已经修改则可以跳过这里
# 确认一下,如果定义 PREFIX=/usr/local/arm 这里就需要修改了
# 必须将 CROSS_COMPILE 定义为交叉编译工具的路径前缀
CROSS_COMPILE = $(PREFIX)/bin/arm-linux-
# 编译
[root@lips linux]# make dep; make bzImage
# 最后生成的内核 arch/arm/boot/zImage
# 内核配置文件是 .config
  



4 根文件系统

4.1 概述
  有了内核之后,还必须有根文件系统(root filesystem)才能使一个Linux系
统正常运行。根文件系统用于存放系统运行期间所需的应用程序、脚本、配置文件
等。
4.2 BusyBox
  主页:
http://www.busybox.net/
  下载:
http://busybox.net/downloads/
  手册:
http://www.busybox.net/downloads/BusyBox.html
4.2.1 简介
  README
  BusyBox combines tiny versions of many common UNIX utilities into a
single
  small executable. It provides minimalist replacements for most of th
e utilities
  you usually find in GNU coreutils, util-linux, etc. The utilities in
BusyBox
  generally have fewer options than their full-featured GNU cousins; h
owever, the
  options that are included provide the expected functionality and beh
ave very
  much like their GNU counterparts.
  BusyBox has been written with size-optimization and limited resource
s in mind.
  It is also extremely modular so you can easily include or exclude co
mmands (or
  features) at compile time. This makes it easy to customize your embe
dded
  systems. To create a working system, just add /dev, /etc, and a Linu
x kernel.
  BusyBox provides a fairly complete POSIX environment for any small o
r embedded
  system.
  
  BusyBox目前的最新版本是1.00-pre10(1.0版的发布一再推迟)。
  BusyBox是什么东西?为什么要使用BusyBox呢?正如手册所说,BusyBox是嵌入
式Linux的“瑞士军刀”。编译安装后的BusyBox只有一个二进制可执行文件busybo
x,它实现了几乎所有常用、必须的应用程序(比如init,shell,getty,ls,cp等
等),而这些应用程序都以符号链接的形式存在。对用户来说,执行命令的方法并
没有改变,命令行调用会作为一个参数传给busybox,即可完成相应的功能。
  使用BusyBox大大简化了根文件系统的制作。如果没有BusyBox的话,在交叉开
发环境中为目标机准备根文件系统是非常麻烦的,需要分别取得这些应用程序的源
代码,然后放在前面准备的交叉编译环境中编译得到其可执行代码,全部工作量是
很大的。而使用BusyBox就可以用一个busybox代替了所有那些应用程序。
  
4.2.2 BusyBox的安装
  INSTALL
  1) Run 'make config' or 'make menuconfig' and select the
   functionality that you wish to enable.
  2) Run 'make dep'
  3) Check the Makefile for any Makefile setting you wish
   to adjust for your system (things like like setting
   your cross compiler, adjusting optimizations, etc)
  4) Run 'make'
  5) Go get a drink of water, drink a soda, visit the bathroom,
   or whatever while it compiles. It doesn't take very
   long to compile, so you don't really need to waste too
   much time waiting...
  6) Run 'make install' or 'make PREFIX=/target install' to
   install busybox and all the needed links. Some people
   will prefer to install using hardlinks and will instead
   want to run 'make install-hardlinks'....
  
  首先,对BusyBox进行配置。
[root@lips busybox-1.00-pre10]# make menuconfig
---------------- BusyBox Configuration ----------------
General Configuration --->
Build Options --->
Installation Options --->
Archival Utilities --->
Coreutils --->
Console Utilities --->
Debian Utilities --->
Editors --->
Finding Utilities --->
Init Utilities --->
Login/Password Management Utilities --->
Miscellaneous Utilities --->
Linux Module Utilities --->
Networking Utilities --->
Process Utilities --->
Another Bourne-like Shell --->
System Logging Utilities --->
Linux System Utilities --->
Debugging Options --->
  
  Build Options --->
  [*] Build BusyBox as a static binary (no shared libs)
  [*] Build with Large File Support (for accessing files > 2 GB)
  [*] Do you want to build BusyBox with a Cross Compiler?
  (/root/arm/arm-toolchain/bin/arm-linux-) Cross Compiler prefix
  () Any extra CFLAGS options for the compiler?
  这里有几个选项要注意:静态编译,省得复制共享库;设置交叉编译器的路径
,根据我们的情况就要设置为 /root/arm/arm-toolchain/bin/arm-linux-,即 $P
REFIX/bin/arm-linux-(与linux/Makefile中的设置相同)。
  
  Installation Options --->
  [*] Don't use /usr
  (/root/arm/fakeroot) BusyBox installation prefix
  这里设置安装路径(/root/arm/fakeroot)。不使用/usr的意思是指全部安装在
/bin和/sbin,不在/usr/bin和/usr/sbin下面安装程序。
  
  其余几个部分用来配置所实现的工具,可以根据需要选择,或者使用缺省配置
即可。
  配置完成后,象配置Linux内核一样,当前配置信息会保存在.config文件中。

  然后,编译、安装。
[root@lips busybox-1.00-pre10]# make dep; make; make install
  
  BTW.BusyBox 版本 stable (0.60.5) 的安装需要手工修改 config.h 和 Mak
efile 文件。
4.3 根文件系统内容
# /root/arm/fakeroot 目录是将来的根文件系统
# 现在我们已经有了 bin sbin usr ,下面来添加其他的内容,
# 关键是 dev 和 etc ,以及必要的 lib 。
[root@lips busybox-1.00-pre10]# cd /root/arm/fakeroot
[root@lips fakeroot]# mkdir dev etc lib mnt proc root tmp var
[root@lips fakeroot]# ls
bin dev etc lib mnt proc root sbin tmp usr var
[root@lips fakeroot]#
4.3.1 bin, sbin, usr/bin, usr/sbin
  bin和sbin下面就是BusyBox编译安装的内容,usr没有用。
[root@lips fakeroot]# ls bin sbin
bin:
[ chown du gzip md5sum pwd tar uniq
adduser chvt echo head mkdir readlink tee unzip
ar clear egrep hexdump mkfifo reset telnet uptime
arping cmp env hostname mknod rm test usleep
ash cp expr id mktemp rmdir tftp vi
awk cut false install more sed time wc
basename date fgrep ip mount sh top wget
bunzip2 dd find kill mv sleep touch which
busybox deallocvt free killall openvt sort tr whoami
bzcat deluser ftpget ln passwd strings true xargs
cat df ftpput logger pidof su tty yes
chgrp dirname grep login ping sync umount zcat
chmod dmesg gunzip ls ps tail uname
sbin:
chroot hwclock ifup insmod modprobe reboot sulogin syslogd
getty ifconfig inetd klogd pivot_root rmmod swapoff telnetd
halt ifdown init lsmod poweroff route swapon
[root@lips fakeroot]#
4.3.2 dev
[root@lips fakeroot]# ls dev/
console kmem mtdblock1 null random systty tty1 zero
initctl mem mtdblock2 ptmx rtc tty ttyS0
initrd mtdblock0 mtdblock3 pts shm tty0 ttyS1
[root@lips fakeroot]#
  
  
  # Basic /dev entries
  # Filename, Type, Major, Minor, Permission, Description
  
  # mem char 1 1 600 Physical memory access
  # kmem char 1 2 600
  # null char 1 3 666 Null device
  # zero char 1 5 666 Null byte source
  # random char 1 8 644 Nondeterministic random number generator
  # initrd block 1 250 600
  # tty0 char 4 0 600 Current virtual console
  # tty1 char 4 1 600 First virtual console
  # ttyS0 char 4 64 600 First UART serial port
  # ttyS1 char 4 65 600 Second UART serial port
  # tty char 5 0 666 Current TTY device
  # console char 5 1 600 System console
  # rtc char 10 135 644 Real Time Clock
  # ptmx char 5 2 666 UNIX98 PTY master
  # mtdblock0 block 31 0 644 MTD
  # mtdblock1 block 31 1 644 MTD
  # mtdblock2 block 31 0 644 MTD
  # mtdblock3 block 31 1 644 MTD
  # pts/0 char 136 0 640 UNIX98 PTY slave
  # pts/1 char 136 1 640 UNIX98 PTY slave
  # initctl FIFO ? ? 600
  # systty -> tty0
  # shm/
  
4.3.3 etc
[root@lips fakeroot]# ls etc/
fstab hosts issue nsswitch.conf profile rc.d securetty sy
sconfig
group inittab issue.net passwd protocols rpc services
[root@lips fakeroot]#
  Etc目录下面存放的是配置文件和脚本。提供少数几个必要的文件即可使系统正
常运行。至于配置文件的具体内容,可以参考主机(Redhat Linux)中的配置文件
。其中rc.d是存放脚本的目录,sysconfig目录主要存放了有关网络的配置和脚本。
保留这些目录结构并非必须的,而仅仅是为了延续Redhat的习惯。
  BusyBox实现的init与SysVinit有较大区别,因此其配置文件inittab相应也要
做较大改变。
[root@lips fakeroot]# cat etc/inittab
#
# inittab This file describes how the INIT process should set up
# the system in a certain run-level.
# Format:
# <id>:<runlevels>:<action>:<process>
#
# WARNING
# The Busybox init is different with SysV init.
# <id>: This field has a non-traditional meaning for BusyBox init!
# The id field is used by BusyBox init to specify the controlling
tty for
# the specified process to run on. The contents of this field are

# appended to "/dev/" and used as-is.
# <runlevel>: The runlevels field is completely ignored.
#
# System initialization.
::sysinit:/etc/rc.d/rc.sysinit
# /bin/sh invocations on selected ttys
# Start an "askfirst" shell on the console (whatever that may be)
::askfirst:/bin/sh
# 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
[root@lips fakeroot]#
  
4.3.4 lib
[root@lips fakeroot]# ls lib/
libnss_files-2.2.4.so libnss_files.so libnss_files.so.2 modules
[root@lips fakeroot]#
  由于busybox是静态编译的,其运行并不依赖额外的库文件。这里的库文件只有
一个 libnss_files-2.2.4.so,是为了配合 etc/ nsswitch.conf 而必须的。
  需要特别注意的是,这个库文件是从前面所准备的交叉编译环境($PREFIX/$T
ARGET/lib,即/root/arm/arm-toolchain/arm-linux/lib)中复制的,而不是从主
机的/lib中复制。
[root@lips fakeroot]# cp -dpR $PREFIX/$TARGET/lib/libnss_files* lib
[root@lips fakeroot]#
  另外,modules 目录用来存放系统中可能用到的Linux内核模块。
  
4.3.5 其他



  
5 引导

5.1 概述
  引导器(bootloader)的作用是装入并运行内核,在内核运行的最后阶段会从
指定位置挂载根文件系统,从而使系统转入正常运行。比如LILO和GRUB都是常见的
引导器软件。然而这些为主机设计的软件并不适合嵌入式系统,这里我们将要用到
的是RedBoot.
  在引导目标机之前,首先必须明确两个问题:
  第一,内核映像文件存放在哪里(什么设备)?
  第二,根文件系统存放在哪里(根设备是什么)、文件系统类型是什么?
  主机的内核和根文件系统通常位于磁盘分区(如/dev/hda1),类型为ext2或者
ext3等。而对于IQ80321来说(或者大多数目标机),没有磁盘这样的大容量存储设
备,取而代之的是FLASH MEMORY之类的存储器,其容量有限(这里是8MB)。因此对
产品来说,其内核和根文件系统都位于 FLASH(MTD设备),类型多数采用 jffs2。

  将内核写入FLASH的方式有几种,比如通过串口、JTAG接口或者网络。在后面的
过程中,我们选择的是使用RedBoot通过网络下载内核文件,然后写入FLASH。这时
,主机需要正确设置TFTP服务器。
  由于将文件写入FLASH的过程比较繁琐(一般需要借助其他工具或者软件),为
了便于频繁修改、测试,在软件开发阶段通常把根文件系统存放在主机,目标机通
过NFS远程挂载根文件系统。
  
5.2 RedBoot
  
http://sources.redhat.com/redboot/
  
5.2.1 简介
  (参考资料[2])
  RedBoot is an acronym for "Red Hat Embedded Debug and Bootstrap", an
d is the standard embedded system debug/bootstrap environment from Red H
at, replacing the previous generation of debug firmware: CygMon and GDB
stubs. It provides a complete bootstrap environment for a range of embed
ded operating systems, such as embedded Linux and eCos, and includes fac
ilities such as network downloading and debugging. It also provides a si
mple flash file system for boot images.
  RedBoot provides a wide set of tools for downloading and executing p
rograms on embedded target systems, as well as tools for manipulating th
e target system’s environment. It can be used for both product developm
ent (debug support) and for end product deployment (flash and network bo
oting).
5.2.2 RedBoot 命令
  RedBoot> help
  Manage aliases kept in FLASH memory
   alias name [value]
  Set/Query the system console baud rate
   baudrate [-b <rate>]
  Manage machine caches
   cache [ON | OFF]
  Display/switch console channel
   channel [-1|<channel number>]
  Compute a 32bit checksum [POSIX algorithm] for a range of memory
   cksum -b <location> -l <length>
  Display (hex dump) a range of memory
   dump -b <location> [-l <length>] [-s] [-1|2|4]
  Execute an image - with MMU off
   exec [-w timeout] [-b <load addr> [-l <length>]]
   [-r <ramdisk addr> [-s <ramdisk length>]]
   [-c "kernel command line"] [<entry_point>]
  Manage FLASH images
   fis {cmds}
  Manage configuration kept in FLASH memory
   fconfig [-i] [-l] [-n] [-f] [-d] | [-d] nickname [value]
  Execute code at a location
   go [-w <timeout>] [entry]
  Run board diagnostics
   diag
  Help about help?
   help [<topic>]
  Set/change IP addresses
   ip_address [-l <local_ip_address>] [-h <server_address>]
  Load a file
   load [-r] [-v] [-d] [-h <host>] [-m <varies>] [-c <channel_number
>]
   [-b <base_address>] <file_name>
  Compare two blocks of memory
   mcmp -s <location> -d <location> -l <length> [-1|-2|-4]
  Fill a block of memory with a pattern
   mfill -b <location> -l <length> -p <pattern> [-1|-2|-4]
  Network connectivity test
   ping [-v] [-n <count>] [-l <length>] [-t <timeout>] [-r <rate>]
   [-i <IP_addr>] -h <IP_addr>
  Reset the system
   reset
  Display RedBoot version information
   version
  Display (hex dump) a range of memory
   x -b <location> [-l <length>] [-s] [-1|2|4]
  
5.2.3 连接目标机
  连接目标机的途径有很多种。这里我们演示的是使用minicom连接目标机的串口

  首先,使用 minicom –s 设置串口参数:/dev/ttyS1,115200,8N1.将该设
置保存为默认值,退出。
  然后用 minicom –o 命令连接IQ80321开发板串口。-o (--noinit) 参数表示
取消发送初始化MODEM指令。这里似乎需要复位一下IQ80321板子(按板上的复位按
钮),敲回车,应该出现 RedBoot> 提示符,表示一切顺利。
  第一次连接后,需要使用 fconfig 命令设置目标机的网络、串口波特率等信息

  另外,还需要熟悉 fis,这是 RedBoot 提供的操作FLASH的工具。
  Help 命令列出了在RedBoot提示符下面可以使用的所有命令。
  
[root@lips root]# minicom -o
Welcome to minicom 2.00.0
OPTIONS: History Buffer, F-key Macros, Search History Buffer, I18n
Compiled on Jan 25 2003, 00:15:18.
Press CTRL-A Z for help on special keys
+Ethernet eth0: MAC address 00:07:e9:03:39:f4
IP: 192.168.0.21/255.255.255.0, Gateway: 192.168.0.1
Default server: 192.168.0.20, DNS server IP: 192.168.0.1
RedBoot(tm) bootstrap and debug environment [ROM]
Red Hat certified release, version 1.61 - built 16:46:58, Oct 23 2002
Platform: IQ80321 (XScale)
Copyright (C) 2000, 2001, 2002, Red Hat, Inc.
RAM: 0x00000000-0x08000000, 0x0001b488-0x01fd1000 available
FLASH: 0xf0000000 - 0xf0800000, 64 blocks of 0x00020000 bytes each.
# 注意!!这两行显示信息很重要,可以看出:
# (1)IQ80321目标板有128M内存,FLASH容量为8M.
# (2)可用内存从地址0x0001b488开始.
# (3)FLASH的erase block size为0x20000(字节).
RedBoot>
RedBoot> fconfig
Run script at boot: false
Use BOOTP for network configuration: false
Gateway IP address: 192.168.0.1
Local IP address: 192.168.0.21
Local IP address mask: 255.255.255.0
Default server IP address: 192.168.0.20
Console baud rate: 115200
DNS server IP address: 192.168.0.1
GDB connection port: 9000
Force console for special debug messages: true
Console number for special debug messages: 0
Network debug at boot time: false
alias/admin:
alias/mobile:
alias/motd: Hello.
RedBoot>
RedBoot> fis
*** invalid 'fis' command: too few arguments
Usage:
fis create -b <mem_base> -l <image_length> [-s <data_length>]
[-f <flash_addr>] [-e <entry_point>] [-r <ram_addr>] [-n] <name>
fis delete name
fis erase -f <flash_addr> -l <length>
fis free
fis init [-f]
fis list [-c] [-d]
fis load [-d] [-b <memory_load_address>] [-c] name
fis lock [-f <flash_addr> -l <length>] [name]
fis unlock [-f <flash_addr> -l <length>] [name]
fis write -f <flash_addr> -b <mem_base> -l <image_length>
RedBoot>
  
5.3 MTD和jffs2
5.3.1 准备
# 重新配置编译主机内核
# 增加 MTD 支持
Memory Technology Devices (MTD) --->
<*> Memory Technology Device (MTD) support
<*> Direct char device access to MTD devices (NEW)
<*> Caching block device access to MTD devices (NEW)
Self-contained MTD device drivers --->
<*> Test driver using RAM (NEW)
#(4096) MTDRAM device size in KiB (NEW)
(8192) MTDRAM device size in KiB (NEW)
(128) MTDRAM erase block size in KiB (NEW)
<*> MTD emulation using block device (NEW)
# 增加 JFFS2 文件系统支持
File systems --->
<*> Journalling Flash File System v2 (JFFS2) support
# 内核中增加了相应的支持之后,还需要 mkfs.jffs2 工具,下载
#
ftp://ftp.nluug.nl/pub/sunsite/distributions/altlinux/Sisyphus/files/i
586/RPMS/jffs2-2.0-alt1.i586.rpm
# 安装此 RPM 包,然后就会有 /sbin/mkfs.jffs2 ,并且可以看手册页
[root@lips tars]# rpm -ivh jffs2-2.0-alt1.i586.rpm
# 创建设备节点
[root@lips tars]# mkdir -p /dev/mtdblock
[root@lips tars]# mknod /dev/mtdblock/0 b 31 0
# 如果已经有了 JFFS2 文件系统映像,怎么看其中的内容?
[root@lips tmp]# dd if=iq80310.jffs2 of=/dev/mtdblock/0
12288+0 records in
12288+0 records out
[root@lips tmp]# mount -t jffs2 /dev/mtdblock/0 /mnt/
[root@lips tmp]#
  
5.3.2 HOWTO
  (参考资料[3])
  *** Putting a jffs file system on the flash devices:
  
  Now that you have successfully managed to detect your flash devices,

  you need to put a jffs on them. Unlike mke2fs there is no utility th
at
  will directly create a jffs file-system onto the
  /dev/mtd0,1,2... device.
  
  You have to use a utility called mkfs.jffs available under mtd/util
  
  Get a directory ready with the stuff that you want to put under
  jffs. Let's assume that it's called /home/jffsstuff
  
  Then just do:
  #/usr/src/mtd/util/mkfs.jffs -d /home/jffsstuff -o /tmp/jffs.image
  
  This makes a jffs image file. Then do (if your flash chips are erase
d,
  else see below):
  #cp /tmp/jffs.image /dev/mtd0,1,2... (as the case may be, most
  likely /dev/mtd0).
  
  You may also mount an erased mtdblock device directly without puttin
g
  a file system on it. This will let you fill the device interactively

  under your shell control (you know- copy stuff to the mounted dir).
  
  If your flash chips are not erased or you have been messing around
  with them earlier, your cannot just copy the new image on top of the

  older one. Bad things may happen. Use the program mtd/util/erase to
  erase your device.
  
  #/usr/src/mtd/util/erase /dev/mtd0,1,2,3 <offset> <erase-size>
  where
  offset: try 0 if you don't know (start of mtd device), else must be
in
  decimal bytes, but must start at an integral erase sector boundary.
  
  
  erase-size: How many "erase sectors" worth do you want to erase.
  Your max erase size for your flash is:
   (total-size/your mtd device erase size- look under `cat /proc/mtd`)

  
  
  Watch the messages on your console (assuming you have verbose turned

  on when you configured your kernel). You should not see any errors.
  
  When your command prompt returns, do:
  #cp /tmp/jffs.image /dev/mtd0,1,2... (as the case may be, most
  likely /dev/mtd0).
  
  
  Then load the jffs module in by:
  #modprobe jffs
  
  Then mount the file system by:
  #mount -t jffs /dev/mtdblock0 /mnt/jffs (assuming /mnt/jffs exists,
else
  make it).
  
  Note: Note the use of /dev/mtdblock0 NOT /dev/mtd0. "mount" needs a
  block device interface and /dev/mtdblock0,1,2,3... are provided for
  that purpose. /dev/mtd0,1,2,3 are char devices are provided for thin
gs
  like copying the binary image onto the raw flash devices.
  
  
  *** Mounting a JFFS(1 or 2) F/S as root device.
  This is rather simple.
  
  *Note: This assumes that you can some how boot your kernel. This
  section does NOT deal with booting your kernel from an mtd partition

  or device.
  You may be doing this by booting your kernel off an IDE flash disk/C
F
  disk etc. using lilo.
  This procedure is the same even when you want to boot the kernel
  directly off flash. This time you will just burn the kernel into the

  raw flash device after the "rdev" step below.
  
  1. Make sure that you can detect your flash devices and read and wri
te
   them though the MTD device nodes (/dev/mtdn).
  2. Make sure than you can mount the required JFFS(1 or 2) f/s on you
r
   flash devices and copy files to it, unmount, reboot, re-mount and

   still see your files there (also do a "diff" on a couple of files

   to make sure that the data did not get corrupted).
  3. Compile all the required MTD/JFFS(1/2) support into the kernel
  4. Tell the kernel what your root device is going to be. Do that by:

  # rdev <your flash image here> /dev/mtdblock<n>
  where mtdblock<n> is where you have constructed your root fs that yo
u
   want to mount as root on reboot.
  5. Run your boot loader init program (lilo for LILO bootloader).
  6. Reboot. Your jffs mtdblock<n> partition should be mounted as root
.
  
5.3.3 mkfs.jffs2
  (man page of mkfs.jffs2)
  MKFS.JFFS2(1)
  
  NAME
   mkfs.jffs2 - Create a JFFS2 file system image from directory
  
  SYNOPSIS
   mkfs.jffs2 [ -p,--pad[=SIZE] ] [ -r,-d,--root directory ] [
-s,--page-
   size=SIZE ] [ -e,--eraseblock=SIZE ] [ -c,--cleanmarker=
SIZE ] [
   -n,--no-cleanmarkers ] [ -o,--output image.jffs2 ] | -l,--lit
tle-endian
   ] [ -b,--big-endian ] [ -D,--devtable=FILE ] [ -f,--fake
time ] [
   -q,--squash ] [ -U,--squash-uids ] [ -P,--squash-perms ] [ -
h,--help ]
   [ -v,--verbose ] [ -V,--version ]
  
  DESCRIPTION
   The program mkfs.jffs2 creates a JFFS2 (Second Journalling F
lash File
   System) file system image and writes the resulting image t
o the file
   specified by the -o option or by default to the standard outp
ut, unless
   the standard output is a terminal device in which case mkfs.
jffs2 will
   abort.
  
   The file system image is created using the files and directo
ries con-
   tained in the directory specified by the option -r or t
he present
   directory, if the -r option is not specified.
  
   Files to be placed into the file system image are compressed
using the
   zlib compression library.
  
   It is unlikely that JFFS2 images are useful except in conjuc
tion with
   the MTD (Memory Technology Device) drivers in the Linux ker
nel, since
   the JFFS2 file system driver in the kernel requires MTD devic
es.
  
  OPTIONS
   Options that take SIZE arguments can be specified as eithe
r decimal
   (e.g., 65536), octal (0200000), or hexidecimal (0x1000).
  
   -p, --pad[=SIZE]
   Pad output to SIZE bytes with 0xFF. If SIZE is not
specified,
   the output is padded to the end of the final erase blo
ck.
  
   -r, -d, --root=DIR
   Build file system from directory DIR. The default is
the cur-
   rent directory.
  
   -e, --eraseblock=SIZE
   Use erase block size SIZE. The default is 64 KiB. If
you use a
   erase block size different than the erase block size o
f the tar-
   get MTD device, JFFS2 may not perform optimally. If
the SIZE
   specified is below 4096, the units are assumed to be K
iB.
  
   -o, --output=FILE
   Write JFFS2 image to file FILE. Default is the standa
rd output.
  
5.4 NFSROOT
  [参考Mounting the root filesystem via NFS (nfsroot), linux/Documents
/nfsroot.txt]
  Kernel command line
  -------------------
  
  When the kernel has been loaded by a boot loader (either by loadlin,

  LILO or a network boot program) it has to be told what root fs devic
e
  to use, and where to find the server and the name of the directory
  on the server to mount as root. This can be established by a couple
  of kernel command line parameters:
  
  root=/dev/nfs
  
   This is necessary to enable the pseudo-NFS-device. Note that it's n
ot a
   real device but just a synonym to tell the kernel to use NFS instea
d of
   a real device.
  
  nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]
  
   <server-ip> Specifies the IP address of the NFS server. If this
field
   is not given, the default address as determined by t
he
   `ip' variable (see below) is used. One use of this
   parameter is for example to allow using different se
rvers
   for RARP and NFS. Usually you can leave this blank.
  
   <root-dir> Name of the directory on the server to mount as root
. If
   there is a "%s" token in the string, the token will
be
   replaced by the ASCII-representation of the client's
IP
   address.
  
  ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<au
toconf>
  
  <client-ip> IP address of the client. If empty, the address will e
ither
   be determined by RARP or BOOTP. What protocol is used de-
   pends on what has been enabled during kernel configuration
   and on the <autoconf> parameter. If this parameter is not
   empty, neither RARP nor BOOTP will be used.
  
   <server-ip> IP address of the NFS server. If RARP is used to dete
rmine
   the client address and this parameter is NOT empty only
   replies from the specified server are accepted. To use
   different RARP and NFS server, specify your RARP server
   here (or leave it blank), and specify your NFS server in
   the `nfsroot' parameter (see above). If this entry is blank
   the address of the server is used which answered the RARP
   or BOOTP request.
  ……
  
5.5 主机设置
5.5.1 DHCP服务器
5.5.2 NFS服务器
  设置NFS服务器的目的是将 /root/arm/fakeroot 目录输出,作为目标机的根文
件系统。
  修改配置文件 /etc/exports。详细语法请参考手册页 exports(5)。
[root@lips fakeroot]# cat /etc/exports
/root/arm/fakeroot (rw,no_root_squash)
[root@lips fakeroot]# /etc/rc.d/init.d/nfs restart
Shutting down NFS mountd: [ OK ]
Shutting down NFS daemon: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [ OK ]
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
[root@lips fakeroot]#
  
5.5.3 TFTP服务器
  设置TFTP服务器的目的是提供给目标机下载内核文件。
  TFTP通过xinetd服务来控制,默认情况下tftp服务器是关闭的。修改/etc/xin
etd.d/tftp配置文件:disable = no,并将其根目录由 /tftpboot 修改为 /root/
arm/boot,因为我们将编译生成的Linux内核文件复制到了这个目录(当然你也可以
不修改这个根目录,只要你将内核放在这里指定的位置即可)。然后启动该网络服
务。
[root@lips fakeroot]# cat /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves files using the trivial file trans
fer /
# protocol. The tftp protocol is often used to boot diskless /
# workstations, download configuration files to network-aware prin
ters, /
# and to start the installation process for some operating systems
.
service tftp
{
disable = no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
# server_args = -s /tftpboot
server_args = -s /root/arm/boot
per_source = 11
cps = 100 2
flags = IPv4
}
[root@lips fakeroot]# /etc/rc.d/init.d/xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
[root@lips fakeroot]#
  
5.6 引导过程:远程NFS根文件系统
# 这些以#开头的注释行是写文档时加入的
# 用fis工具的list命令查看当前FLASH中的文件
RedBoot> fis list
Name FLASH addr Mem addr Length Entry point
RedBoot 0xF0000000 0xF0000000 0x00040000 0x00000000
RedBoot config 0xF07C0000 0xF07C0000 0x00001000 0x00000000
FIS directory 0xF07E0000 0xF07E0000 0x00020000 0x00000000
RedBoot> fis free
0xF0040000 .. 0xF07C0000
RedBoot>
# 通过网络从主机TFTP服务器下载zImage内核文件,并装入内存地址0x100000
# -r :下载RAW数据
# -b 0x100000 :将下载的文件装入该内存地址(怎么确定这个地址?前面我们已
经知道了目标板RAM的大小和可用内存的起始地址,这里所确定的内存地址应该大于
该起始地址;另外,为了方便后面估算文件大小,我们用了0x100000,即1M,这样
一个对齐的地址。)
# -h 192.168.0.20 :主机(TFTP服务器)IP地址
# zImage :Linux内核文件名
RedBoot> load -r -b 0x100000 -h 192.168.0.20 zImage
Raw file loaded 0x00100000-0x001c71d7, assumed entry at 0x00100000
# 用fis工具的create命令将内存中的内核文件写入FLASH,并命名为kernel
# -b 0x100000 :文件在内存中的地址(与前面的load命令相同)
# -l 0xe0000 :写入数据的长度(怎么确定这个长度?根据前面load命令的返回信
息,可以知道装入内存的文件大小,然后取一个不小于文件大小并对齐FLASH的era
se block大小的值即可。我们已经知道目标板所用FLASH的erase block size为0x2
0000,因此这里取值为0xE0000。特别注意,如果重新编译了内核,要根据实际情况
计算这个长度。)
# 另外,这里create命令没有指定-f参数,即写入FLASH的地址,则默认使用了FLA
SH的空闲起始地址。
RedBoot> fis create -b 0x100000 -l 0xe0000 kernel
... Erase from 0xf0040000-0xf0120000: .......
... Program from 0x00100000-0x001e0000 at 0xf0040000: .......
... Unlock from 0xf07e0000-0xf0800000: .
... Erase from 0xf07e0000-0xf0800000: .
... Program from 0x01fdf000-0x01fff000 at 0xf07e0000: .
... Lock from 0xf07e0000-0xf0800000: .
# 查看一下
RedBoot> fis list
Name FLASH addr Mem addr Length Entry point
RedBoot 0xF0000000 0xF0000000 0x00040000 0x00000000
RedBoot config 0xF07C0000 0xF07C0000 0x00001000 0x00000000
FIS directory 0xF07E0000 0xF07E0000 0x00020000 0x00000000
kernel 0xF0040000 0x00100000 0x000E0000 0x00100000
RedBoot> fis free
0xF0120000 .. 0xF07C0000
RedBoot>
# 这时内核文件已经位于FLASH
# 用fis工具的load命令将内核kernel从FLASH装入内存
RedBoot> fis load kernel
# 执行上一步装入的内核,-c 后面是内核的引导参数
# console=ttyS0,115200 :以目标机的串口ttyS0作为控制台,波特率115200
# ip=192.168.0.21 :设置目标机的IP地址
# root=/dev/nfs :根设备,设置为远程nfs挂载
# nfsroot=192.168.0.20:/root/arm/fakeroot :提供nfs远程根文件系统的主机I
P地址和绝对路径(注意,主机上面应该已经正确设置了NFS服务器和exports路径)

# 这个命令输入之后,如果一切正常,内核就会启动并挂载根文件系统运行
RedBoot> exec -c "console=ttyS0,115200 ip=192.168.0.21 root=/dev/nfs nfs
root=192.168.0.20:/root/arm/fakeroot"
Using base address 0x00100000 and length 0x000e0000
Uncompressing Linux.....................................................
.... done, booting the kernel.
Linux version 2.4.21-rmk1-ds0-dj9 (root@lips) (gcc version 2.95.3 200103
15 (release)) #1 Mon Jul 5 14:34:15 CST 2004
CPU: XScale-IOP80321 revision 2
Machine: Intel IQ80321
alloc_bootmem_low
memtable_init
On node 0 totalpages: 16384
zone(0): 16384 pages.
zone(1): 0 pages.
zone(2): 0 pages.
Kernel command line: console=ttyS0,115200 ip=192.168.0.21 root=/dev/nfs
nfsroot=192.168.0.20:/root/arm/fakeroot
Calibrating delay loop... 599.65 BogoMIPS
Memory: 64MB = 64MB total
Memory: 62904KB available (1398K code, 261K data, 232K init)
XScale Cache/TLB Locking Copyright(c) 2001 MontaVista Software, Inc.
Dentry cache hash table entries: 8192 (order: 4, 65536 bytes)
Inode cache hash table entries: 4096 (order: 3, 32768 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer-cache hash table entries: 4096 (order: 2, 16384 bytes)
Page-cache hash table entries: 16384 (order: 4, 65536 bytes)
POSIX conformance testing by UNIFIX
PCI: bus0: Fast back to back transfers disabled
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Intel IOP3xx AAU RAID Copyright(c) 2003 Intel Corporation
Starting kswapd
JFFS2 version 2.1. (C) 2001 Red Hat, Inc., designed by Axis Communicatio
ns AB.
pty: 256 Unix98 ptys configured
Serial driver version 5.05c (2001-07-08) with MANY_PORTS SHARE_IRQ SERIA
L_PCI enabled
ttyS00 at 0xfe800000x (irq = 28) is a 16550A
Real Time Clock Driver v1.10e
RAMDISK driver initialized: 16 RAM disks of 8192K size 1024 blocksize
Intel(R) PRO/1000 Network Driver - version 5.0.43-k1
Copyright (c) 1999-2003 Intel Corporation.
eth0: Intel(R) PRO/1000 Network Connection
Uniform Multi-Platform E-IDE driver Revision: 7.00beta4-2.4
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus
=xx
cfi_cmdset_0001: Erase suspend on write enabled
Using buffer write method
Using RedBoot partition definition
Creating 5 MTD partitions on "IOP3xx Flash":
0x00000000-0x00040000 : "RedBoot"
0x00040000-0x00120000 : "kernel"
0x00120000-0x007c0000 : "unallocated space"
0x007c0000-0x007c1000 : "RedBoot config"
mtd: partition "RedBoot config" doesn't end on an erase block -- force r
ead-only
0x007e0000-0x00800000 : "FIS directory"
md: raid5 personality registered as nr 4
raid5: measuring checksumming speed
iop3xx_aau: 223.200 MB/sec
raid5: using function: iop3xx_aau (223.200 MB/sec)
md: md driver 0.90.0 MAX_MD_DEVS=256, MD_SB_DISKS=27
md: Autodetecting RAID arrays.
md: autorun ...
md: ... autorun DONE.
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 4096 bind 4096)
IP-Config: Guessing netmask 255.255.255.0
IP-Config: Complete:
device=eth0, addr=192.168.0.21<6>e1000: eth0 NIC Link is Up 100 Mb
ps Full Duplex
, mask=255.255.255.0, gw=255.255.255.255,
host=192.168.0.21, domain=, nis-domain=(none),
bootserver=255.255.255.255, rootserver=192.168.0.20, rootpath=
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
NetWinder Floating Point Emulator V0.97 (double precision)
Looking up port of RPC 100003/2 on 192.168.0.20
Looking up port of RPC 100005/1 on 192.168.0.20
VFS: Mounted root (nfs filesystem).
Freeing init memory: 232K
# 敲一个回车激活控制台
Please press Enter to activate this console.
BusyBox v1.00-pre10 (2004.04.27-01:28+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
# 控制台上面出现shell提示符,表示引导成功
/ #
  
5.7 引导过程:FLASH根文件系统
  
# 使用 mkfs.jffs2 工具,制作根文件系统映像
# -d fakeroot :根文件系统的内容放在fakeroot目录中
# -e 0x20000 :FLASH的eraseblock大小为0x20000字节
# -p :以0xff填充文件尾部的空间对齐eraseblock
# -o fakeroot.jffs2.img :输出映像文件名
[root@lips arm]# mkfs.jffs2 -d fakeroot -e 0x20000 -p -o fakeroot.jffs2.
img
# 将映像文件复制到TFTP服务器的根目录(这里是/root/arm/boot/)
[root@lips arm]# cp fakeroot.jffs2.img boot/
[root@lips arm]#
# 查看一下当前FLASH的布局,确定空闲空间的地址
RedBoot> fis list
Name FLASH addr Mem addr Length Entry point
RedBoot 0xF0000000 0xF0000000 0x00040000 0x00000000
RedBoot config 0xF07C0000 0xF07C0000 0x00001000 0x00000000
FIS directory 0xF07E0000 0xF07E0000 0x00020000 0x00000000
kernel 0xF0040000 0x00100000 0x000E0000 0x00100000
RedBoot> fis free
0xF0120000 .. 0xF07C0000
# 通过网络从主机TFTP服务器下载fakeroot.jffs2.img文件,并装入内存地址0x10
0000
# 这里几个参数的意义可以参考上一节
# -b 0x100000 :确定该值的原则与下载内核文件时相同,并且可以使用一个不一
样的地址
RedBoot> load -r -b 0x100000 -h 192.168.0.20 fakeroot.jffs2.img
Raw file loaded 0x00100000-0x0023ffff, assumed entry at 0x00100000
# 用fis工具的erase命令擦除指定的FLASH区域
# 擦除之后的区域被填充为0xFF,这样做是为了保证没有写有效数据的空间是“干
净”的,从而避免因为文件尾部有垃圾数据而导致的错误。这个步骤并非必须执行

RedBoot> fis erase -f 0xf0120000 -l 0x140000
# 用fis工具的write命令将内存中的内容写入FLASH
# -b 0x100000 :数据在内存中的地址
# -f 0xf0120000 :数据写入FLASH的地址(怎么确定这个地址?从上面的fis fre
e命令可以知道当前可用空间的起始地址,从而确定这个地址。当然也可以靠后一些
,比如0xf0200000,不过要注意这样的话就会出现一个空闲空间的空洞,并且会影
响根设备的编号,即/dev/mtdblock?。)
# -l 0x140000 :数据块的长度(怎么确定这个长度?从load命令的返回信息知道
映像文件的大小,然后取一个稍大并且对齐erase block size 0x20000的值。)
RedBoot> fis write -b 0x100000 -f 0xf0120000 -l 0x140000
* CAUTION * about to program FLASH
at 0xf0120000..0xf025ffff from 0x00100000 - continue (y/n)?
y
... Erase from 0xf0120000-0xf0260000: ..........
... Program from 0x00100000-0x00240000 at 0xf0120000: ..........
# 用fis工具的create命令命名刚才写入的内容为fakeroot
# -n :该参数指定仅创建了目录节点
RedBoot> fis create -f 0xf0120000 -l 0x140000 -n fakeroot
... Unlock from 0xf07e0000-0xf0800000: .
... Erase from 0xf07e0000-0xf0800000: .
... Program from 0x01fdf000-0x01fff000 at 0xf07e0000: .
... Lock from 0xf07e0000-0xf0800000: .
# 查看一下,确认写入成功
RedBoot> fis list
Name FLASH addr Mem addr Length Entry point
RedBoot 0xF0000000 0xF0000000 0x00040000 0x00000000
RedBoot config 0xF07C0000 0xF07C0000 0x00001000 0x00000000
FIS directory 0xF07E0000 0xF07E0000 0x00020000 0x00000000
kernel 0xF0040000 0x00100000 0x000E0000 0x00100000
fakeroot 0xF0120000 0xF0120000 0x00140000 0x00100000
RedBoot> fis free
0xF0260000 .. 0xF07C0000
# 从FLASH加载内核
RedBoot> fis load kernel
# exec命令执行内核,-c指定引导参数
# console=ttyS0,115200 :设置串口控制台
# root=/dev/mtdblock2 :设置根文件系统为/dev/mtdblock2
# 这个“/dev/mtdblock2”是怎么确定的?我们已经创建了设备节点mtdblock0~m
tdblock7,这里要确定写入FLASH的jffs2文件系统对应哪个设备。方法是,从FLAS
H的起始地址往后数,看写入的jffs2位于第几个分区;计数从0开始;在IQ80321板
子上第一个分区是RedBoot;”unallocated space”也要算。准确的信息可以在引
导过程中看到,比如下面的”Creating 6 MTD partitions on IOP3xx Flash:”;
或者在引导成功后的/proc/mtd文件中也可以看到。
RedBoot> exec -c "console=ttyS0,115200 root=/dev/mtdblock2"
Using base address 0x00100000 and length 0x000e0000
Uncompressing Linux.....................................................
.... done, booting the kernel.
Linux version 2.4.21-rmk1-ds0-dj9 (root@lips) (gcc version 2.95.3 200103
15 (release)) #1 Mon Jul 5 14:34:15 CST 2004
CPU: XScale-IOP80321 revision 2
Machine: Intel IQ80321
alloc_bootmem_low
memtable_init
On node 0 totalpages: 16384
zone(0): 16384 pages.
zone(1): 0 pages.
zone(2): 0 pages.
Kernel command line: console=ttyS0,115200 root=/dev/mtdblock2
Calibrating delay loop... 599.65 BogoMIPS
Memory: 64MB = 64MB total
Memory: 62904KB available (1398K code, 261K data, 232K init)
XScale Cache/TLB Locking Copyright(c) 2001 MontaVista Software, Inc.
Dentry cache hash table entries: 8192 (order: 4, 65536 bytes)
Inode cache hash table entries: 4096 (order: 3, 32768 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer-cache hash table entries: 4096 (order: 2, 16384 bytes)
Page-cache hash table entries: 16384 (order: 4, 65536 bytes)
POSIX conformance testing by UNIFIX
PCI: bus0: Fast back to back transfers disabled
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Intel IOP3xx AAU RAID Copyright(c) 2003 Intel Corporation
Starting kswapd
JFFS2 version 2.1. (C) 2001 Red Hat, Inc., designed by Axis Communicatio
ns AB.
pty: 256 Unix98 ptys configured
Serial driver version 5.05c (2001-07-08) with MANY_PORTS SHARE_IRQ SERIA
L_PCI enabled
ttyS00 at 0xfe800000x (irq = 28) is a 16550A
Real Time Clock Driver v1.10e
RAMDISK driver initialized: 16 RAM disks of 8192K size 1024 blocksize
Intel(R) PRO/1000 Network Driver - version 5.0.43-k1
Copyright (c) 1999-2003 Intel Corporation.
eth0: Intel(R) PRO/1000 Network Connection
Uniform Multi-Platform E-IDE driver Revision: 7.00beta4-2.4
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus
=xx
cfi_cmdset_0001: Erase suspend on write enabled
Using buffer write method
Using RedBoot partition definition
Creating 6 MTD partitions on "IOP3xx Flash":
0x00000000-0x00040000 : "RedBoot"
0x00040000-0x00120000 : "kernel"
0x00120000-0x00260000 : "fakeroot"
0x00260000-0x007c0000 : "unallocated space"
0x007c0000-0x007c1000 : "RedBoot config"
mtd: partition "RedBoot config" doesn't end on an erase block -- force r
ead-only
0x007e0000-0x00800000 : "FIS directory"
md: raid5 personality registered as nr 4
raid5: measuring checksumming speed
iop3xx_aau: 223.200 MB/sec
raid5: using function: iop3xx_aau (223.200 MB/sec)
md: md driver 0.90.0 MAX_MD_DEVS=256, MD_SB_DISKS=27
md: Autodetecting RAID arrays.
md: autorun ...
md: ... autorun DONE.
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 4096 bind 4096)
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
NetWinder Floating Point Emulator V0.97 (double precision)
VFS: Mounted root (jffs2 filesystem).
Freeing init memory: 232K
Setting hostname iq80321:
Mounting proc filesystem:
mount: Mounting none on /proc failed: Device or resource busy
Please press Enter to activate this console.
BusyBox v1.00-pre10 (2004.04.27-01:28+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
# 得到shell提示符,引导成功!
/ #
# 前面我们使用erase/write/create连续三个命令完成了jffs2映像根文件系统的写
入,主要是为了保证0xff填充非有效数据的空间,如果能够保证这一点的话,使用
create命令直接写入FLASH也是可以的。怎么保证0xff填充呢?经验是,执行 fis
init –f 命令对FLASH完全初始化之后,空闲空间以0xFF填充;或者用 fis erase
命令擦除FLASH;或者用 mfill 命令将一段内存区域填充为0xFF之后再load文件至
该区域;必要的话可以用 dump 命令查看确认一下FLASH的内容。总之,理解了“为
什么”就可以灵活使用这些命令,而不必拘泥于文档中的演示。
# 下面是测试过程:
RedBoot> fis free
0xF0260000 .. 0xF07C0000
RedBoot> load -r -b 0x200000 -h 192.168.0.20 fakeroot.jffs2.img
Raw file loaded 0x00200000-0x0033ffff, assumed entry at 0x00200000
RedBoot> fis create -b 0x200000 -f 0xf0260000 -l 0x140000 fakeroot2
... Erase from 0xf0260000-0xf03a0000: ..........
... Program from 0x00200000-0x00340000 at 0xf0260000: ..........
... Unlock from 0xf07e0000-0xf0800000: .
... Erase from 0xf07e0000-0xf0800000: .
... Program from 0x01fdf000-0x01fff000 at 0xf07e0000: .
... Lock from 0xf07e0000-0xf0800000: .
RedBoot> fis list
Name FLASH addr Mem addr Length Entry point
RedBoot 0xF0000000 0xF0000000 0x00040000 0x00000000
RedBoot config 0xF07C0000 0xF07C0000 0x00001000 0x00000000
FIS directory 0xF07E0000 0xF07E0000 0x00020000 0x00000000
kernel 0xF0040000 0x00100000 0x000E0000 0x00100000
fakeroot 0xF0120000 0xF0120000 0x00140000 0x00100000
fakeroot2 0xF0260000 0xF0260000 0x00140000 0x00200000
RedBoot> fis free
0xF03A0000 .. 0xF07C0000
RedBoot> dump -b 0xf025ff00
F025FF00: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF |...........
.....|
F025FF10: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF |...........
.....|
RedBoot> fis load kernel
RedBoot> exec -c "console=ttyS0,115200 root=/dev/mtdblock3"
Using base address 0x00100000 and length 0x000e0000
Uncompressing Linux.....................................................
....
/ # cat /proc/mtd
dev: size erasesize name
mtd0: 00040000 00020000 "RedBoot"
mtd1: 000e0000 00020000 "kernel"
mtd2: 00140000 00020000 "fakeroot"
mtd3: 00140000 00020000 "fakeroot2"
mtd4: 00420000 00020000 "unallocated space"
mtd5: 00001000 00020000 "RedBoot config"
mtd6: 00020000 00020000 "FIS directory"
/ # mount
/dev/mtdblock3 on / type jffs2 (rw)
/proc on /proc type proc (rw)
/ #
  
5.8 FLASH存储空间分布
  RAM: 0x00000000-0x08000000, 0x0001b488-0x01fd1000 available
  FLASH: 0xf0000000 - 0xf0800000, 64 blocks of 0x00020000 bytes each.
  
Name
FLASH addr
Length
0
RedBoot
0xF0000000
0x00040000
1
kernel
0xF0040000
0x000E0000
内核
2
fakeroot
0xF0120000
0x00140000
根文件系统
3
0xF0260000
Free (unallocated space)
4
RedBoot config
0xF07C0000
0x00001000
5
FIS directory
0xF07E0000
0x00020000
0xF0800000
End
  
  

6 提示

6.1 已经解决的问题
6.1.1 问题描述
  整个开发过程还是比较顺利的,因为有裁减Linux系统的经验(lips),远程N
FS根文件系统的引导过程一次就成功了。稍后使用在FLASH上面使用jffs2文件系统
引导的过程中碰到了一些棘手的问题,幸运的是花了两天的时间就弄清楚了。这里
大概说明一下碰到的问题和解决方法。  当时的情况是,kernel已经写到了FLAS
H中,在主机上用 mkfs.jffs2 命令创建了 fakeroot 的映像文件,但是没有使用
--eraseblock=0x20000 和 -p 参数。然后在用 fis create 命令将映像文件从内存
写入FLASH时,-l 参数指定的长度是 0x200000 (2M),实际上映像文件只有 1.2M左
右,当时想把文件系统留大一些。
  准备好之后,以 root=/dev/mtdblock/2 作为参数启动内核,得到的结果如下

  
  RedBoot> fis list
  Name FLASH addr Mem addr Length Entry point
  RedBoot 0xF0000000 0xF0000000 0x00040000 0x00000000
  RedBoot config 0xF07C0000 0xF07C0000 0x00001000 0x00000000
  FIS directory 0xF07E0000 0xF07E0000 0x00020000 0x00000000
  kernel 0xF0040000 0x01008000 0x000C0000 0x01008000
  fakeroot 0xF0100000 0xF0100000 0x00200000 0x00100000
  RedBoot> fis free
   0xF0300000 .. 0xF07C0000
  RedBoot> fis load kernel
  RedBoot> exec -c "console=ttyS0,115200 root=/dev/mtdblock/2"
  Using base address 0x01008000 and length 0x000c0000
  Uncompressing Linux.................................................
...... done
  Linux version 2.4.21-rmk1-ds0-dj9 (root@lips) (gcc version 2.95.3 20
010315 (rel
  CPU: XScale-IOP80321 revision 2
  Machine: Intel IQ80321
  
  Using RedBoot partition definition
  Creating 6 MTD partitions on "IOP3xx Flash":
  0x00000000-0x00040000 : "RedBoot"
  0x00040000-0x00100000 : "kernel"
  0x00100000-0x00300000 : "fakeroot"
  0x00300000-0x007c0000 : "unallocated space"
  0x007c0000-0x007c1000 : "RedBoot config"
  mtd: partition "RedBoot config" doesn't end on an erase block -- for
ce read-onl
  0x007e0000-0x00800000 : "FIS directory"
  
  jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000000
0: 0xf018 i
  jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000000
4: 0xf018 i
  jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000000
8: 0xf018 i
  jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000000
c: 0xf018 id
  …………
  Further such events for this erase block will not be printed
  JFFS2: Erase block at 0x00000000 is not formatted. It will be erased

  jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0002000
0: 0x0008 id
  jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0002000
4: 0xaff0 id
  jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0002000
8: 0x1009 id
  …………
  Further such events for this erase block will not be printed
  JFFS2: Erase block at 0x00020000 is not formatted. It will be erased

  Cowardly refusing to erase blocks on filesystem with no valid JFFS2
nodes
  Kernel panic: VFS: Unable to mount root fs on 1f:00
  
  这里主要存在两个问题,分别说明一下。
6.1.2 创建jffs2文件系统注意事项
  引导过程中出现的数十行”jffs2_scan_eraseblock(): Magic bitmask 0x198
5 not found…”信息说明jffs2文件系统有问题。另外,如果我先用远程NFS根文件
系统引导,然后在目标机系统中直接 mount -t jffs2 /dev/mtdblock/2 /mnt 也会
得到同样的警告信息,不过可以在 /mnt 下面看到正确的文件系统内容。
  为了解决这个问题,我首先仔细看了 mkfs.jffs2 的手册页,发现 --erasebl
ock 参数似乎比较重要,而我没有使用,于是找到该参数值 0x20000,用该参数重
新生成了映像文件。测试表明问题仍然存在。
  查找资料发现,有人强调在 mkfs.jffs2 时使用 -p 选项,其作用是从文件末
尾到最后一个erase block填充0xFF。这时我意识到FLASH的未分配空间必须以0xFF
填充。而我先前的做法不能保证这一点。首先没有指定-p选项;其次,由于-l参数
指定了远远大于实际映像文件大小的长度,而将内存区域中大量垃圾数据写到了FL
ASH中。
  因此,重新带参数-p制作jffs2文件系统映像,并改-l 0x200000为0x140000写
FLASH,这样再次mount该设备就OK了,没有再出现警告信息。但是Kernel panic仍
然存在,这是另外一个问题。
  
6.1.3 /dev/mtdblock/2 还是 /dev/mtdblock2
  (首先说明,’2’只是个例子./dev/mtdblock/n,n=0,1,2,3,…)
  看起来这两个设备节点应该是完全等效的。至少我原来是这么认为。所看到的
资料中,有的用/dev/mtdblock/2,有的用/dev/mtdblock2。能够看到的差别就是,
如果需要多个MTD块设备节点的话,把这些节点放在单独的/dev/mtdblock目录中,
而不是统统放在/dev下面,可以使/dev看起来清爽一些。因此,我在制作根文件系
统的时候,选择了前者,即在/dev/mtdblock目录下面创建了0-7共8个设备节点。

  然而,“Kernel panic: VFS: Unable to mount root fs on 1f:00”错误说明
内核没有从引导参数“root=/dev/mtdblock/2”正确定位到根文件系统(即使已经
解决了上一个问题,保证jffs2文件系统没有问题)。
  在考虑排除了多种可能性之后,无奈之下我决定试一下“root=/dev/mtdblock
2”。奇迹发生了,引导成功!特别注意,这时我并没有修改/dev设备节点,而仅仅
是修改了引导参数的写法。也就是说,不论你创建的MTD设备节点是/dev/mtdblock
/2还是/dev/mtdblock2,内核引导参数都应该是“root=/dev/mtdblock2”!
  为了不致于引起更多迷惑,我还是把设备节点改变为了/dev/mtdblock2的形式
。那么内核引导参数中到底可不可以使用/dev/mtdblock/2的形式呢?后来我猜测内
核如果支持 devfs 的话应该是可以的。devfs 的目的不就是把/dev从一塌糊涂的扁
平结构改成清晰的层次结构嘛?不过我还没有验证。
  另外,在内核引导参数中使用“主设备号、次设备号”的形式来指定根文件系
统的位置也是可以的。如下所示,“root=1f02”同样指定了/dev/mtdblock2。0x1
f=31是MTD块设备的主设备号,0x02=2是次设备号,即mtdblock2.
RedBoot> fis load kernel
RedBoot> exec -c "console=ttyS0,115200 root=1f02"
Using base address 0x00100000 and length 0x000e0000
Uncompressing Linux.....................................................
....
......
VFS: Mounted root (jffs2 filesystem).
Freeing init memory: 232K
Please press Enter to activate this console.
BusyBox v1.00-pre10 (2004.04.27-01:28+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
/ # mount
/dev/mtdblock2 on / type jffs2 (rw)
/proc on /proc type proc (rw)
/ #
  
6.2 尚未解决的问题
6.2.1 RTC(硬件时钟与系统时间)
  BusyBox的hwclock不能访问RTC(/dev/rtc),会产生Segmentation fault,再
次访问会报告找不到RTC设备。
  目前因为无法同步硬件时钟和系统时间,每次重新启动后系统时间都复位至19
70年。
  测试发现 util-linux-2.11z (
http://kernel.org/pub/linux/utils/util-li
nux/util-linux-2.11z.tar.gz)中的hwclock有同样的问题。估计跟IQ80321板子有
关系?
  
6.2.2 与RedHat兼容的系统配置文件和启动脚本
  网络配置相关
  /etc/sysconfig/network-script
  /etc/rc.d/init.d/network
  系统日志相关
  /var/log/message
  
6.2.3 如何创建一个空的jffs2文件系统?
  
6.2.4 启动telnetd服务器
  有人说,只要将devpts挂载到/dev/pts即可。/etc/fstab文件中添加如下行:

none /dev/pts devpts mode=620
0 0
  On Fri, Jul 16, 2004 at 09:08:28AM +0800, Xiaoming DONG wrote:
  > I tried telnetd in BusyBox 1.00-pre10 and failed either.
  > My board is Intel IQ80321, using linux-2.4.21-rmk1-ds0.
  > I beleive that telnetd require some kernel configurations as follo
wing,
  > Character devices --->
  > [*] Virtual terminal
  > [*] Support for console on virtual terminal
  > But I cannot compile the kernel sucessful if I added these options
,
  > it failed on some files about 'keyboard' (my board have no keyboar
d, you know).
  > If someone do this successed, please let me know.
  
  You need PTY support, not virtual terminal support. And you need to
  mount the devpts filesystem: mount -t devpts devpts /dev/pts .
  
  
  Erik
  
  --
  ---- Erik Mouw ---- www.bitwizard.nl ---- +31 15 2600 998 ----

  
  在80321平台上面运行telnetd(BusyBox 1.00-pre10),然后从其他主机连接
、登录过程如下:
[root@lips root]# telnet 192.168.0.21
Trying 192.168.0.21...
Connected to 192.168.0.21.
Escape character is '^]'.
IQ80321 ARM Linux
Kernel 2.4.21-rmk1-ds0-dj9 on an armv5l
iq80321 login: root
Password:
Login incorrect
  
  可见,telnetd确实运行了,不过用户认证有问题。是否应该试一下TinyLogin

  
  (参考
http://www.busybox.net/lists/busybox/2003-May/008370.html)
[BusyBox] How I got telnetd to run
lbrigman at fcpa.fujitsu.com lbrigman at fcpa.fujitsu.com
Tue May 20 12:11:15 MDT 2003

Here is what I did to get my diskless nodes to run telnetd. Part o
f the problem with this
is that telnetd is considered a security risk and has been removed
from most default
distribution installations and replaced with ssh along with all the
supporting documentation.
Also I was not ever successful using the predeclared devices or usi
ng inetd. This is probably
my own fault because of a lack of understanding.


1. Compile busybox with telnetd on and set "use devpts" in "General
Configuration" to on. You
don't need to compile or turn on inetd, as this add to the
number of files that are needed.

2. Build a kernel with filesystems ->/dev/pts = Y. Character Devic
es Unix98 PTY = Y.
Chose a number of PTY to support. Configure your networking as
required for your setup.

3. In your root file system make a directory /dev/pts and mknod /de
v/ptmx c 5 2

4. If you are using shared libraries make sure you have
llibnsl.so.1 libnss_files.so.2 libnss_compat.so.2
with the appropriate symbolic links. You will have to have oth
ers for busybox to even run.
(My problem with some of the networking code is that mklibs.sh
misses these libraries)

5. Have an entry in the /etc/fstab file like
none /dev/pts devpts defaults 0 0

You will have to mount it either manually (mount -t devpts /dev
/pts) or when your startup
scripts run "mount -a".

6. You can start telnetd from the inittab but if you run it with re
spawn it will consume all you memory
as busybox (at least as late as 20030413 unstable development)
has problems with daemons.
So a working inittab line "::once:/usr/sbin/telnetd"

For testing you can start it from the command line with no opti
ons.

----
Larry Brigman
Fujitsu Computer Products of America
503.693.2051 lbrigman at fcpa.fujitsu.com
Coins 87-7935-2051

原创粉丝点击