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