Memory Technology Device (MTD)
MTD is the Linux kernel subsystem providing a common interface to flash and other memory devices, including raw NAND and NOR.
MTD covers flash, RAM and similar devices. It exposes device operations rather than supplying a filesystem or an SSD-style translation layer. [1]
Raw NAND has eraseblock, write and OOB geometry. An ECC step need not span a whole NAND page or match a host sector. [2] [3]
UBI adds logical eraseblocks, wear management and volumes; UBIFS supplies files above UBI. [4]
In the ECC-enabled mtd_read_oob path, nonnegative correction counts become 0 or -EUCLEAN according to bitflip_threshold; negative results are preserved. -EBADMSG does not count bad blocks or mean every returned byte is wrong. [5] [6]
Userspace differs: ordinary read() on /dev/mtdX can deliver bytes despite -EUCLEAN or -EBADMSG below it. MEMREAD returns per-request ECC statistics and can report EUCLEAN for below-threshold corrections. An ioctl error is -1 with errno set, not the kernel's negative errno value. [7]
MEMREAD distinguishes corrected_bitflips (total), max_bitflips (one ECC step) and uncorrectable_errors. MTD_OPS_RAW bypasses error correction. The request mode overrides the descriptor mode set by MTDFILEMODE; raw mode is not a stronger integrity check. [8]
Inspect returned len and ooblen with errno and ECC statistics. MEMREAD can copy data and still report an ECC error; returned bytes alone do not certify integrity. [7]
Relations
- related
- NAND flash, NOR flash, Unsorted Block Images (UBI), UBI File System (UBIFS), MTD bitflip threshold, Bad block management, Error-correcting code
Citations
- Linux v6.16, Memory Technology Device configuration
- Linux v6.16, MTD interface: device geometry and operations
- Linux v6.16, MTD sysfs ABI: ECC step, strength and bitflip threshold
- Linux kernel, UBIFS Authentication Support: MTD, UBI and UBIFS
- Linux v6.16, mtd_read and mtd_read_oob: status conversion
- Linux v6.16, ubi_io_read: corrected and uncorrectable read results
- Linux v6.16, mtdchar_read and mtdchar_read_ioctl: userspace read results
- Linux v6.16, MEMREAD request and per-operation ECC statistics
Sources & caveats
- Source review scoped to Linux v6.16. No raw-flash device, fault injection or endurance experiment was run.