Knowing MTD

来源:互联网 发布:手机淘宝众筹入口 编辑:程序博客网 时间:2024/05/16 19:42

1. Character device & Block device

 

Character devices were things like keyboards or mice, that you cound read current data from, but could'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.

 

2. MTD (Memory Technology Device)

 

MTD is neither a character device nor a block device. They behave similar to block device, but have differences. For example, block devices don't distinguish between write and erase operations.

 

3. What are differences between flash devices and block drives

 

Note: SSD, MMC, eMMC, RS-MMC, SD, mini-SD, micro-SD, USB flash drive, CampactFlash, MemoryStick, MemoryStick Micro and other FTL devices are block devices, not raw flash devices.

 

The following table describes the difference between block devices and raw flashes.

 

Block deviceMTD deviceConsists of sectorsConsists of eraseblocksSectors are small (512, 1024 bytes)Eraseblocks are larger (typically 128KiB)Maintains 2 main operations: read sector and write sectorMaintains 3 main operations: read from eraseblock, write to eraseblock, and erase eraseblockBad sectors are re-mapped and hidden by hardware (at least in modern LBA hard drives); in case of FTL devices it is the responsibility of FTL to provide thisBad eraseblocks are not hidden and should be dealt with in softwareSectors are devoid of the wear-out property (in FTL devices it is the responsibility 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

 

4. Working MTD

 

In order to use one of conventional file systems owvere MTD device, you need a software layer which emulates a block device over the MTD device. These layers are after called Flash Translation Layers (FTLs).

 

There is an extremely simple FTL layer in Linux MTD subsystem - mtdblcok. It emulates blcok devices over MTD 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/mtdblockXX device nodes.

 

 

 

 

原创粉丝点击