Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2036450
  • 博文数量: 610
  • 博客积分: 11499
  • 博客等级: 上将
  • 技术积分: 5511
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-12 19:27
文章分类

全部博文(610)

文章存档

2016年(5)

2015年(18)

2014年(12)

2013年(16)

2012年(297)

2011年(45)

2010年(37)

2009年(79)

2008年(101)

分类:

2008-03-12 19:43:08

在嵌入式Linux系统中挂载 jffs2 根文件系统


在嵌入式Linux系统中挂载 jffs2 根文件系统
我已经在《构建基本的嵌入式Linux根文件系统》介绍了如何建立基本的嵌入式Linux根文件系统,并用NFS挂载成功。如果要以挂载JFFS2格式的根文件系统,其基本方法就是将这个建立好的根文件系统制作成jffs2镜像,烧到FLASH中,改改Linux的启动参数即可。
具体做法如下:
一、宿主机HOST编译制做MTD工具
 
从下载mtd-utils 的tarball,可以下载最新的。然后解压,并在其目录下 make 就好!
 
二、制作根文件系统的JFFS2镜像。
 
使用MTD工具中的mkfs.jffs2命令,具体做法如下:
mkfs.jffs2 -r /home/tekkamanninja/working/nfs/rootfs -o rootfs.jffs2 -e 0x4000 --pad=0x500000 -s 0x200 -n
 
各参数的意义:
(1)-r : 指定要做成image的源資料夾.
(2)-o : 指定輸出image檔案的文件名.
(3)-e : 每一塊要抹除的block size,預設是64KB.要注意,不同的flash, 其block size會不一樣.我的是三星的K9F1208U0B.
(4)--pad (-p): 用16進制來表示所要輸出檔案的大小,也就是root.jffs2的size。很重要的是, 為了不浪費flash空間, 這個值最好符合flash driver所規劃的區塊大小.以我的板子來說,就是5MB.
(5)如果挂载后会出现类似:CLEANMARKER node found at 0x0042c000 has totlen 0xc != normal 0x0  的警告,则加上 -n 就会消失。
(6) 还有的选项,自己看帮助!-h
 
三、烧写JFFS2镜像到NAND FLASH。
将 rootfs.jffs2拷贝到NFS共享目录,然后启动开发板。具体操作看我的开发板信息就好了:
U-Boot 1.3.1 (Feb 7 2008 - 16:41:05)

DRAM: 64 MB
Flash: 1 MB
NAND: NAND flash probing at 0x4E000000
  64 MB
In: serial
Out: serial
Err: serial
Hit any key to stop autoboot: 0
[Tekkaman2440]#nfs 0x30008000 192.168.1.22:/home/tekkamanninja/working/nfs/rootfs.jffs2
dm9000 i/o: 0x20000300, id: 0x90000a46
MAC: 08:08:08:08:12:27
operating at 100M full duplex mode
File transfer via NFS from server 192.168.1.22; our IP address is 192.168.1.2
Filename '/home/tekkamanninja/working/nfs/rootfs.jffs2'.
Load address: 0x30008000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ##################################################
done
Bytes transferred = 5242880 (500000 hex)
[Tekkaman2440]#nand erase 0xa00000 0x500000

NAND erase: device 0 offset 10485760, size 5242880 ...
OK
[Tekkaman2440]#nand write 0x30008000 0xa00000 0x500000

NAND write: device 0 offset 10485760, size 5242880 ...
 5242880 bytes written: OK
[Tekkaman2440]#setenv bootargs noinitrd root=/dev/mtdblock4 rootfstype=jffs2 rw console=ttySAC0,115200 init=/linuxrc mem=64M
[Tekkaman2440]#boot
dm9000 i/o: 0x20000300, id: 0x90000a46
MAC: 08:08:08:08:12:27
operating at 100M full duplex mode
File transfer via NFS from server 192.168.1.22; our IP address is 192.168.1.2
Filename '/home/tekkamanninja/working/nfs/zImage.img'.
Load address: 0x30008000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #####################################################
done
Bytes transferred = 1600564 (186c34 hex)
## Booting image at 30008000 ...
   Image Name: tekkamanninja
   Created: 2008-02-15 2:16:28 UTC
   Image Type: ARM Linux Kernel Image (uncompressed)
   Data Size: 1600500 Bytes = 1.5 MB
   Load Address: 30008000
   Entry Point: 30008040
   Verifying Checksum ... OK
   XIP Kernel Image ... OK

Starting kernel ...

Uncompressing Linux........................................................................................................ done, booting the kernel.
Linux version 2.6.24 (tekkamanninja@Tekkaman-Ninja) (gcc version 4.1.1) #1 Fri Feb 15 10:15:36 CST 2008
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
Machine: Tekkaman2440
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
S3C24XX Clocks, (c) 2004 Simtec Electronics
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: noinitrd root=/dev/mtdblock4 rootfstype=jffs2 rw console=ttySAC0,115200 init=/linuxrc mem=64M
irq: clearing pending ext status 00000200
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
PID hash table entries: 256 (order: 8, 1024 bytes)
timer tcon=00500000, tcnt a4ca, tcfg 00000200,00000000, usec 00001e57
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: 61464KB available (2960K code, 306K data, 120K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 64 bytes
NET: Registered protocol family 16
S3C2410 Power Management, (c) 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C2440: Clock Support, DVS off
S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics
DMA channel 0 at c4800000, irq 33
DMA channel 1 at c4800040, irq 34
DMA channel 2 at c4800080, irq 35
DMA channel 3 at c48000c0, irq 36
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
NetWinder Floating Point Emulator V0.97 (double precision)
JFFS2 version 2.2. (NAND) ©; 2001-2006 Red Hat, Inc.
fuse init (API version 7.9)
yaffs Feb 15 2008 10:10:34 Installing.
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
Serial: 8250/16550 driver $Revision: 1.90 $ 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
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: module loaded
dm9000 Ethernet Driver
eth0: dm9000 at f6100300,f6100304 IRQ 51 MAC: 08:08:08:08:12:27
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
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 3579 at 0x037ec000
Creating 7 MTD partitions on "NAND 64MiB 3,3V 8-bit":
0x00000000-0x00020000 : "U-Boot-1.3.1"
0x00020000-0x00030000 : "U-Boot-1.3.1 Parameter"
0x00030000-0x00500000 : "Linux2.6.24 Kernel"
0x00500000-0x00a00000 : "Root(cramfs)"
0x00a00000-0x00f00000 : "Root(JFFS2)"
0x00f00000-0x01400000 : "Root(YAFFS)"
0x01400000-0x04000000 : "DATA"
usbmon: debugfs is not available
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
mice: PS/2 mouse device common for all mice
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c2410-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c2410-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
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 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
s3c2410-rtc s3c2410-rtc: setting system clock to 2008-02-17 12:46:08 UTC (1203252368)
VFS: Mounted root (jffs2 filesystem).
Freeing init memory: 120K
init started: BusyBox v1.9.1 (2008-02-16 15:04:08 CST)
starting pid 779, tty '': '/etc/init.d/rcS'
----------mount all
----------Starting mdev......
*********************************************************
  Tekkaman Ninja 2440 Rootfs(nfs) 2008.2
        Love Linux !
********************************************************
starting pid 783, tty '': '/bin/login'
(none) login: root
Password:
login[783]: root login on 'console'

Processing /etc/profile...
Set search library path in /etc/profile
Set user path in /etc/profile
Set PS1 in /etc/profile
Done

[root@
阅读(1243) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:在Linux下开发AVR单片机的工具

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