嵌入式linu下常见的文件系统_第1页
嵌入式linu下常见的文件系统_第2页
嵌入式linu下常见的文件系统_第3页
已阅读5页,还剩8页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、嵌入式linux 下常见的文件系统RomFS:ROMRAMlinux 中常用来作 根文件系统 RamFS:VFSRAMJFFS/JFFS2FlashROMRAMlinux根文件系统RamFS:利用 VFS 自身构造而形成的内存文件系RAMJFFS/JFFS2:FlashYaffs:Nand Flash为内核和内核模块将信息发送给进程供给一种机制,可以查看系统模块装载的信息devFS:设备文件系统LinuxExt2fs4 TB1012 字符可选择规律块快速符号链接Ext2flash512 byte、1 KB、2KB没有供给对基于扇区的擦除写操作的良好治理假设在一个扇区中擦除单个字节,必需将整个扇

2、区复制到RAM,然后擦除,再重写入在消灭电源故障时,Ext2fs 是不能防止崩溃的文件系统不支持损耗平衡,缩短了 flash 的寿命jffs/jffs2日志文件系统供给了更好的崩溃、掉电安全保护jffs2flashExt2文件系统接近满时,JFFS2速度垃圾收集NandyaffsNand flashjffsjffs2Nand flashRAMRAM128MBNand4MB来维护节点启动的时候需要扫描日志节点,不适合大容量Nand flashFATmtd接口更,适合与 yaffsmtdmtdMakefile 中MTD_OLD = -DCONFIG_YAFFS_USE_OLD_MTD参考文档: y

3、affs-rootfs-howtoyaffs HYPERLINK “ :/ aleph1.co.uk/armlinux/projects/yaffs“ :/ aleph1.co.uk/armlinux/projects/yaffsyaffscat /proc/yaffsyaffs统的相关信息mount -t yaffs /dev/mtdblock/0 /mnt/yaffsLinux 文件系统JFFS 全称为:TheJournallingFlashFileSystem日志闪存文件系统最初由瑞典的 AxisCommunications 开发,RedHat 的 DavidWoodhouse 对它进展

4、JFFSExt2由于有以下这些优点而在无盘嵌入式设备中越来越受欢送:JFFS 在扇区级别上执行闪存擦除写读操作要比 Ext2 文件系统好。JFFSExt2时,Ext2 文件系统将整个扇区复制到内存DRAM中,在内存中合并数据,并写回整个扇区。这意味着为了更改单个字,必需对整个扇区64 KB执行读DRAM入 DRAM 后就擦除了闪存扇区。JFFS 附加文件而不是重写整个扇区,并且具有崩溃掉电安全保护这一功能。的,所以它的整个设计供给了更好的闪存治理。FLASHJFFS操作系统。uclinux 2.4jffs关键词:uclinux vfs jffs担保。更具体的状况请参阅 GNU 通用公共许可证(

5、GPLGNU 自由文档协议(GFDL)。写信给:TheFreeSoftwareFoundation,Inc.,675MassAve,Cambridge,MA02139,USA欢送各位指出文档中的错误与疑问一、flash 读写的特别性件系统建立在 flashflashflash 上的文件flash不能对单个字节进展擦除,最小的擦写单位是一个block,有时候也称为一个扇区。典型的一个block 的大小是 64k。不同的flash 会有不同,具体参考flashf的位置操作,sectorram,ramsector。jffs二、jffs 体系构造介绍1、存储构造jffs_raw_inode示 inod

6、erawinode,raw inode2、文件组成在文件系统 mount 到 flash 设备上的时候,会扫描flash,从而依据flash 上的raw inodejffs_filenode list。下面的图显示了一个文件的组成一个文件是由假设干个 jffs_node 组成,每一个 jffs_node 是依据 flash 上得jffs_raw_inodejffs_filenode 创立的早晚,就是说 version_head 指向的是一个最老的 node,也就意味着垃圾回收的时候最该回收的就是这个最老的 node。 .其nM3、操作一个的 jffs_node 的诞生,同时要写一个相映的raw

7、 inode 到 flash 上,这样jffs_nodeflashraw inodedirty。下面举一个例子可能会更清楚一些。 jffs_node的时候lseek( fd, 10, SEEK_SET );write( fd, buf,40 );第一个和最终一个 node 被截短了,其次个 node 完全被数据替换,该 node 会从链表上摘下来,flashdirty。假设做如下写操作的时候lseek( fd, 23, SEEK_SET );write( fd, buf,5 );此时,其次个nodenode,同时产生一个的node,range元素变成五个。Linux2.6YAFFSv1.0,2

8、022-6-6一、YAFFS 文件系统简介 Another Flash File SystemJFFS/JFFS2Flash 设计的嵌入式文件系统。与 JFFS 相比,它削减了一些功能,因此速度更快、占用内存更少。YAFFSJFFSYAFFS仅仅借鉴了日志系统的思想,不供给日志机能,所以稳定性不如JAFFS, 但是资源占用少。YAFFSJFFSNANDYAFFS适合存储容量大的系统。YAFFS 还带有NANDAPI,MTD+YAFFSMTD Memory Technology Devices,内存技术设备设计分开。二、YAFFS 文件系统的移植yaffs HYPERLINK “ :/ alep

9、h1.co.uk/armlinux/projects/下载“ :/ aleph1.co.uk/armlinux/projects/下载yaffsyaffs_ecc.c,yaffs_fileem.c,yaffs_fs.c,yaffs_guts.c,yaffs_mtdif.c,yaffs_ramem.c。表一 Yaffs文件名 功能yaffs_ecc.c ECC校验算法 flashyaffs_fs.c 文件系统接口函数yaffs_guts.c Yaffsyaffs_mtdif.c NANDyaffs_ramem.c RamdiskYAFFS,所以需要自己建立YAFFSYAFFS制到该名目下面。#m

10、kdir fs/yaffs#cp *.c(yaffs source code) fs/yaffsfs/Kconfigyaffs :source “fs/yaffs/Kconfig“修改fs/makefile,添加如下内容: obj-$(CONFIG_YAFFS_FS)+=yaffs/makefileKconfigMakefile 内容为:yaffs-objs := yaffs_fs.o yaffs_guts.o yaffs_mtdif.o yaffs_ecc.oEXTRA_CFLAGS += $(YAFFS_CONFIGS) -DCONFIG_KERNEL_2_6Kconfig# YAFFS

11、file system configurations#config YAFFS_FStristate “Yet Another Flash Filing System(YAFFS) file system support“helpYAFFS, for Yet Another Flash Filing System, is a filing systemoptimised for NAND Flash chips.To compile the YAFFS file system support as a module, choose M here:the module will be calle

12、d yaffs.If unsure, say N.Further information on YAFFS is available at HYPERLINK “ :/ aleph1.co.uk/yaffs/“ .config YAFFS_MTD_ENABLEDbool “NAND mtd support“ depends on YAFFS_FShelpThis adds the yaffs file system support for working with a NAND mtd.If unsure, say Y.config YAFFS_RAM_ENABLEDbool “yaffsra

13、m file system support“depends on YAFFS_FShelpThis adds the yaffsram file system support. Nice for testing on x86,but uses 2MB of RAM. Don”t enable for NAND-based targets.If unsure, say N.comment “WARNING: mtd and/or yaffsram support should be selected“depends on YAFFS_FS & !YAFFS_MTD_ENABLED & !YAFF

14、S_RAM_ENABLEDconfig YAFFS_USE_OLD_MTDbool “Old mtd support“ depends on YAFFS_FS & 0helpEnable this to use the old MTD stuff that did not have yaffs support.You can use this to get around compilation problems, but the best thingtodoisto upgradeyourMTDsupport. Youwillget betterspeed.If unsure, say N.

15、configYAFFS_USE_NANDECCbool “Use ECC functions of the generic MTD-NAND driver“depends on YAFFS_FSdefault yhelpThis enables the ECC functions of the generic MTD-NAND driver.This will not work if you are using the old mtd.NB Use NAND ECC does not work at present with yaffsram.If unsure, say Y.config Y

16、AFFS_ECC_WRONG_ORDERbool “Use the same ecc byte order as Steven Hill”s nand_ecc.c“depends on YAFFS_FShelpThis makes yaffs_ecc.c use the same ecc byte order as Steven Hill”s nand_ecc.c. If not set, then you get thesame ecc byte order as SmartMedia.If unsure, say N.config YAFFS_USE_GENERIC_RWbool “Use

17、 Linux file caching layer“default ydepends on YAFFS_FShelpUse generic_read/generic_write for reading/writing files. Thisenables the use of the Linux file caching layer.If you disable this, then caching is disabled and file read/writeis direct.If unsure, say Y.config YAFFS_USE_HEADER_FILE_SIZEbool “U

18、se object header size“ depends on YAFFS_FShelpWhen the flash is scanned, two file sizes are constructed:The size taken from the object header for the file.The size figured out by scanning the data chunks.If this option is enabled, then the object header size is used,otherwise the scanned size is use

19、d.If unsure, say N.config YAFFS_DISABLE_CHUNK_ERASED_CHECKbool “Turn off debug chunk erase check“depends on YAFFS_FSdefault yhelpEnabling this turns off the test that chunks are erased in flash before writing to them. This is safe, since the write verificationwill fail. Suggest enabling the test (ie

20、. say N)during development to help debug things.If unsure, say Y.#config YAFFS_DISABLE_WRITE_VERIFY# bool “Disable write verify (DANGEROUS)“# depends on YAFFS_FS & EXPERIMENTAL# help#I am severely reluctant to provide this config. Disabling the#verification is not a good thing to do since NAND write

21、s can#fail silently. Disabling the write verification will cause your#teeth to rot, rats to eat your corn and give you split ends.#You have been warned. ie. Don”t uncomment the following line.#If unsure, say N.#config YAFFS_SHORT_NAMES_IN_RAMbool “Cache short names in RAM“depends on YAFFS_FSdefault

22、yhelpIf this config is set, then short names are stored with the yaffs_Object. This costs an extra 16 bytes of RAM per object,but makes look-ups faster.If unsure, say Y.在/arch/arm/mach-s3c2410/mach-smdk2410.csmdk_default_nand_partnandstruct mtd_partition smdk_default_nand_part = 0=.name=“vivi“,.size

23、=0 x00020220,.offset=0 x00000000,1=.name=“param“,.size=0 x00010000,.offset=0 x00020220,2=.name=“kernel“,.size=0 x00100000,.offset=0 x00030000,3 = .name=“root“,.size=0 x01900000,.offset=0 x00130000,4 = .name=“user“,.size=0 x025d0000,.offset=0 x01a30000,;注:此分区要结合 vivi 里面的分区来进展设置。配置内核时选中 MTD 支持:Memory

24、Technology Devices (MTD) - Memory Technology Device (MTD) supportMTD partitioning support- User Modules And Translation Layers Direct char device access to MTD devices Caching block device access to MTD devicesNAND Flash Device Drivers - NAND Device Support NAND Flash support for S3C2410 SoCS3C2410

25、NAND driver debug7YAFFS File systems - Miscellaneousfilesystems Yet Another Flash Filing System(YAFFS) file system supportNAND mtd supportUse ECC functions of the generic MTD-NAND driverUse Linux file caching layerTurn off debug chunk erase checkCache short names in RAMflash三、Yaffs内核启动之后,在启动信息里面可以看到

26、如下内容:ID:0 xec,ChipID:0 x76(SamsungNAND64MiB3,3V8-bit)Scanning device for bad blocksCreating 5 MTD partitions on “NAND 64MiB 3,3V 8-bit“:0 x00000000-0 x00020220 : “vivi“0 x00020220-0 x00030000 : “param“0 x00030000-0 x00130000 : “kernel“0 x00130000-0 x01a30000 : “root“0 x01a30000-0 x04100000 : “user“假

27、设在内核里面添加了procprocyaffs # cat proc/filesystemsnodevsysfsnodevrootfsnodevbdevnodevprocnodevsockfsnodevpipefs nodevnodevtmpfsnodeveventpollfsnodevdevptsnodevvfatnodevdevfsnodevyaffsnodevrpc_pipefsdev # ls dev/mtddrwxr-xr-x1-alrootroot0Jan 100:00 .drwxr-xr-x1rootroot0Jan 100:00 .crw-rw-rw-1rootroot90,0J

28、an100:000cr-r-r-1rootroot90,1Jan100:000rocrw-rw-rw-1rootroot90,2Jan100:001cr-r-r-1rootroot90,3Jan100:001rocrw-rw-rw-1rootroot90,4Jan100:002cr-r-r-1rootroot90,5Jan100:002rocrw-rw-rw-1rootroot90,6Jan100:003cr-r-r-1rootroot90,7Jan100:003rocrw-rw-rw-1rootroot90,8Jan100:004cr-r-r-1rootroot90,9Jan100:004r

29、o # ls dev/mtdblock/ -aldrwxr-xr-x1rootroot0Jan 100:00 .drwxr-xr-x1rootroot0Jan 100:00 .brw-1rootroot31,0Jan100:000brw-1rootroot31,1Jan100:001brw-1rootroot31,2Jan100:002brw-1rootroot31,3Jan100:003brw-1rootroot31,4Jan100:004mount、umountmount #mkdir /mnt/flash0 #mkdir /mnt/flash1Mountblockdevice 设备 #m

30、ount t yaffs /dev/mtdblock/3 /mnt/flash0 #mount t yaffs /dev/mtdblock/4 /mnt/flash1 #cp 1.txt /mnt/flash0 #cp 2.txt /mnt/flash1查看 mount 上的名目,可以看到该名目下有刚刚拷贝的文件,将其 umount 后, mountumount, flash # mount t yaffs /dev/mtdblock/3 /mnt/flash0 #cp (your rootfs) /mnt/flash0 #umount /mnt/flash0重启动,转变启动参数:param

31、set linux_cmd_line “noinitrd root=/dev/mtdblock3 init=/linuxrcconsole=ttySAC0“重启动,开发板就可以从 flash 启动根文件系统了。注:这里你得在内核中添加 devfs 文件系统的支持,否则内核无法找到/dev/mtdblock/3flashJFFS2NOR flashJFFS2NAND flash 的 JFFS2 HYPERLINK “ :/ /“ 上面下载。但是在我的测试过程中,在 nand flash 上挂接的 JFFS2 文件系统很不稳定,经常CRCCRCNAND flashJFFS2YAFFSNAND fl

32、ash HYPERLINK “ :/ aleph1.co.uk/yaffs/index.html“ :/ aleph1.co.uk/yaffs/index.html上下载。在测试过程中稳定性能JFFS2mountJFFS2JFFS2 mount2m1s。下面分别介绍在 uclinuxJFFS2YAFFS1、JFFS2到 HYPERLINK “ :/ /“ :/ 上面下载最的MTDJFFS2MTDMTDJFFS2nandflash动了。假设不想把 JFFS2 作为根文件系统的话,还需要修改 MTD_BLOCK_MAJOR 。驱动可以参考里面的例子,最简洁的就是参考 spia.c。写驱动主要工作是定义 flash 分区构造、定义 flash 读写地址、写把握 flash的*_hwcontrolnand flash 改完之后再配置MemoryTechnologyDevices(MTD)下CONFIG_MTD=Y CONFIG_MTD_DEBUG=Y CONFIG_MTD_DEBUG_VERBOSE=3 CONFIG_MTD_PARTITIONS=Y CONFIG_MTD_CHAR=Y CONFIG_MTD_BL

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论