Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2295106
  • 博文数量: 218
  • 博客积分: 5767
  • 博客等级: 大校
  • 技术积分: 5883
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-01 14:44
文章存档

2012年(53)

2011年(131)

2009年(1)

2008年(33)

分类: LINUX

2011-08-03 09:01:39


转载
Tekkaman,原文地址:http://blog.chinaunix.net/space.php?uid=20543672&do=blog&id=94326
U-Boot1.3.1中JFFS2文件系统支持和U盘支持的使用备忘
 
在U-Boot可能早就有了对JFFS2和U盘的支持,但是由于我没有移植是注意到,就没有使用。在这次的移植中,我通过往网上的资料在开发板的配置文件中添加了对这两项的支持,并使用成功。在这里写下备忘,以备后用.
一、U-Boot对JFFS2文件系统的支持
我在include/configs/tekkaman2440.h文件中添加了:

#define CONFIG_CMD_JFFS2

/*JFFS2 Support */
#undef CONFIG_JFFS2_CMDLINE
#define CONFIG_JFFS2_NAND 1
#define CONFIG_JFFS2_DEV "nand0"
#define CONFIG_JFFS2_PART_SIZE 0x4c0000
#define CONFIG_JFFS2_PART_OFFSET 0x40000
/*JFFS2 Support */

解释:
CONFIG_CMD_JFFS2 :使能对JFFS2相关命令的支持;
CONFIG_JFFS2_CMDLINE  :若添加了此项定义,会加上对MTD的支持。但是要使用nand驱动,而不是nand_legacy驱动。对于我这次移植改动会很大,所以暂不用;
CONFIG_JFFS2_NAND :使能JFFS2文件系统在NAND FLASH上的支持;
CONFIG_JFFS2_DEV  :定义JFFS2文件系统所在的存储设备。若对于NOR FLASH 为"nor0";
CONFIG_JFFS2_PART_SIZE  :定义JFFS2文件系统分区大小。
CONFIG_JFFS2_PART_OFFSET :定义JFFS2文件系统分区所在存储设备的起始偏移地址;

U-Boot还支持多分区的JFFS2文件系统,我还未做实验。
注意:即使是JFFS2 in NAND Flash,也不要使用\doc\README.JFFS2_NAND中介绍的CONFIG_JFFS2_NAND_DEV、 CONFIG_JFFS2_NAND_OFF、CONFIG_JFFS2_NAND_SIZE 来配置,现在这些定义还未使用,是为以后的扩展设置的。一开始我也被骗了。

配置好以上定义后,编译,下载到板子。
以下是我使用一个JFFS2分区来存放内核,在启动时由U-Boot读取,并启动内核的操作过程:
首先,在HOST上将U-Boot处理过的内核做成JFFS2镜像,镜像大小为 0x4c0000 字节。(mkfs.jffs2的使用在我的《在嵌入式Linux系统中挂载 jffs2 根文件系统 》一文中有介绍)

[tekkamanninja@Tekkaman-Ninja mtd-utils.git]$ ./mkfs.jffs2 -r /home/tekkamanninja/working/nfs/boot -o boot.jffs2 -e 0x4000 --pad=0x4c0000 -s 0x200 -n


以下就是开发板的操作:

U-Boot 1.3.1 (Feb 18 2008 - 14:41:39)

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/boot.jffs2;nand erase 0x40000 0x4c0000
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/boot.jffs2'.
Load address: 0x30008000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ###############################################################
done
Bytes transferred = 4980736 (4c0000 hex)

NAND erase: device 0 offset 262144, size 4980736 ...
OK
[Tekkaman2440]#nand write.jffs2 0x30008000 0x40000 0x4c0000

NAND write: device 0 offset 262144, size 4980736 ...
 4980736 bytes written: OK
[Tekkaman2440]#ls
Scanning JFFS2 FS: . done.
 -rw-rw-r-- 1600504 Mon Feb 18 06:36:05 2008 zImage.img
[Tekkaman2440]#fsload zImage.img;bootm
### JFFS2 loading 'zImage.img' to 0x30008000
### JFFS2 load complete: 1600504 bytes loaded to 0x30008000
## Booting image at 30008000 ...
   Image Name: tekkamanninja
   Created: 2008-02-18 6:36:04 UTC
   Image Type: ARM Linux Kernel Image (uncompressed)
   Data Size: 1600440 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) #2 Mon Feb 18 14:35:35 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-0x00030000 : "U-Boot-1.3.1"
0x00030000-0x00040000 : "U-Boot-1.3.1 Parameter"
0x00040000-0x00500000 : "Linux2.6.24 Kernel(JFFS2)"
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-18 14:47:35 UTC (1203346055)
Empty flash at 0x0042eeb0 ends at 0x0042f000
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@~]#mount -t jffs2 /dev/mtdblock2 /mnt/jffs2/
[root@~]#ls -l /mnt/jffs2/
-rw-rw-r-- 1 501 501 1600504 Feb 18 06:36 zImage.img

二、U-Boot对U盘读取的支持。(似乎只支持普通U盘,不支持读卡器之类的USB存储设备)
我在include/configs/tekkaman2440.h文件中添加了:

#define CONFIG_CMD_USB
#define CONFIG_CMD_FAT


/* USB Support 080218 */
#define CONFIG_USB_OHCI
#define CONFIG_USB_STORAGE
#define CONFIG_USB_KEYBOARD
#define CONFIG_DOS_PARTITION
#define CFG_DEVICE_DEREGISTER
#define CONFIG_SUPPORT_VFAT
#define LITTLEENDIAN
/* USB Support 080218 */


解释:
CONFIG_CMD_USB :使能USB相关命令的支持
CONFIG_CMD_FAT :使能FAT文件系统相关命令的支持
CONFIG_USB_OHCI :使能USB_OHCI协议的支持
CONFIG_USB_STORAGE:使能USB存储设备的支持
CONFIG_DOS_PARTITION : 使能FAT文件系统分区的支持
CONFIG_SUPPORT_VFAT : 使能FAT32文件系统的支持
LITTLEENDIAN : 定义数据为小端模式
CFG_DEVICE_DEREGISTER和CONFIG_USB_KEYBOARD是对USB键盘的支持(本次未使用)

配置好以上定义后,编译,下载到板子。
以下是我使用U盘来存放内核,在启动时由U-Boot读取,并启动内核的操作过程:
首先将U-Boot处理过的内核存入U盘,以下就是开发板的操作:

U-Boot 1.3.1 (Feb 18 2008 - 16:04:40)

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]#
usb start
(Re)start USB...
USB: scanning bus for devices... 2 USB Device(s) found
       scanning bus for storage devices... 1 Storage Device(s) found
[Tekkaman2440]#fatls usb 0
.
  1600504 zimage.img
.
1 file(s), 0 dir(s)

[Tekkaman2440]#fatload usb 0 0x30008000 zimage.img
reading zimage.img
.
...........................................................................................................................................................
.
1600504 bytes read
[Tekkaman2440]#
bootm
## Booting image at 30008000 ...
   Image Name: tekkamanninja
   Created: 2008-02-18 8:32:06 UTC
   Image Type: ARM Linux Kernel Image (uncompressed)
   Data Size: 1600440 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) #2 Mon Feb 18 14:35:35 CST 2008
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
Machine: Tekkaman2440
Memory policy: ECC disabled, Data cache writeback
/*(以下略)*/
阅读(670) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~