119fe7f1aSKevin CernekeeWhat: /sys/class/mtd/ 219fe7f1aSKevin CernekeeDate: April 2009 319fe7f1aSKevin CernekeeKernelVersion: 2.6.29 419fe7f1aSKevin CernekeeContact: linux-mtd@lists.infradead.org 519fe7f1aSKevin CernekeeDescription: 619fe7f1aSKevin Cernekee The mtd/ class subdirectory belongs to the MTD subsystem 719fe7f1aSKevin Cernekee (MTD core). 819fe7f1aSKevin Cernekee 919fe7f1aSKevin CernekeeWhat: /sys/class/mtd/mtdX/ 1019fe7f1aSKevin CernekeeDate: April 2009 1119fe7f1aSKevin CernekeeKernelVersion: 2.6.29 1219fe7f1aSKevin CernekeeContact: linux-mtd@lists.infradead.org 1319fe7f1aSKevin CernekeeDescription: 1419fe7f1aSKevin Cernekee The /sys/class/mtd/mtd{0,1,2,3,...} directories correspond 1519fe7f1aSKevin Cernekee to each /dev/mtdX character device. These may represent 1619fe7f1aSKevin Cernekee physical/simulated flash devices, partitions on a flash 17*880113efSArtem Bityutskiy device, or concatenated flash devices. 1819fe7f1aSKevin Cernekee 1919fe7f1aSKevin CernekeeWhat: /sys/class/mtd/mtdXro/ 2019fe7f1aSKevin CernekeeDate: April 2009 2119fe7f1aSKevin CernekeeKernelVersion: 2.6.29 2219fe7f1aSKevin CernekeeContact: linux-mtd@lists.infradead.org 2319fe7f1aSKevin CernekeeDescription: 2419fe7f1aSKevin Cernekee These directories provide the corresponding read-only device 25*880113efSArtem Bityutskiy nodes for /sys/class/mtd/mtdX/ . 2619fe7f1aSKevin Cernekee 2719fe7f1aSKevin CernekeeWhat: /sys/class/mtd/mtdX/dev 2819fe7f1aSKevin CernekeeDate: April 2009 2919fe7f1aSKevin CernekeeKernelVersion: 2.6.29 3019fe7f1aSKevin CernekeeContact: linux-mtd@lists.infradead.org 3119fe7f1aSKevin CernekeeDescription: 3219fe7f1aSKevin Cernekee Major and minor numbers of the character device corresponding 3319fe7f1aSKevin Cernekee to this MTD device (in <major>:<minor> format). This is the 3419fe7f1aSKevin Cernekee read-write device so <minor> will be even. 3519fe7f1aSKevin Cernekee 3619fe7f1aSKevin CernekeeWhat: /sys/class/mtd/mtdXro/dev 3719fe7f1aSKevin CernekeeDate: April 2009 3819fe7f1aSKevin CernekeeKernelVersion: 2.6.29 3919fe7f1aSKevin CernekeeContact: linux-mtd@lists.infradead.org 4019fe7f1aSKevin CernekeeDescription: 4119fe7f1aSKevin Cernekee Major and minor numbers of the character device corresponding 4219fe7f1aSKevin Cernekee to the read-only variant of thie MTD device (in 4319fe7f1aSKevin Cernekee <major>:<minor> format). In this case <minor> will be odd. 4419fe7f1aSKevin Cernekee 4519fe7f1aSKevin CernekeeWhat: /sys/class/mtd/mtdX/erasesize 4619fe7f1aSKevin CernekeeDate: April 2009 4719fe7f1aSKevin CernekeeKernelVersion: 2.6.29 4819fe7f1aSKevin CernekeeContact: linux-mtd@lists.infradead.org 4919fe7f1aSKevin CernekeeDescription: 5019fe7f1aSKevin Cernekee "Major" erase size for the device. If numeraseregions is 5119fe7f1aSKevin Cernekee zero, this is the eraseblock size for the entire device. 5219fe7f1aSKevin Cernekee Otherwise, the MEMGETREGIONCOUNT/MEMGETREGIONINFO ioctls 5319fe7f1aSKevin Cernekee can be used to determine the actual eraseblock layout. 5419fe7f1aSKevin Cernekee 5519fe7f1aSKevin CernekeeWhat: /sys/class/mtd/mtdX/flags 5619fe7f1aSKevin CernekeeDate: April 2009 5719fe7f1aSKevin CernekeeKernelVersion: 2.6.29 5819fe7f1aSKevin CernekeeContact: linux-mtd@lists.infradead.org 5919fe7f1aSKevin CernekeeDescription: 6019fe7f1aSKevin Cernekee A hexadecimal value representing the device flags, ORed 6119fe7f1aSKevin Cernekee together: 6219fe7f1aSKevin Cernekee 6319fe7f1aSKevin Cernekee 0x0400: MTD_WRITEABLE - device is writable 6419fe7f1aSKevin Cernekee 0x0800: MTD_BIT_WRITEABLE - single bits can be flipped 6519fe7f1aSKevin Cernekee 0x1000: MTD_NO_ERASE - no erase necessary 6619fe7f1aSKevin Cernekee 0x2000: MTD_POWERUP_LOCK - always locked after reset 6719fe7f1aSKevin Cernekee 6819fe7f1aSKevin CernekeeWhat: /sys/class/mtd/mtdX/name 6919fe7f1aSKevin CernekeeDate: April 2009 7019fe7f1aSKevin CernekeeKernelVersion: 2.6.29 7119fe7f1aSKevin CernekeeContact: linux-mtd@lists.infradead.org 7219fe7f1aSKevin CernekeeDescription: 7319fe7f1aSKevin Cernekee A human-readable ASCII name for the device or partition. 7419fe7f1aSKevin Cernekee This will match the name in /proc/mtd . 7519fe7f1aSKevin Cernekee 7619fe7f1aSKevin CernekeeWhat: /sys/class/mtd/mtdX/numeraseregions 7719fe7f1aSKevin CernekeeDate: April 2009 7819fe7f1aSKevin CernekeeKernelVersion: 2.6.29 7919fe7f1aSKevin CernekeeContact: linux-mtd@lists.infradead.org 8019fe7f1aSKevin CernekeeDescription: 8119fe7f1aSKevin Cernekee For devices that have variable eraseblock sizes, this 8219fe7f1aSKevin Cernekee provides the total number of erase regions. Otherwise, 8319fe7f1aSKevin Cernekee it will read back as zero. 8419fe7f1aSKevin Cernekee 8519fe7f1aSKevin CernekeeWhat: /sys/class/mtd/mtdX/oobsize 8619fe7f1aSKevin CernekeeDate: April 2009 8719fe7f1aSKevin CernekeeKernelVersion: 2.6.29 8819fe7f1aSKevin CernekeeContact: linux-mtd@lists.infradead.org 8919fe7f1aSKevin CernekeeDescription: 9019fe7f1aSKevin Cernekee Number of OOB bytes per page. 9119fe7f1aSKevin Cernekee 9219fe7f1aSKevin CernekeeWhat: /sys/class/mtd/mtdX/size 9319fe7f1aSKevin CernekeeDate: April 2009 9419fe7f1aSKevin CernekeeKernelVersion: 2.6.29 9519fe7f1aSKevin CernekeeContact: linux-mtd@lists.infradead.org 9619fe7f1aSKevin CernekeeDescription: 9719fe7f1aSKevin Cernekee Total size of the device/partition, in bytes. 9819fe7f1aSKevin Cernekee 9919fe7f1aSKevin CernekeeWhat: /sys/class/mtd/mtdX/type 10019fe7f1aSKevin CernekeeDate: April 2009 10119fe7f1aSKevin CernekeeKernelVersion: 2.6.29 10219fe7f1aSKevin CernekeeContact: linux-mtd@lists.infradead.org 10319fe7f1aSKevin CernekeeDescription: 10419fe7f1aSKevin Cernekee One of the following ASCII strings, representing the device 10519fe7f1aSKevin Cernekee type: 10619fe7f1aSKevin Cernekee 10719fe7f1aSKevin Cernekee absent, ram, rom, nor, nand, dataflash, ubi, unknown 10819fe7f1aSKevin Cernekee 10919fe7f1aSKevin CernekeeWhat: /sys/class/mtd/mtdX/writesize 11019fe7f1aSKevin CernekeeDate: April 2009 11119fe7f1aSKevin CernekeeKernelVersion: 2.6.29 11219fe7f1aSKevin CernekeeContact: linux-mtd@lists.infradead.org 11319fe7f1aSKevin CernekeeDescription: 11419fe7f1aSKevin Cernekee Minimal writable flash unit size. This will always be 11519fe7f1aSKevin Cernekee a positive integer. 11619fe7f1aSKevin Cernekee 11719fe7f1aSKevin Cernekee In the case of NOR flash it is 1 (even though individual 11819fe7f1aSKevin Cernekee bits can be cleared). 11919fe7f1aSKevin Cernekee 12019fe7f1aSKevin Cernekee In the case of NAND flash it is one NAND page (or a 12119fe7f1aSKevin Cernekee half page, or a quarter page). 12219fe7f1aSKevin Cernekee 12319fe7f1aSKevin Cernekee In the case of ECC NOR, it is the ECC block size. 124a9b672e8SMike Dunn 125a9b672e8SMike DunnWhat: /sys/class/mtd/mtdX/ecc_strength 126a9b672e8SMike DunnDate: April 2012 127a9b672e8SMike DunnKernelVersion: 3.4 128a9b672e8SMike DunnContact: linux-mtd@lists.infradead.org 129a9b672e8SMike DunnDescription: 130a9b672e8SMike Dunn Maximum number of bit errors that the device is capable of 131a9b672e8SMike Dunn correcting within each region covering an ecc step. This will 132a9b672e8SMike Dunn always be a non-negative integer. Note that some devices will 133a9b672e8SMike Dunn have multiple ecc steps within each writesize region. 134a9b672e8SMike Dunn 135a9b672e8SMike Dunn In the case of devices lacking any ECC capability, it is 0. 136d062d4edSMike Dunn 137d062d4edSMike DunnWhat: /sys/class/mtd/mtdX/bitflip_threshold 138d062d4edSMike DunnDate: April 2012 139d062d4edSMike DunnKernelVersion: 3.4 140d062d4edSMike DunnContact: linux-mtd@lists.infradead.org 141d062d4edSMike DunnDescription: 142d062d4edSMike Dunn This allows the user to examine and adjust the criteria by which 143021796b8SMike Dunn mtd returns -EUCLEAN from mtd_read() and mtd_read_oob(). If the 144021796b8SMike Dunn maximum number of bit errors that were corrected on any single 145021796b8SMike Dunn region comprising an ecc step (as reported by the driver) equals 146021796b8SMike Dunn or exceeds this value, -EUCLEAN is returned. Otherwise, absent 147021796b8SMike Dunn an error, 0 is returned. Higher layers (e.g., UBI) use this 148021796b8SMike Dunn return code as an indication that an erase block may be 149021796b8SMike Dunn degrading and should be scrutinized as a candidate for being 150021796b8SMike Dunn marked as bad. 151d062d4edSMike Dunn 152d062d4edSMike Dunn The initial value may be specified by the flash device driver. 153d062d4edSMike Dunn If not, then the default value is ecc_strength. 154d062d4edSMike Dunn 155d062d4edSMike Dunn The introduction of this feature brings a subtle change to the 156d062d4edSMike Dunn meaning of the -EUCLEAN return code. Previously, it was 157d062d4edSMike Dunn interpreted to mean simply "one or more bit errors were 158d062d4edSMike Dunn corrected". Its new interpretation can be phrased as "a 159d062d4edSMike Dunn dangerously high number of bit errors were corrected on one or 160d062d4edSMike Dunn more regions comprising an ecc step". The precise definition of 161d062d4edSMike Dunn "dangerously high" can be adjusted by the user with 162d062d4edSMike Dunn bitflip_threshold. Users are discouraged from doing this, 163d062d4edSMike Dunn however, unless they know what they are doing and have intimate 164d062d4edSMike Dunn knowledge of the properties of their device. Broadly speaking, 165d062d4edSMike Dunn bitflip_threshold should be low enough to detect genuine erase 166d062d4edSMike Dunn block degradation, but high enough to avoid the consequences of 167d062d4edSMike Dunn a persistent return value of -EUCLEAN on devices where sticky 168d062d4edSMike Dunn bitflips occur. Note that if bitflip_threshold exceeds 169021796b8SMike Dunn ecc_strength, -EUCLEAN is never returned by the read operations. 170edbc4540SMike Dunn Conversely, if bitflip_threshold is zero, -EUCLEAN is always 171edbc4540SMike Dunn returned, absent a hard error. 172d062d4edSMike Dunn 173d062d4edSMike Dunn This is generally applicable only to NAND flash devices with ECC 174edbc4540SMike Dunn capability. It is ignored on devices lacking ECC capability; 175edbc4540SMike Dunn i.e., devices for which ecc_strength is zero. 176