MTD bitflip threshold
The MTD bitflip threshold is the per-ECC-step corrected-bit warning threshold used by Linux kernel MTD read APIs to report -EUCLEAN on otherwise successful ECC-enabled reads.
The comparison uses the largest driver-reported correction count in any one ECC step, not their sum. In a hypothetical read with threshold 4, two steps reporting 3 and 3 corrections stay below it; a step reporting 4 reaches it. These examples illustrate the API rule, not a measurement or a recommended setting. [1]
A 0 status can therefore accompany corrected errors. The normal ECC-enabled path compares the nonnegative driver result against the threshold; it preserves negative errors first and bypasses the comparison if ecc_strength is zero. With threshold zero, even a reported correction count of zero can yield -EUCLEAN. [2]
Do not infer the effective threshold from ECC strength alone. In Linux v6.16, raw NAND initialization supplies ceil(3 * ecc_strength / 4) when a threshold has not already been set. This is a software default for that path, not a universal NAND failure limit. [3]
UBI translates MTD's -EUCLEAN to UBI_IO_BITFLIPS. Its logical-eraseblock read path can request scrubbing, whereas -EBADMSG has distinct handling. A warning is not an automatic permanent bad-block mark, and changing its threshold does not strengthen the ECC code. [4] [5]
This threshold rule is not the MEMREAD ioctl's complete return contract. Its accumulated corrected-bit statistics can trigger EUCLEAN below the threshold. Record the API as well as the status. [6]
Relations
- related
- Memory Technology Device (MTD), Error-correcting code, Bad block management, Unsorted Block Images (UBI), NAND page
Citations
- Linux v6.16, MTD sysfs ABI: ECC step, strength and bitflip threshold
- Linux v6.16, mtd_read and mtd_read_oob: status conversion
- Linux v6.16, nand_scan_tail: raw-NAND bitflip threshold initialization
- Linux v6.16, ubi_io_read: corrected and uncorrectable read results
- Linux v6.16, ubi_eba_read_leb: volume-specific CRC and scrubbing paths
- Linux v6.16, mtdchar_read and mtdchar_read_ioctl: userspace read results
Sources & caveats
- Source review scoped to Linux v6.16. No raw-flash device, fault injection or endurance experiment was run.