免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1668 | 回复: 0
打印 上一主题 下一主题

mtd设备简介 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-11-18 19:55 |只看该作者 |倒序浏览

http://www.linux-mtd.infradead.org/faq/general.html
   
    Unix traditionally only knew block devices and character devices.
Character devices were things like keyboards or mice, that you could
read current data from, but couldn't be seek-ed and didn't have a size.
Block devices had a fixed size and could be seek-ed. They also happened
to be organized in blocks of multiple bytes, usually 512.
    Flash doesn't match the description of either block or character devices.
They behave similar to block device, but have differences. For example,
block devices don't distinguish between write and erase operations.
Therefore, a special device type to match flash characteristics was created:
MTD.
What are the differences between flash devices and block drives?
The following table describes the differences between block devices and
raw flashes. Note, SSD, MMC, eMMC, RS-MMC, SD, mini-SD, micro-SD, USB flash
drive, CompactFlash, MemoryStick, MemoryStick Micro, and other FTL devices
are block devices, not raw flash devices. Of course, hard drives are
also block devices.
       
                Block drives
                MTD device
       
       
                Consists of sectors
                Consists of eraseblocks
       
       
                Sectors are small (512, 1024 bytes)
                Eraseblocks are larger (typically 128KiB)
       
       
               
                        Maintains 2 main operations: read sectorwrite sector and
                       
               
               
                        Maintains 3 main operations: read from eraseblock,
                        write to eraseblock, and erase eraseblock
               
       
       
               
                        Bad sectors are re-mapped and hidden by hardware (at
                        least in modern LBA hard drives); in case of FTL
                        devices it is the resposibility of FTL to provide this
               
               
                        Bad eraseblocks are not hidden and should be dealt with
                        in software
               
       
       
                Sectors are devoid of the wear-out property (in FTL devices
                        it is the resposibility of FTL to provide this)
               
                        Eraseblocks wear-out and become bad and unusable after
                        about 103 (for MLC NAND) - 105
                        (NOR, SLC NAND) erase cycles
               
       
So as one sees flashes (MTD devices) are somewhat more difficult to work
with.
    Please, do not be confused by USB stick, MMC, SD, CompactFlash and other popular
removable devices. Although they are also called "flash", they are not MTD devices.
They are out of MTD subsystem's scope.
   
    In order to use one of conventional file systems over an MTD device, you need a
software layer which emulates a block device over the MTD device. These layers
are often called Flash Translation Layers (FTLs).
    There is an extremely simple FTL layer in Linux MTD subsystem -
mtdblock. It emulates block devices over MTD devices. There is
also an mtdblock_ro module which emulates read-only block devices.
When you load this module, it creates a block device for each MTD device in the
system. The block devices are then accessible via /dev/mtdblockX
device nodes.

        MTD 驱动程序是专门针对嵌入式Linux的一种驱动程序,相对于常规块设备驱动程序(比如PC中的IDE硬盘)而言,[color="#ff0000"]MTD驱动程序能更好的支持和管理闪存设备,因为它本身就是专为闪存设备而设计的。MTD设备是指不同于传统字符设备和块设备的flash存储设备,使得上层的文件系统像访问传统的字符或块设备一样访问flash,为上层软件系统提供一个同一的接口。
    具体地讲,基于MTD的FLASH驱动,承上可以很好地支持cramfs,jffs2和yaffs等
文件系统,启下也能对FLASH的擦除,读写,FLASH坏块以及损耗平衡进行很好的管理。所谓损耗平衡,是指对NAND的擦写不能总是集中在某一个或某
几个block中,这是由NAND芯片有限的擦写次数的特性决定的。
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/84729/showart_1422628.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP