Sunday 3 February 2019

Difference between Raw Flashes (MTD) and Block Devices


Block Devices Examples 

  • SSD
  • MMC
  • eMMC
  • RS-MMC
  • SD
  • Mini/micro-SD
  • USB flash drive
  • CompactFlash
  • MemoryStick
  • MemoryStick Micro
  • Hard drives 

Ext2, ext3, XFS, JFS, FAT and conventional file systems work with block devices. 

Features
  • Block devices consists of sectors.
  • Sectors are small (512, 1024 bytes)
  • Maintains operations: read sector and write sector
  • Bad sectors are re-mapped and hidden by hardware (at least in modern LBA hard drives);
  • Sectors are devoid of the wear-out property 
 Bad sector re-mapping and wear out in case of FTL devices, it is the responsibility of FTL to provide this.

MTD (Memory Technology Devices) Examples ( Used for Raw Flash devices)

  • NAND
  • OneNAND
  • NOR 
  • AG-AND
  • ECC'd NOR
  • CFI (Common Flash Interface)  
  • Bare NAND Flashes with SW/HW
  • Legacy FTL/NFTL "translation layers"
  •  M-Systems' DiskOnChip 2000 and Millennium chips
  •  PCMCIA flashes (pcmciamtd driver).

 MTD subsystem provides an abstraction layer for raw flash devices to make use of the same API when working with different flash types and technologies. Also to use conventional files systems over an MTD device, we need a software layer known as Flash Translation Layers (FTLs) which enables them to behave like a block devices.

MTD Characteristics & Features

  • Consists of eraseblocks
  • Eraseblocks are larger (typically 128KiB)
  • Maintains : read from eraseblockwrite to eraseblock, and erase eraseblock
  • Bad eraseblocks are not hidden and should be dealt with in software.
  • Eraseblocks wear-out and become bad and unusable after about 103 (for MLC NAND) - 105 (NOR, SLC NAND) erase cycles

MTD Subsystem interfaces:

  • MTD character devices - These character devices provide I/O access to the raw flash and referred as /dev/mtd0, /dev/mtd1 etc. They support a number of ioctl calls for getting information about MTD devices.
  • The sysfs interface - It provides full information about each MTD device in the system and is easily extensible.
  • The /proc/mtd proc file system- This is a legacy interface and provides general MTD information. 
During Electronic Product Design & Development it is essential that hardware is designed in a way that it uses proper flash types & accordingly partitions are made.

For More information :http://www.linux-mtd.infradead.org