cramfs文件系统制作与移植(二)

*****************************************************************************************************************

接        续:cramfs文件系统移植(一)点击打开链接

作        者:fulinux

装载声明:点击打开链接

*****************************************************************************************************************

1、下面我以fl2440开发板的256M的nandflash进行移植,内核中nandflash的分区表信息是这样的

Creating 11 MTD partitions on "NAND":
0x000000000000-0x000000100000 : "mtdblock0 u-boot 1MB"
0x000000100000-0x000000500000 : "mtdblock1 kernel 4MB"
0x000000500000-0x000000f00000 : "mtdblock2 ramdisk 10MB"
0x000000f00000-0x000001e00000 : "mtdblock3 cramfs 15MB"
0x000001e00000-0x000004600000 : "mtdblock4 jffs2 40MB"
0x000004600000-0x000006e00000 : "mtdblock5 yaffs2 40MB"
0x000006e00000-0x000009600000 : "mtdblock6 ubifs 40MB"
0x000009600000-0x000009700000 : "mtdblock7 info 1MB"
0x000009700000-0x00000bf00000 : "mtdblock8 apps 40MB"
0x00000bf00000-0x00000e700000 : "mtdblock9 data 40MB"
0x00000e700000-0x000010000000 : "mtdblock10 backup 25MB"

同时

[lingyun@localhost linux-3.0]$vt100

[lingyun@localhost linux-3.0]$make menuconfig

将下面的

-> General setup                                                                                                     |
  |                  -> Initial RAM filesystem and RAM disk (initramfs/initrd) support (BLK_DEV_INITRD [=y]) 中的

(这里的内容为空)    Initramfs source file(s)

 File systems  --->
      Miscellaneous filesystems  --->
           <*> Compressed ROM file system support (cramfs)

2、在更文件系统的dev目录下创建11个mtdblock设备

[lingyun@localhost rootfs]$ cd rootfs_tree/
[lingyun@localhost rootfs_tree]$ ls
apps    bin   dev  home  init  linuxrc  media  opt   root  stat  tmp  var
backup  data  etc  info  lib   logs     mnt    proc  sbin  sys   usr
[lingyun@localhost rootfs_tree]$ cd dev/
[lingyun@localhost dev]$ ls
console  null  ttyS0
[lingyun@localhost dev]$ sudo mknod mtdblock0 b 31 0
[lingyun@localhost dev]$ sudo mknod mtdblock1 b 31 1
[lingyun@localhost dev]$ sudo mknod mtdblock2 b 31 2
[lingyun@localhost dev]$ sudo mknod mtdblock3 b 31 3
[lingyun@localhost dev]$ sudo mknod mtdblock4 b 31 4
[lingyun@localhost dev]$ sudo mknod mtdblock5 b 31 5 
[lingyun@localhost dev]$ sudo mknod mtdblock6 b 31 6 
[lingyun@localhost dev]$ sudo mknod mtdblock7 b 31 7 
[lingyun@localhost dev]$ sudo mknod mtdblock8 b 31 8 
[lingyun@localhost dev]$ sudo mknod mtdblock9 b 31 9 
[lingyun@localhost dev]$ sudo mknod mtdblock10 b 31 10 

[lingyun@localhost dev]$ ls
console    mtdblock1   mtdblock2  mtdblock4  mtdblock6  mtdblock8  null
mtdblock0  mtdblock10  mtdblock3  mtdblock5  mtdblock7  mtdblock9  ttyS0
[lingyun@localhost dev]$ ls
console    mtdblock1   mtdblock2  mtdblock4  mtdblock6  mtdblock8  null
mtdblock0  mtdblock10  mtdblock3  mtdblock5  mtdblock7  mtdblock9  ttyS0
[lingyun@localhost dev]$ 


3、制作cramfs文件系统的工具,可以在下面的文章中找到

点击打开链接


4、制作rootfs.cramfs,并将其拷贝到/tftp目录下

[lingyun@localhost rootfs]$ mkcramfs rootfs_tree/ rootfs.cramfs
Directory data: 8284 bytes
Everything: 5324 kilobytes
Super block: 76 bytes
CRC: 318312b
[lingyun@localhost rootfs]$ du -h rootfs.cramfs
5.2M    rootfs.cramfs
[lingyun@localhost rootfs]$ cp rootfs.cramfs /tftp/


5、根据第一步中分区表的信息,将rootfs.cramfs烧录到开发板中

(1)下面是开发板中低环境变量

[ s3c2440@fulinux]# pri
bootargs=console=ttyS0,115200 mem=64M initrd=0x30800000,16M root=/dev/ram0 rw loglevel=7
bootcmd=run bootcmd_ramdisk
cpu=s3c2440
bbl=nand erase 0 100000;tftp 30008000 u-boot-$cpu.bin;nand write 30008000 0 $filesize
norbbl=erase bank 1;tftp 30008000 u-boot-$cpu.bin;cp.b 30008000 0 $filesize
bkr=tftp 30008000 uImage-$cpu.gz;nand erase 100000 400000;nand write 30008000 100000 $filesize
brdfs=tftp 30800000 ramdisk-$cpu.gz;nand erase 500000 a00000;nand write 30800000 500000 $filesize
bubifs=tftp 30800000 ubifs-$cpu.img;nand erase 0x02e00000 0x01400000;nand write 0x30800000 0x2e00000 0x4c0000
bootcmd_ramdisk=nand read 30008000 100000 400000;nand read 30800000 500000 a00000;bootm 30008000
bootcmd_rootfs=nand read 30008000 100000 400000;bootm 30008000
tpb=tftp 30008000 uImage-$cpu.gz;tftp 30800000 ramdisk-$cpu.gz;bootm 30008000 
bootargs_ramdisk=console=ttyS0,115200 mem=64M initrd=0x30800000,16M root=/dev/ram0 rw loglevel=7
bootargs_ubifs=console=ttyS0,115200 mem=64M ubi.mtd=5 root=ubi0:rootfs rootwait rootfstype=ubifs rw
mtdids=nand0=nand0
mtdparts=mtdparts=nand0:1M@0x0(u-boot),5M@0x100000(kernel),10M@0x600000(ramdisk),10M@0x1000000(cramfs),20M@0x1a00000(yaffs2),20M@0x2e00000(ubifs),-(users)
bootdelay=1
baudrate=115200
ethaddr=08:00:3e:26:0a:6b
ipaddr=192.168.1.244
netmask=255.255.255.0
ethact=dm9000
serverip=192.168.1.3
stdin=serial
stdout=serial
stderr=serial


Environment size: 1377/131068 bytes
[ s3c2440@fulinux]# 


(2)下面设置一个烧录rootfs.cramfs的环境变量

[ s3c2440@fulinux ]# set bcramfs 'tftp 30800000 rootfs.cramfs;nand erase f00000 600000;nand write 30800000 f00000 600000'
[ s3c2440@fulinux ]# save
Saving Environment to NAND...
Erasing Nand...
Erasing at 0x60000 -- 100% complete.
Writing to Nand... done
[ s3c2440@fulinux ]# 


(3)下面是烧录

[ s3c2440@fulinux ]# run bcramfs 
dm9000 i/o: 0x20000300, id: 0x90000a46 
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:6b
could not establish link
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.3; our IP address is 192.168.1.244
Filename 'rootfs.cramfs'.
Load address: 0x30800000
Loading: T #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ###############################################
done
Bytes transferred = 5451776 (533000 hex)


NAND erase: device 0 offset 0xf00000, size 0x600000
Erasing at 0x14e0000 -- 100% complete.
OK


NAND write: device 0 offset 0xf00000, size 0x600000
 6291456 bytes written: OK
[ s3c2440@fulinux ]#


6、设置bootargs 和bootcmd

[ s3c2440@fulinux ]# set bootargs 'noinitrd root=/dev/mtdblock3 rootfstype=cramfs init=/linuxrc console=ttyS0,115200'
[ s3c2440@fulinux ]# set bootcmd_cramfs 'nand read 30008000 100000 400000;bootm 30008000'
[ s3c2440@fulinux ]# set bootcmd 'run bootcmd_cramfs'
[ s3c2440@fulinux ]# save
Saving Environment to NAND...
Erasing Nand...
Erasing at 0x60000 -- 100% complete.
Writing to Nand... done
[ s3c2440@fulinux ]# 


7、根据分区表下载内核到开发板中

[ s3c2440@fulinux ]# tftp 30008000 linuxrom-fulinux.bin;nand erase 100000 400000;nand write 30008000 100000 400000
dm9000 i/o: 0x20000300, id: 0x90000a46 
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:6b
could not establish link
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.3; our IP address is 192.168.1.244
Filename 'linuxrom-fulinux.bin'.
Load address: 0x30008000
Loading: T #################################################################
         #################################################################
         ################################################
done
Bytes transferred = 2612480 (27dd00 hex)


NAND erase: device 0 offset 0x100000, size 0x400000
Erasing at 0x4e0000 -- 100% complete.
OK


NAND write: device 0 offset 0x100000, size 0x400000
 4194304 bytes written: OK
[ s3c2440@fulinux ]#


8、启动开发板

[ s3c2440@fulinux ]# bootm
## Booting kernel from Legacy Image at 30008000 ...
   Image Name:   Linux Kernel
   Created:      2013-04-23  12:05:15 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2612416 Bytes = 2.5 MiB
   Load Address: 30008000
   Entry Point:  30008040
   Verifying Checksum ... OK
   XIP Kernel Image ... OK
OK
OS entry point: 30008040
Image entry point=30008040


Starting kernel ...


Uncompressing Linux... done, booting the kernel.
Linux version 3.0.0 ([email protected]) (gcc version 4.5.4 (Buildroot 2012.08) ) #2 Tue Apr 23 20:05:12 CST 2013
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: SMDK2440
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, Copyright 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/mtdblock3 rootfstype=cramfs init=/linuxrc console=ttyS0,115200
PID hash table entries: 256 (order: -2, 1024 bytes)
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: 59468k/59468k available, 6068k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    DMA     : 0xffc00000 - 0xffe00000   (   2 MB)
    vmalloc : 0xc4800000 - 0xf6000000   ( 792 MB)
    lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .init : 0xc0008000 - 0xc002f000   ( 156 kB)
      .text : 0xc002f000 - 0xc04f3000   (4880 kB)
      .data : 0xc04f4000 - 0xc0523c40   ( 192 kB)
       .bss : 0xc0523c64 - 0xc05500c4   ( 178 kB)
NR_IRQS:85
irq: clearing pending ext status 00080000
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttyS0] enabled
Calibrating delay loop... 201.52 BogoMIPS (lpj=503808)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
gpiochip_add: gpios 288..303 (GPIOK) failed to register
gpiochip_add: gpios 320..334 (GPIOL) failed to register
gpiochip_add: gpios 352..353 (GPIOM) failed to register
NET: Registered protocol family 16
S3C Power Management, Copyright 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, Copyright 2003-2006 Simtec Electronics
DMA channel 0 at c4804000, irq 33
DMA channel 1 at c4804040, irq 34
DMA channel 2 at c4804080, irq 35
DMA channel 3 at c48040c0, irq 36
S3C244X: Clock Support, DVS off
s3c-adc s3c24xx-adc: attached adc driver
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
Advanced Linux Sound Architecture Driver Version 1.0.24.
cfg80211: Calling CRDA to update world regulatory domain
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
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
NetWinder Floating Point Emulator V0.97 (extended precision)
NTFS driver 2.1.30 [Flags: R/W].
JFFS2 version 2.2. (NAND) (SUMMARY)  © 2001-2006 Red Hat, Inc.
msgmni has been set to 116
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
Console: switching to colour frame buffer device 60x34
fb0: s3c2410fb frame buffer device
s3c2440-uart.0: ttyS0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: ttyS1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: ttyS2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
loop: module loaded
at24 0-0050: 65536 byte 24c512 EEPROM, writable, 128 bytes/write
physmap platform flash device: 00400000 at 08000000
physmap-flash physmap-flash.0: map_probe failed
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 221 at 0x000001ba0000
Bad eraseblock 1592 at 0x00000c700000
Creating 11 MTD partitions on "NAND":
0x000000000000-0x000000100000 : "mtdblock0 u-boot 1MB"
0x000000100000-0x000000500000 : "mtdblock1 kernel 4MB"
0x000000500000-0x000000f00000 : "mtdblock2 ramdisk 10MB"
0x000000f00000-0x000001e00000 : "mtdblock3 cramfs 15MB"
0x000001e00000-0x000004600000 : "mtdblock3 jffs2 40MB"
0x000004600000-0x000006e00000 : "mtdblock4 yaffs2 40MB"
0x000006e00000-0x000009600000 : "mtdblock5 ubifs 40MB"
0x000009600000-0x000009700000 : "mtdblock6 info 1MB"
0x000009700000-0x00000bf00000 : "mtdblock7 apps 40MB"
0x00000bf00000-0x00000e700000 : "mtdblock8 data 40MB"
0x00000e700000-0x000010000000 : "mtdblock9 backup 25MB"

PPP generic driver version 2.4.2
PPP Deflate Compression module registered
PPP BSD Compression module registered
PPP MPPE Compression module registered
NET: Registered protocol family 24
dm9000 Ethernet Driver, V1.31
eth0: dm9000a at c4864300,c4866304 IRQ 51 MAC: 08:00:3e:26:0a:6b (chip)
usbcore: registered new interface driver rt2800usb
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: New USB device found, idVendor=1d6b, idProduct=0001
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: S3C24XX OHCI
usb usb1: Manufacturer: Linux 3.0.0 ohci_hcd
usb usb1: SerialNumber: s3c24xx
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
usbcore: registered new interface driver usbserial
usbserial: USB Serial Driver core
USB Serial support registered for ch341-uart
usbcore: registered new interface driver ch341
USB Serial support registered for FTDI USB Serial Device
usbcore: registered new interface driver ftdi_sio
ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver
USB Serial support registered for GSM modem (1-port)
usbcore: registered new interface driver option
option: v0.7.2:USB Driver for GSM modems
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
mousedev: PS/2 mouse device common for all mice
samsung-ts s3c2440-ts: driver attached, registering input device
input: S3C24XX TouchScreen as /devices/virtual/input/input0
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
s3c-sdi s3c2440-sdi: mmc0 - using pio, sw SDIO IRQ
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
S3C24XX_UDA134X SoC Audio driver
UDA134X SoC Audio Codec
asoc: uda134x-hifi <-> s3c24xx-iis mapping ok
ALSA device list:
  #0: S3C24XX_UDA134X
Netfilter messages via NETLINK v0.30.
nf_conntrack version 0.5.0 (929 buckets, 3716 max)
ctnetlink v0.93: registering with nfnetlink.
xt_time: kernel timezone is -0000
ip_set: protocol 6
IPVS: Registered protocols (TCP, UDP, AH, ESP)
IPVS: Connection hash table configured (size=4096, memory=32Kbytes)
IPVS: Creating netns size=1008 id=0
IPVS: ipvs loaded.
IPVS: [rr] scheduler registered.
IPVS: [wrr] scheduler registered.
IPVS: [lc] scheduler registered.
IPVS: [wlc] scheduler registered.
IPVS: [lblc] scheduler registered.
IPVS: [lblcr] scheduler registered.
IPVS: [dh] scheduler registered.
IPVS: [sh] scheduler registered.
IPVS: [sed] scheduler registered.
IPVS: [nq] scheduler registered.
ip_tables: (C) 2000-2006 Netfilter Core Team
ipt_CLUSTERIP: ClusterIP Version 0.8 loaded successfully
arp_tables: (C) 2002 David S. Miller
TCP cubic registered
NET: Registered protocol family 17
lib80211: common routines for IEEE802.11 drivers
Registering the dns_resolver key type
s3c-rtc s3c2410-rtc: setting system clock to 2023-01-05 16:11:13 UTC (1672935073)
VFS: Mounted root (cramfs filesystem) readonly on device 31:3.
Freeing init memory: 156K
usb 1-1: new full speed USB device number 2 using s3c2410-ohci
usb 1-1: New USB device found, idVendor=05e3, idProduct=0606
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1: Product: USB Hub 2.0
hub 1-1:1.0: USB hub found
hub 1-1:1.0: 4 ports detected
UBI: attaching mtd8 to ubi8
UBI: physical eraseblock size:   131072 bytes (128 KiB)
UBI: logical eraseblock size:    129024 bytes
UBI: smallest flash I/O unit:    2048
UBI: sub-page size:              512
UBI: VID header offset:          512 (aligned 512)
UBI: data offset:                2048
UBI: max. sequence number:       12
UBI: attached mtd8 to ubi8
UBI: MTD device name:            "mtdblock7 apps 40MB"
UBI: MTD device size:            40 MiB
UBI: number of good PEBs:        320
UBI: number of bad PEBs:         0
UBI: number of corrupted PEBs:   0
UBI: max. allowed volumes:       128
UBI: wear-leveling threshold:    4096
UBI: number of internal volumes: 1
UBI: number of user volumes:     1
UBI: available PEBs:             33
UBI: total number of reserved PEBs: 287
UBI: number of PEBs reserved for bad PEB handling: 3
UBI: max/mean erase counter: 2/1
UBI: image sequence number:  301304821
UBI: background thread "ubi_bgt8d" started, PID 545
UBIFS: mounted UBI device 8, volume 0, name "apps"
UBIFS: file system size:   34965504 bytes (34146 KiB, 33 MiB, 271 LEBs)
UBIFS: journal size:       1806336 bytes (1764 KiB, 1 MiB, 14 LEBs)
UBIFS: media format:       w4/r0 (latest is w4/r0)
UBIFS: default compressor: lzo
UBIFS: reserved for root:  1651507 bytes (1612 KiB)
UBI: attaching mtd9 to ubi9
UBI: physical eraseblock size:   131072 bytes (128 KiB)
UBI: logical eraseblock size:    129024 bytes
UBI: smallest flash I/O unit:    2048
UBI: sub-page size:              512
UBI: VID header offset:          512 (aligned 512)
UBI: data offset:                2048
UBI: max. sequence number:       12
UBI: attached mtd9 to ubi9
UBI: MTD device name:            "mtdblock8 data 40MB"
UBI: MTD device size:            40 MiB
UBI: number of good PEBs:        319
UBI: number of bad PEBs:         1
UBI: number of corrupted PEBs:   0
UBI: max. allowed volumes:       128
UBI: wear-leveling threshold:    4096
UBI: number of internal volumes: 1
UBI: number of user volumes:     1
UBI: available PEBs:             32
UBI: total number of reserved PEBs: 287
UBI: number of PEBs reserved for bad PEB handling: 3
UBI: max/mean erase counter: 2/1
UBI: image sequence number:  661140379
UBI: background thread "ubi_bgt9d" started, PID 573
UBIFS: mounted UBI device 9, volume 0, name "data"
UBIFS: file system size:   34965504 bytes (34146 KiB, 33 MiB, 271 LEBs)
UBIFS: journal size:       1806336 bytes (1764 KiB, 1 MiB, 14 LEBs)
UBIFS: media format:       w4/r0 (latest is w4/r0)
UBIFS: default compressor: lzo
UBIFS: reserved for root:  1651507 bytes (1612 KiB)
dm9000 dm9000.0: eth0: link down
dm9000 dm9000.0: eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1


Copyright (C) 2012 GuoWenxue<[email protected]>
Default Password:  12345




fulinux login: root
Password: 
~ >: ls
apps     data     home     lib      media    proc     stat     usr
backup   dev      info     linuxrc  mnt      root     sys      var
bin      etc      init     logs     opt      sbin     tmp
~ >: touch xxx
touch: xxx: Read-only file system
~ >: 


*****************************************************************************************************************

作        者:fulinux

装载声明:点击打开链接

*****************************************************************************************************************

你可能感兴趣的:(cramfs,文件系统移植)