18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_cimenuconfig MTD_UBI 38c2ecf20Sopenharmony_ci tristate "Enable UBI - Unsorted block images" 48c2ecf20Sopenharmony_ci select CRC32 58c2ecf20Sopenharmony_ci help 68c2ecf20Sopenharmony_ci UBI is a software layer above MTD layer which admits use of LVM-like 78c2ecf20Sopenharmony_ci logical volumes on top of MTD devices, hides some complexities of 88c2ecf20Sopenharmony_ci flash chips like wear and bad blocks and provides some other useful 98c2ecf20Sopenharmony_ci capabilities. Please, consult the MTD web site for more details 108c2ecf20Sopenharmony_ci (www.linux-mtd.infradead.org). 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ciif MTD_UBI 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ciconfig MTD_UBI_WL_THRESHOLD 158c2ecf20Sopenharmony_ci int "UBI wear-leveling threshold" 168c2ecf20Sopenharmony_ci default 4096 178c2ecf20Sopenharmony_ci range 2 65536 188c2ecf20Sopenharmony_ci help 198c2ecf20Sopenharmony_ci This parameter defines the maximum difference between the highest 208c2ecf20Sopenharmony_ci erase counter value and the lowest erase counter value of eraseblocks 218c2ecf20Sopenharmony_ci of UBI devices. When this threshold is exceeded, UBI starts performing 228c2ecf20Sopenharmony_ci wear leveling by means of moving data from eraseblock with low erase 238c2ecf20Sopenharmony_ci counter to eraseblocks with high erase counter. 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci The default value should be OK for SLC NAND flashes, NOR flashes and 268c2ecf20Sopenharmony_ci other flashes which have eraseblock life-cycle 100000 or more. 278c2ecf20Sopenharmony_ci However, in case of MLC NAND flashes which typically have eraseblock 288c2ecf20Sopenharmony_ci life-cycle less than 10000, the threshold should be lessened (e.g., 298c2ecf20Sopenharmony_ci to 128 or 256, although it does not have to be power of 2). 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ciconfig MTD_UBI_BEB_LIMIT 328c2ecf20Sopenharmony_ci int "Maximum expected bad eraseblock count per 1024 eraseblocks" 338c2ecf20Sopenharmony_ci default 20 348c2ecf20Sopenharmony_ci range 0 768 358c2ecf20Sopenharmony_ci help 368c2ecf20Sopenharmony_ci This option specifies the maximum bad physical eraseblocks UBI 378c2ecf20Sopenharmony_ci expects on the MTD device (per 1024 eraseblocks). If the underlying 388c2ecf20Sopenharmony_ci flash does not admit of bad eraseblocks (e.g. NOR flash), this value 398c2ecf20Sopenharmony_ci is ignored. 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci NAND datasheets often specify the minimum and maximum NVM (Number of 428c2ecf20Sopenharmony_ci Valid Blocks) for the flashes' endurance lifetime. The maximum 438c2ecf20Sopenharmony_ci expected bad eraseblocks per 1024 eraseblocks then can be calculated 448c2ecf20Sopenharmony_ci as "1024 * (1 - MinNVB / MaxNVB)", which gives 20 for most NANDs 458c2ecf20Sopenharmony_ci (MaxNVB is basically the total count of eraseblocks on the chip). 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci To put it differently, if this value is 20, UBI will try to reserve 488c2ecf20Sopenharmony_ci about 1.9% of physical eraseblocks for bad blocks handling. And that 498c2ecf20Sopenharmony_ci will be 1.9% of eraseblocks on the entire NAND chip, not just the MTD 508c2ecf20Sopenharmony_ci partition UBI attaches. This means that if you have, say, a NAND 518c2ecf20Sopenharmony_ci flash chip admits maximum 40 bad eraseblocks, and it is split on two 528c2ecf20Sopenharmony_ci MTD partitions of the same size, UBI will reserve 40 eraseblocks when 538c2ecf20Sopenharmony_ci attaching a partition. 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci This option can be overridden by the "mtd=" UBI module parameter or 568c2ecf20Sopenharmony_ci by the "attach" ioctl. 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci Leave the default value if unsure. 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ciconfig MTD_UBI_FASTMAP 618c2ecf20Sopenharmony_ci bool "UBI Fastmap (Experimental feature)" 628c2ecf20Sopenharmony_ci default n 638c2ecf20Sopenharmony_ci help 648c2ecf20Sopenharmony_ci Important: this feature is experimental so far and the on-flash 658c2ecf20Sopenharmony_ci format for fastmap may change in the next kernel versions 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci Fastmap is a mechanism which allows attaching an UBI device 688c2ecf20Sopenharmony_ci in nearly constant time. Instead of scanning the whole MTD device it 698c2ecf20Sopenharmony_ci only has to locate a checkpoint (called fastmap) on the device. 708c2ecf20Sopenharmony_ci The on-flash fastmap contains all information needed to attach 718c2ecf20Sopenharmony_ci the device. Using fastmap makes only sense on large devices where 728c2ecf20Sopenharmony_ci attaching by scanning takes long. UBI will not automatically install 738c2ecf20Sopenharmony_ci a fastmap on old images, but you can set the UBI module parameter 748c2ecf20Sopenharmony_ci fm_autoconvert to 1 if you want so. Please note that fastmap-enabled 758c2ecf20Sopenharmony_ci images are still usable with UBI implementations without 768c2ecf20Sopenharmony_ci fastmap support. On typical flash devices the whole fastmap fits 778c2ecf20Sopenharmony_ci into one PEB. UBI will reserve PEBs to hold two fastmaps. 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci If in doubt, say "N". 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ciconfig MTD_UBI_GLUEBI 828c2ecf20Sopenharmony_ci tristate "MTD devices emulation driver (gluebi)" 838c2ecf20Sopenharmony_ci help 848c2ecf20Sopenharmony_ci This option enables gluebi - an additional driver which emulates MTD 858c2ecf20Sopenharmony_ci devices on top of UBI volumes: for each UBI volumes an MTD device is 868c2ecf20Sopenharmony_ci created, and all I/O to this MTD device is redirected to the UBI 878c2ecf20Sopenharmony_ci volume. This is handy to make MTD-oriented software (like JFFS2) 888c2ecf20Sopenharmony_ci work on top of UBI. Do not enable this unless you use legacy 898c2ecf20Sopenharmony_ci software. 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ciconfig MTD_UBI_BLOCK 928c2ecf20Sopenharmony_ci bool "Read-only block devices on top of UBI volumes" 938c2ecf20Sopenharmony_ci default n 948c2ecf20Sopenharmony_ci depends on BLOCK 958c2ecf20Sopenharmony_ci help 968c2ecf20Sopenharmony_ci This option enables read-only UBI block devices support. UBI block 978c2ecf20Sopenharmony_ci devices will be layered on top of UBI volumes, which means that the 988c2ecf20Sopenharmony_ci UBI driver will transparently handle things like bad eraseblocks and 998c2ecf20Sopenharmony_ci bit-flips. You can put any block-oriented file system on top of UBI 1008c2ecf20Sopenharmony_ci volumes in read-only mode (e.g., ext4), but it is probably most 1018c2ecf20Sopenharmony_ci practical for read-only file systems, like squashfs. 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci When selected, this feature will be built in the UBI driver. 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci If in doubt, say "N". 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ciendif # MTD_UBI 108