分类: LINUX
2010-10-22 14:01:18
1、yaffs2源代码获取
进入 ,点击“Download GNU tarball”,下载后出现cvs-ro ot.tar.gz压缩包。
2、busybox-1.13.3
从 下载busybox,这里下载的是busy busybox-1.13.3.tar.gz。
3、根文件系统制作工具
从 网站下载根文件系统制作工具mkyaffs2image.tgz。
4、友善之臂的根文件系统
在制作根文件系统时,需要用到链接库,为保证链接库能用直接用友善之臂的根文件系统root_qtopia 中的链接库lib,到友善之臂网站下载root_qtopia.tgz。
5、 给内核打yaffs2文件系统的补丁
cd /opt/stdudyarm/source
tar –zxvf cvs-root.tar.gz –C /opt/studyarm
cd /opt/stdudyarm/cvs/yaffs2/
./patch-ker.sh c /opt/studyarm/linux-2.6.29.1/
上面命令完成下面三件事情:
(1) 修改内核fs/Kconfig
增加一行:source "fs/yaffs2/Kconfig"
(2) 修改内核fs/Kconfig
增加一行:ojb-$(CONFIG_YAFFS_FS) +=yaffs2/
(3) 在内核fs/目录下创建yaffs2目录
将yaffs2源码目录下面的Makefile.kernel文件复制为内核fs/yaffs2/Makefie;
将yaffs2 源码目录的Kconfig文件复制到内核fs/yaffs2目录下;
将yaffs2源码目录下的*.c *.h文件复制到内核fs/yaffs2目录下.
6 配置Linux内核
选择支持yaffs2文件系统
Filesystem--->
Miscellaneous filesystems--->
<*>YAFFS2 file system support
[*] Lets Yaffs do its own ECC
Native language support
<*> Codepage 437 (United States,Canada)
<*>Simplified Chinese charset(GB2312)
<*>Traditional Chinese charset(Big5)
<*>NLS ISO 8859-1(Latin1:Western European Languages)
<*>NLS UTF-8
编译内核
make zImage
二.制作根文件系统
2.1嵌入式Linux中都需要构建根文件系统,构建根文件系统的规则在FHS(Filesystem Hierarchy Standard)文档中,下面是根文件系统顶层目录。
目录 内容
bin 存放所有用户都可以使用的、基本的命令。
sbin 存放的是基本的系统命令,它们用于启动系统、修复系统等。
usr 里面存放的是共享、只读的程序和数据。
proc 这是个空目录,常作为proc文件系统的挂载点。
dev 该目录存放设备文件和其它特殊文件。
etc 存放系统配置文件,包括启动文件。
lib 存放共享库和可加载块(即驱动程序),共享库用于启动系统、运行根文件系统中的可执行程序。
boot 引导加载程序使用的静态文件
home 用户主目录,包括供服务账号锁使用的主目录,如FTP
mnt 用于临时挂接某个文件系统的挂接点,通常是空目录。也可以在里面创建空的子目录。
opt 给主机额外安装软件所摆放的目录。
root root用户的主目录
tmp 存放临时文件,通常是空目录。
var 存放可变的数据。
2.2、构建根文件按系统
2.2.1、建立根文件系统目录
进入到/opt/studyarm目录,新建建立根文件系统目录的脚本文件 create_rootfs_bash,使用命令chmod +x create_rootfs_bash改变文件的可执行权 限,./create_rootfs_bash运行脚本,就完成了根文件系统目录的创建。
#!/bin/sh
echo "------Create rootfs directons start...--------"
mkdir rootfs
cd rootfs
echo "--------Create root,dev....----------"
mkdir root dev etc boot tmp var sys proc lib mnt home
mkdir etc/init.d etc/rc.d etc/sysconfig
mkdir usr/sbin usr/bin usr/lib usr/modules
echo "make node in dev/console dev/null"
mknod -m 600 dev/console c 5 1
mknod -m 600 dev/null c 1 3
mkdir mnt/etc mnt/jffs2 mnt/yaffs mnt/da
mkdir var/lib var/lock var/run var/tmp
chmod 1777 tmp
chmod 1777 var/tmp
echo "-------make direction done---------"
改变了tmp目录的使用权,让它开启sticky位,为tmp目录的使用权开启此位,可确保 tmp目录底下建立的文件,只有建立它的用户有权删除。尽管嵌入式系统多半是单用户,不过有些嵌入式应用不一定用root的权限来执行,因此需要遵照根文 件系统权限位的基本规定来设计。
2.2.2、建立动态链接库
动态链接库直接用友善之臂的,先解压友善之臂的根文件包,拷贝lib的内容到新建的根文件目录lib内。
cd /mnt/hgfs/share
tar –zxvf root_qtopia.tgz –C /opt/studyarm
cp –rfd /opt/studyarm/root_qtopia/lib/* /opt/studyarm/rootfs/lib/*
2.2.3 交叉编译Bosybox
Bosybox是一个遵循GPL v2协议的开源项目,它在编写过程总对文件大小进行优化,并考虑了系统资源有限(比如内存等)的情况,使用Busybox可以自动生成根文件系统所需的bin、sbin、usr目录和linuxrc文件。
1、解压busybox
cd /mnt/hgfs/share
tar –zxvf busybox-1.13.3.tar.tgz –C /opt/studyarm
2、进入源码,修改Makefile文件:
cd /opt/studyarm/busybox-1.13.3
修改:
CROSS_COMPILE ?=arm-linux- //第164行
ARCH ?=arm //第189行
3、配置busybox
输入make menuconfig进行配置
(1)、Busybox Settings--->
General Configuration--->
[*] Show verbose applet usage messages
[*] Store applet usage messages in compressed form
[*] Support –install [-s] to install applet links at runtime
[*] Enable locale support(system needs locale for this to work)
[*] Support for –long-options
[*] Use the devpts filesystem for unix98 PTYs
[*] Support writing pidfiles
[*] Runtime SUID/SGID configuration via /etc/busybox.config
[*] Suppress warning message if /etc/busybox.conf is not readable
Build Options--->
[*] Build BusyBox as a static binary(no shared libs)
[*] Build with Large File Support(for accessing files>2GB)
Installation Options->
[]Don’t use /usr
Applets links (as soft-links) --->
(./_install) BusyBox installation prefix
Busybox Library Tuning --->
(6)Minimum password legth
(2)MD5:Trade Bytes for Speed
[*]Fsater /proc scanning co
[*]Command line editing
(1024)Maximum length of input
[*] vi-style line editing commands
(15) History size
[*] History saving
[*] Tab completion
[*]Fancy shell prompts
(4) Copy buffer size ,in kilobytes
[*]Use ioctl names rather than hex values in error messages
[*]Support infiniband HW
(2)、Linux Module Utilities--->
(/lib/modules)Default directory containing modules
(modules.dep)Default name of modules.dep
[*] insmod
[*] rmmod
[*] lsmod
[*] modprobe
-----options common to multiple modutils
[ ] support version 2.2/2.4 Linux kernels
[*]Support tainted module checking with new kernels
[*]Support for module .aliases file
[*] support for modules.symbols file
(3)、在busybox中配置对dev下设备类型的支持
dev的创建有三种方法:
手动创建:在制作根文件系统的时候,就在dev目录下创建好要使用的设备文件,系统挂接根文件系统后,就可以使用dev目录下的设备文件了。
使用devfs文件系统:这种方法已经过时,具有不确定的设备映射、没有足够的主/次设备号、devfs消耗大量的内存。
udev:它是个用户程序,能根据系统中硬件设备的状态动态的更新设备文件,包括设备文件的创建、删除等。它的操作相对复杂,但灵活性很高
mdev是busybox自带的一个简化版的udev,适合于嵌入式的应用埸合。其具有使用 简单的特点。它的作用,就是在系统启动和热插拔或动态加载驱动程序时,自动产生驱动程序所需的节点文件。在以busybox为基础构建嵌入式linux的 根文件系统时,使用它是最优的选择。下面的选项将增加对mdev的支持。
Linux System Utilities --->
[*]Support /etc/mdev.conf
[*]Support command execution at device addition/removal
4、 编译busybox
编译busybox到指定目录:
cd /opt/studyarm/busybox-1.13.3
make CONFIG_PREFIX=/opt/studyarm/rootfs install
在rootfs目录下会生成目录bin、sbin、usr和文件linuxrc的内容。
2.2.4 建立etc目录下的配置文件
1、etc/mdev.conf文件,内容为空。
2、拷贝主机etc目录下的passwd、group、shadow文件到rootfs/etc目录下。
3、etc/sysconfig目录下新建文件HOSTNAME,内容为”H3-Studio”。
4、etc/inittab文件:
#etc/inittab
::sysinit:/etc/init.d/rcS
s3c2410_serial0::askfirst:-/bin/sh
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a –r
5、etc/init.d/rcS文件:
#!/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
runlevel=S
prevlevel=N
umask 022
export PATH runlevel prevlevel
echo "----------munt all----------------"
mount -a
echo /sbin/mdev>/proc/sys/kernel/hotplug
mdev -s
echo "***********************************************"
echo "****************Studying ARM*********************"
echo "Kernel version:linux-2.6.29.1"
echo "Student:Huang huahai"
echo "Date:2009.10.1"
echo "***********************************************"
/bin/hostname -F /etc/sysconfig/HOSTNAME
(或者直接 /bin/hostname H3-Studio )
使用以下命令改变rcS的执行权限:
Chmod +x rcS
6、etc/fstab文件:
#device mount-point type option dump fsck order
proc /proc proc defaults 0 0
none /tmp ramfs defaults 0 0
sysfs /sys sysfs defaults 0 0
mdev /dev ramfs defaults 0 0
7、 etc/profile文件:
#Ash pro
#vim:syntax=sh
#No core file by defaults
#ulimit -S -c 0>/dev/null 2>&1
USER="id -un"
LOGNAME=$USER
PS1='[\u@\h=W]#'
PATH=$PATH
HOSTNAME='/bin/hostname'
export USER LOGNAME PS1 PATH
2.2.5 制作根文件系统映像文件
使用以下命令安装好yaffs文件系统制作工具:
cd /mnt/hgfs/share
tar –zxvf mkyaffs2image.tgz –C /
在/opt/studyarm目录下,使用命令mkyaffs2image rootfs rootfs.img生成根文件系统映像文件。
启动信息:
Copy linux kernel from 0x00050000 to 0x30008000, size = 0x00200000 ... done
zImage magic = 0x016f2818
Setup linux parameters at 0x30000100
linux command line is: "noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0"
MACH_TYPE = 782
NOW, Booting Linux......
Uncompressing
Linux...........................................................................................................................
done, booting the kernel.
Linux version 2.6.29.1 (root@FriendlyARM) (gcc version 4.3.2 (Sourcery G++ Lite 2008q3-72) ) #2 Thu Oct 1 16:46:24 JST 2009
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT da
Machine: Study-S3C2440
ATAG_INITRD is deprecated; please update your bootloader.
Memory policy: ECC disabled, Da
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, (c) 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
PID hash table entries: 256 (order: 8, 1024 bytes)
Console: colour dummy device 80x30
console [ttySAC0] enabled
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 60828KB available (3556K co
Calibrating delay loop... 201.93 BogoMIPS (lpj=504832)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 716 bytes
NET: Registered protocol family 16
S3C2410 Power Management, (c) 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics
DMA channel 0 at c4808000, irq 33
DMA channel 1 at c4808040, irq 34
DMA channel 2 at c4808080, irq 35
DMA channel 3 at c48080c0, irq 36
S3C244X: Clock Support, DVS off
bio: create slab
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
NET: Registered protocol family 1
NetWinder Floating Point Emulator V0.97 (extended precision)
JFFS2 version 2.2. (NAND) (SUMMARY) © 2001-2006 Red Hat, Inc.
yaffs Oct 1 2009 16:45:43 Installing.
msgmni has been set to 118
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
Console: switching to colour frame buffer device 30x40
fb0: s3c2410fb frame buffer device
lp: driver loaded but no devices found
ppdev: user-space parallel port driver
Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
s3c2440-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
loop: module loaded
dm9000 Ethernet Driver, V1.31
Uniform Multi-Platform E-IDE driver
ide-gd driver 1.18
ide-cd driver 5.00
Driver 'sd' needs updating - please use bus_type methods
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c2440-nand s3c2440-nand: Tacls=1, 9ns Twrph0=4 39ns, Twrph1=1 9ns
NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 3339 at 0x00000342c000
Creating 8 MTD partitions on "NAND 64MiB 3,3V 8-bit":
0x000000000000-0x000000030000 : "bootloder"
0x000000050000-0x000000250000 : "kernel"
0x000000250000-0x000003ffc000 : "root"
0x000000800000-0x000000a00000 : "S3C2410 flash partition 3"
0x000000a00000-0x000000e00000 : "S3C2410 flash partition 4"
0x000000e00000-0x000001800000 : "S3C2410 flash partition 5"
0x000001800000-0x000003000000 : "S3C2410 flash partition 6"
0x000003000000-0x000004000000 : "S3C2410 flash partition 7"
usbmon: debugfs is not available
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
usbcore: registered new interface driver libusual
usbcore: registered new interface driver usbserial
USB Serial support registered for generic
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial Driver core
USB Serial support registered for FTDI USB Serial Device
usbcore: registered new interface driver ftdi_sio
ftdi_sio: v1.4.3:USB FTDI Serial Converters Driver
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
mice: PS/2 mouse device common for all mice
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c2440-i2c s3c2440-i2c: slave address 0x10
s3c2440-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c2440-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
TCP cubic registered
NET: Registered protocol family 17
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
yaffs: dev is 32505858 name is "mtdblock2"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.2, "mtdblock2"
yaffs: block 3191 is marked bad
block 3192 is bad
yaffs_read_super: isCheckpointed 0
VFS: Mounted root (yaffs filesystem) on device 31:2.
Freeing init memory: 156K
------mount all------
************************************
**********studyARM******************
Kernel version:linux-2.6.29.1
Student:Huang huahai
Da
***********************************
Please press Enter to activate this console.
OK!