最小yaffs2文件系统移植(目标板TQ2440)
2019-07-12 11:47发布
生成海报
转自:http://blog.sina.com.cn/s/blog_95268f5001013m6d.html
首先说一下最小文件系统需要的文件
(1)/dev/null /dev/consore这两个节点时一定要有的,/dev/consore是标准输入,标准输出,标准错误时要用到,也就是说我们要输入东西显示出来就要用到它,/dev/null是默认控制台
(2)init其实就是busybox
(3)/etc/inittab配置文件
(4)配置文件指定要运行的程序
(5)库
可以从www.busybox.net/downloads/下载busybox源码,busybox是将我们文件系统要用到的命令集合起来,这里使用busybox-1.13.0,下载好代码后解压
#tar xjv busybox-1.13.0.tar.bz2
然后进入目录#cd busybox-1.13.0,修改Makefile大概164行把改为CROSS_COMPILE ?=arm-linux-,还有189行改成 ARCH ?= arm,
接下来make menuconfig和内核一样进入菜单界面选择你要加进命令等
一般使用默认都很好了,这里只改一点,设置TAB键补齐
Busybox Settings --->
Busybox Library Tuning --->
[*] Tab completion
是否使用静态链接
Busybox Settings --->
Build Options --->
[ ] Build BusyBox as a static binary (no shared libs)
我们用动态链接这里不用选上
其它的使用默认都可以了
执行make命令
到了这里我们在/work下建一个yaffs2_root目录,用来安装busybox
#mkdir yaffs2_root
最后执行下面命令把 busybox安装在指定目录下
#make CONFIG_PREFIX=/work/yaffs2_root install
其中的linuxrc就是我们的sbin/init。
会生成bin,linuxrc -> bin/busybox*,sbin,usr几个目录,其它目录下的各种命令其实都是/bin/busybox的符号连接,下面可以看一下
root@www:/work/busybox-1.13.0/root/sbin# ll
总用量 8
drwxr-xr-x 2 root root 4096 2012-05-06 22:55 ./
drwxr-xr-x 17 root root 4096 2012-05-07 23:58 ../
lrwxrwxrwx 1 root root 14 2012-05-06 22:55 adjtimex -> ../bin/busybox*
lrwxrwxrwx 1 root root 14 2012-05-06 22:55 arp -> ../bin/busybox*
lrwxrwxrwx 1 root root 14 2012-05-06 22:55 blkid -> ../bin/busybox*
lrwxrwxrwx 1 root root 14 2012-05-06 22:55 devmem -> ../bin/busybox*
lrwxrwxrwx 1 root root 14 2012-05-06 22:55 fbsplash -> ../bin/busybox*
lrwxrwxrwx 1 root root 14 2012-05-06 22:55 fdisk -> ../bin/busybox*
lrwxrwxrwx 1 root root 14 2012-05-06 22:55 findfs -> ../bin/busybox*
lrwxrwxrwx 1 root root 14 2012-05-06 22:55 freeramdisk -> ../bin/busybox*
lrwxrwxrwx 1 root root 14 2012-05-06 22:55 fsck -> ../bin/busybox*
lrwxrwxrwx 1 root root 14 2012-05-06 22:55 fsck.minix -> ../bin/busybox*
lrwxrwxrwx 1 root root 14 2012-05-06 22:55 getty -> ../bin/busybox*
lrwxrwxrwx 1 root root 14 2012-05-06 22:55 halt -> ../bin/busybox*
lrwxrwxrwx 1 root root 14 2012-05-06 22:55 hdparm -> ../bin/busybox*
lrwxrwxrwx 1 root root 14 2012-05-06 22:55 hwclock -> ../bin/busybox*
lrwxrwxrwx 1 root root 14 2012-05-06 22:55 ifconfig -> ../bin/busybox*
lrwxrwxrwx 1 root root 14 2012-05-06 22:55 ifdown -> ../bin/busybox*
lrwxrwxrwx 1 root root 14 2012-05-06 22:55 ifenslave -> ../bin/busybox*
lrwxrwxrwx 1 root root 14 2012-05-06 22:55 ifup -> ../bin/busybox*
所以到这里我们的init就弄好了;
接下来建立/dev/condore,/dev/null设备节点,首先建一个/dev目录,还多建一个/dev/tq2440__serial0,因为我在内核里改了那个控制台名字;
进入yaffs2_root目录
#mkdir dev
#cd dev
然后
#mknod condore c 5 1
#mknod null c 1 3
#mknod tq2440_serial0 c 204 64
接下来就是建立配置文件在/etc/inittab下
先建立etc目录
#mkdir etc
#cd etc
接下来就是
#vim inittab
tq2440_serial0::askfirst:-/bin/sh
保存退出后加上x权限
#chmod 777 inittab
就写入这一行就可以了,我们没有启动其它程序
由于没有指定其他程序所以我们不用再建立其它程序,这里只是先做一个最小文件系统用来体验一下的
接下来就是建立库
先建立lib目录
#nkdir lib
#cd lib
接下来就是复制我们交叉编译链的库过来,这里是建立动态库,我的是4.3.3编译链
# cp -f /work/tools/opt/EmbedSky/4.3.3/arm-none-linux-gnueabi/libc/armv4t/lib/*.so* lib -a
#cp -f /work/tools/opt/EmbedSky/4.3.3/arm-none-linux-gnueabi/libc/armv4t/usr/lib/*.so* lib -a
要加上lib -a 它代表把那个符号连接都复制过来,要不让的话,像下面那样
lrwxrwxrwx 1 root root 14 2012-05-09 18:19 libuuid.so.1 -> libuuid.so.1.2*
没有加lib -a的话不会有链接
到了这里我们的最小文件系统就建好了,接下来是制作出yaffs2的镜像,mkyaffs2image这个命令是在交叉编译链里有的(TQ2440里就会有,不过一定要交叉编译链里的,也就是说你用什么交叉编译链编译文件系统的就要用对应交叉编译链里的mkyaffs2image要么可能你能编译出文件系统镜像,不过编译出来的文件系统可能不能用),把它复制到/usr/local/sbin目录下。然后执行(注意这时要在/work目录里)
#mkyaffs2image yaffs2_root yaffs2
制作出来的yaffs2加上x如下
#chmod 777 yaffs2
下面是这个文件系统的运行情况
Uncompressing Linux......................................................................................................................... done, booting the kernel.
Linux version 2.6.30.4-EmbedSky (root@www) (gcc version 4.3.3 (Sourcery G++ Lite 2009q1-203) ) #54 Sun May 6 23:43:18 CST 2012
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: TQ2440
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, (c) 2004 Simtec Electronics
S3C244X: core 400.000 MHz, memory 100.000 MHz, peripheral 50.000 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/mtdblock3 init=/linuxrc console=ttySAC0
NR_IRQS:85
irq: clearing pending ext status 00080000
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: 60864KB available (3480K code, 364K data, 136K init, 0K highmem)
Calibrating delay loop... 199.47 BogoMIPS (lpj=498688)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 936 bytes
NET: Registered protocol family 16
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 at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c2440-i2c s3c2440-i2c: slave address 0x10
s3c2440-i2c s3c2440-i2c: bus frequency set to 97 KHz
s3c2440-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
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
JFFS2 version 2.2. (NAND) (SUMMARY) 漏 2001-2006 Red Hat, Inc.
ROMFS MTD (C) 2007 Red Hat, Inc.
yaffs May 6 2012 16:12:42 Installing.
msgmni has been set to 119
io scheduler noop registered (default)
Console: switching to colour frame buffer device 60x34
fb0: s3c2410fb frame buffer device
s3c2440-uart.0: tq2440_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: tq2440_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: tq2440_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2440
loop: module loaded
Driver 'sd' needs updating - please use bus_type methods
dm9000 Ethernet Driver, V1.31
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c2440-nand s3c2440-nand: Tacls=2, 20ns Twrph0=3 30ns, Twrph1=2 20ns
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 1785 at 0x00000df20000
Bad eraseblock 1811 at 0x00000e260000
Creating 4 MTD partitions on "NAND 256MiB 3,3V 8-bit":
0x000000000000-0x000000040000 : "u-boot"
0x000000200000-0x000000400000 : "kernel"
0x000000400000-0x000000c00000 : "jffs2"
0x000000c00000-0x000010000000 : "yaffs2"
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
s3c2410_udc: debugfs dir creation failed -19
mice: PS/2 mouse device common for all mice
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
i2c /dev entries driver
Linux video capture interface: v2.00
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
Advanced Linux Sound Architecture Driver Version 1.0.20.
ALSA device list:
No soundcards found.
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)
end_request: I/O error, dev mtdblock3, sector 256
isofs_fill_super: bread failed, dev=mtdblock3, iso_blknum=64, block=128
yaffs: dev is 32505859 name is "mtdblock3"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.3, "mtdblock3"
yaffs: auto selecting yaffs2
block 1690 is bad
block 1716 is bad
yaffs_read_super: isCheckpointed 0
VFS: Mounted root (yaffs filesystem) on device 31:3.
Freeing init memory: 136K
Please press Enter to activate this console.
/ #
/ #
/ #
/ #
/ # ls
bin etc linuxrc sbin
dev lib lost+found usr
/ #
上面只是一个最小的文件系统。。。。。。。。。
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮