^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) # SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) menuconfig MTD_UBI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) tristate "Enable UBI - Unsorted block images"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) select CRC32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) UBI is a software layer above MTD layer which admits use of LVM-like
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) logical volumes on top of MTD devices, hides some complexities of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) flash chips like wear and bad blocks and provides some other useful
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) capabilities. Please, consult the MTD web site for more details
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) (www.linux-mtd.infradead.org).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) if MTD_UBI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) config MTD_UBI_WL_THRESHOLD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) int "UBI wear-leveling threshold"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) default 4096
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) range 2 65536
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) This parameter defines the maximum difference between the highest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) erase counter value and the lowest erase counter value of eraseblocks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) of UBI devices. When this threshold is exceeded, UBI starts performing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) wear leveling by means of moving data from eraseblock with low erase
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) counter to eraseblocks with high erase counter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) The default value should be OK for SLC NAND flashes, NOR flashes and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) other flashes which have eraseblock life-cycle 100000 or more.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) However, in case of MLC NAND flashes which typically have eraseblock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) life-cycle less than 10000, the threshold should be lessened (e.g.,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) to 128 or 256, although it does not have to be power of 2).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) config MTD_UBI_BEB_LIMIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) int "Maximum expected bad eraseblock count per 1024 eraseblocks"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) default 20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) range 0 768
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) This option specifies the maximum bad physical eraseblocks UBI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) expects on the MTD device (per 1024 eraseblocks). If the underlying
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) flash does not admit of bad eraseblocks (e.g. NOR flash), this value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) is ignored.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) NAND datasheets often specify the minimum and maximum NVM (Number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) Valid Blocks) for the flashes' endurance lifetime. The maximum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) expected bad eraseblocks per 1024 eraseblocks then can be calculated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) as "1024 * (1 - MinNVB / MaxNVB)", which gives 20 for most NANDs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) (MaxNVB is basically the total count of eraseblocks on the chip).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) To put it differently, if this value is 20, UBI will try to reserve
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) about 1.9% of physical eraseblocks for bad blocks handling. And that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) will be 1.9% of eraseblocks on the entire NAND chip, not just the MTD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) partition UBI attaches. This means that if you have, say, a NAND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) flash chip admits maximum 40 bad eraseblocks, and it is split on two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) MTD partitions of the same size, UBI will reserve 40 eraseblocks when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) attaching a partition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) This option can be overridden by the "mtd=" UBI module parameter or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) by the "attach" ioctl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) Leave the default value if unsure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) config MTD_UBI_FASTMAP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) bool "UBI Fastmap (Experimental feature)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) default n
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) Important: this feature is experimental so far and the on-flash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) format for fastmap may change in the next kernel versions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) Fastmap is a mechanism which allows attaching an UBI device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) in nearly constant time. Instead of scanning the whole MTD device it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) only has to locate a checkpoint (called fastmap) on the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) The on-flash fastmap contains all information needed to attach
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) the device. Using fastmap makes only sense on large devices where
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) attaching by scanning takes long. UBI will not automatically install
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) a fastmap on old images, but you can set the UBI module parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) fm_autoconvert to 1 if you want so. Please note that fastmap-enabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) images are still usable with UBI implementations without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) fastmap support. On typical flash devices the whole fastmap fits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) into one PEB. UBI will reserve PEBs to hold two fastmaps.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) If in doubt, say "N".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) config MTD_UBI_GLUEBI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) tristate "MTD devices emulation driver (gluebi)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) This option enables gluebi - an additional driver which emulates MTD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) devices on top of UBI volumes: for each UBI volumes an MTD device is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) created, and all I/O to this MTD device is redirected to the UBI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) volume. This is handy to make MTD-oriented software (like JFFS2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) work on top of UBI. Do not enable this unless you use legacy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) software.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) config MTD_UBI_BLOCK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) bool "Read-only block devices on top of UBI volumes"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) default n
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) depends on BLOCK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) This option enables read-only UBI block devices support. UBI block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) devices will be layered on top of UBI volumes, which means that the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) UBI driver will transparently handle things like bad eraseblocks and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) bit-flips. You can put any block-oriented file system on top of UBI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) volumes in read-only mode (e.g., ext4), but it is probably most
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) practical for read-only file systems, like squashfs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) When selected, this feature will be built in the UBI driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) If in doubt, say "N".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) endif # MTD_UBI