162306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0-only
262306a36Sopenharmony_cimenuconfig MTD_UBI
362306a36Sopenharmony_ci	tristate "Enable UBI - Unsorted block images"
462306a36Sopenharmony_ci	select CRC32
562306a36Sopenharmony_ci	help
662306a36Sopenharmony_ci	  UBI is a software layer above MTD layer which admits use of LVM-like
762306a36Sopenharmony_ci	  logical volumes on top of MTD devices, hides some complexities of
862306a36Sopenharmony_ci	  flash chips like wear and bad blocks and provides some other useful
962306a36Sopenharmony_ci	  capabilities. Please, consult the MTD web site for more details
1062306a36Sopenharmony_ci	  (www.linux-mtd.infradead.org).
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ciif MTD_UBI
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ciconfig MTD_UBI_WL_THRESHOLD
1562306a36Sopenharmony_ci	int "UBI wear-leveling threshold"
1662306a36Sopenharmony_ci	default 4096
1762306a36Sopenharmony_ci	range 2 65536
1862306a36Sopenharmony_ci	help
1962306a36Sopenharmony_ci	  This parameter defines the maximum difference between the highest
2062306a36Sopenharmony_ci	  erase counter value and the lowest erase counter value of eraseblocks
2162306a36Sopenharmony_ci	  of UBI devices. When this threshold is exceeded, UBI starts performing
2262306a36Sopenharmony_ci	  wear leveling by means of moving data from eraseblock with low erase
2362306a36Sopenharmony_ci	  counter to eraseblocks with high erase counter.
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci	  The default value should be OK for SLC NAND flashes, NOR flashes and
2662306a36Sopenharmony_ci	  other flashes which have eraseblock life-cycle 100000 or more.
2762306a36Sopenharmony_ci	  However, in case of MLC NAND flashes which typically have eraseblock
2862306a36Sopenharmony_ci	  life-cycle less than 10000, the threshold should be lessened (e.g.,
2962306a36Sopenharmony_ci	  to 128 or 256, although it does not have to be power of 2).
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ciconfig MTD_UBI_BEB_LIMIT
3262306a36Sopenharmony_ci	int "Maximum expected bad eraseblock count per 1024 eraseblocks"
3362306a36Sopenharmony_ci	default 20
3462306a36Sopenharmony_ci	range 0 768
3562306a36Sopenharmony_ci	help
3662306a36Sopenharmony_ci	  This option specifies the maximum bad physical eraseblocks UBI
3762306a36Sopenharmony_ci	  expects on the MTD device (per 1024 eraseblocks). If the underlying
3862306a36Sopenharmony_ci	  flash does not admit of bad eraseblocks (e.g. NOR flash), this value
3962306a36Sopenharmony_ci	  is ignored.
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci	  NAND datasheets often specify the minimum and maximum NVM (Number of
4262306a36Sopenharmony_ci	  Valid Blocks) for the flashes' endurance lifetime. The maximum
4362306a36Sopenharmony_ci	  expected bad eraseblocks per 1024 eraseblocks then can be calculated
4462306a36Sopenharmony_ci	  as "1024 * (1 - MinNVB / MaxNVB)", which gives 20 for most NANDs
4562306a36Sopenharmony_ci	  (MaxNVB is basically the total count of eraseblocks on the chip).
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci	  To put it differently, if this value is 20, UBI will try to reserve
4862306a36Sopenharmony_ci	  about 1.9% of physical eraseblocks for bad blocks handling. And that
4962306a36Sopenharmony_ci	  will be 1.9% of eraseblocks on the entire NAND chip, not just the MTD
5062306a36Sopenharmony_ci	  partition UBI attaches. This means that if you have, say, a NAND
5162306a36Sopenharmony_ci	  flash chip admits maximum 40 bad eraseblocks, and it is split on two
5262306a36Sopenharmony_ci	  MTD partitions of the same size, UBI will reserve 40 eraseblocks when
5362306a36Sopenharmony_ci	  attaching a partition.
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci	  This option can be overridden by the "mtd=" UBI module parameter or
5662306a36Sopenharmony_ci	  by the "attach" ioctl.
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci	  Leave the default value if unsure.
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ciconfig MTD_UBI_FASTMAP
6162306a36Sopenharmony_ci	bool "UBI Fastmap (Experimental feature)"
6262306a36Sopenharmony_ci	default n
6362306a36Sopenharmony_ci	help
6462306a36Sopenharmony_ci	   Important: this feature is experimental so far and the on-flash
6562306a36Sopenharmony_ci	   format for fastmap may change in the next kernel versions
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci	   Fastmap is a mechanism which allows attaching an UBI device
6862306a36Sopenharmony_ci	   in nearly constant time. Instead of scanning the whole MTD device it
6962306a36Sopenharmony_ci	   only has to locate a checkpoint (called fastmap) on the device.
7062306a36Sopenharmony_ci	   The on-flash fastmap contains all information needed to attach
7162306a36Sopenharmony_ci	   the device. Using fastmap makes only sense on large devices where
7262306a36Sopenharmony_ci	   attaching by scanning takes long. UBI will not automatically install
7362306a36Sopenharmony_ci	   a fastmap on old images, but you can set the UBI module parameter
7462306a36Sopenharmony_ci	   fm_autoconvert to 1 if you want so. Please note that fastmap-enabled
7562306a36Sopenharmony_ci	   images are still usable with UBI implementations without
7662306a36Sopenharmony_ci	   fastmap support. On typical flash devices the whole fastmap fits
7762306a36Sopenharmony_ci	   into one PEB. UBI will reserve PEBs to hold two fastmaps.
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci	   If in doubt, say "N".
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ciconfig MTD_UBI_GLUEBI
8262306a36Sopenharmony_ci	tristate "MTD devices emulation driver (gluebi)"
8362306a36Sopenharmony_ci	help
8462306a36Sopenharmony_ci	   This option enables gluebi - an additional driver which emulates MTD
8562306a36Sopenharmony_ci	   devices on top of UBI volumes: for each UBI volumes an MTD device is
8662306a36Sopenharmony_ci	   created, and all I/O to this MTD device is redirected to the UBI
8762306a36Sopenharmony_ci	   volume. This is handy to make MTD-oriented software (like JFFS2)
8862306a36Sopenharmony_ci	   work on top of UBI. Do not enable this unless you use legacy
8962306a36Sopenharmony_ci	   software.
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ciconfig MTD_UBI_BLOCK
9262306a36Sopenharmony_ci	bool "Read-only block devices on top of UBI volumes"
9362306a36Sopenharmony_ci	default n
9462306a36Sopenharmony_ci	depends on BLOCK
9562306a36Sopenharmony_ci	help
9662306a36Sopenharmony_ci	   This option enables read-only UBI block devices support. UBI block
9762306a36Sopenharmony_ci	   devices will be layered on top of UBI volumes, which means that the
9862306a36Sopenharmony_ci	   UBI driver will transparently handle things like bad eraseblocks and
9962306a36Sopenharmony_ci	   bit-flips. You can put any block-oriented file system on top of UBI
10062306a36Sopenharmony_ci	   volumes in read-only mode (e.g., ext4), but it is probably most
10162306a36Sopenharmony_ci	   practical for read-only file systems, like squashfs.
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_ci	   When selected, this feature will be built in the UBI driver.
10462306a36Sopenharmony_ci
10562306a36Sopenharmony_ci	   If in doubt, say "N".
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ciendif # MTD_UBI
108