I am working on an embedded Linux system (kernel-5.24) and the development host is running WSL2 in Windows.
There is a NAND FLASH of 128MB in the embedded system (PEB is 128KiB, page size is 4096 bytes, and there are 1024 PEBs). Now I want to create a UBIFS volume on the MTD2 which is the last MTD partition, whose size is 0x7700000 (119MiB) with ubinize.
Here is ubinize.cfg I am using,
[ubifs] mode=ubi image=ubifs.rootfs vol_id=0 vol_size=119MiB vol_type=dynamic vol_alignment=1 vol_name=rootfs vol_flags=autoresize
The command is as follows,
ubinize -m 2048 -p 128KiB -s 512 -O 2048 ./ubinize.cfg -v -o ubi.img
Then I deployed the generated ubi.img, the system booted up with error as follows,
[ 2.138286] ubi0: attaching mtd2 [ 2.315180] ubi0: scanning is finished [ 2.322753] ubi0 error: vtbl_check: too large reserved_pebs 983, good PEBs 952 [ 2.330258] ubi0 error: vtbl_check: volume table check failed: record 0, error 9 [ 2.337904] Volume table record 0 dump: [ 2.341878] reserved_pebs 983 [ 2.345202] alignment 1 [ 2.348354] data_pad 0 [ 2.351515] vol_type 1 [ 2.354663] upd_marker 0 [ 2.357812] name_len 6 [ 2.360976] name rootfs [ 2.364572] crc 0xd6e9ec58 [ 2.368727] ubi0 error: ubi_attach_mtd_dev: failed to attach mtd2, error -22 [ 2.376054] UBI error: cannot attach mtd2
So by checking the internet, to make use of the whole MTD2 partition, I changed the ubinize.cfg without setting
vol_size as follows,
[ubifs] mode=ubi image=system.ubifs vol_id=0 vol_type=dynamic vol_alignment=1 vol_name=rootfs vol_flags=autoresize
With this, kernel can bootup and rootfs can be mounted correctly, and
ubinfo showed followings,
# ubinfo -a UBI version: 1 Count of UBI devices: 1 UBI control device major/minor: 10:63 Present UBI devices: ubi0 ubi0 Volumes count: 1 Logical eraseblock size: 126976 bytes, 124.0 KiB Total amount of logical eraseblocks: 952 (120881152 bytes, 115.2 MiB) Amount of available logical eraseblocks: 0 (0 bytes) Maximum count of volumes 128 Count of bad physical eraseblocks: 0 Count of reserved physical eraseblocks: 20 Current maximum erase counter value: 2 Minimum input/output unit size: 2048 bytes Character device major/minor: 248:0 Present volumes: 0 Volume ID: 0 (on ubi0) Type: dynamic Alignment: 1 Size: 928 LEBs (117833728 bytes, 112.3 MiB) State: OK Name: rootfs Character device major/minor: 248:1
I have following questions:
There are totally 952 LEBs, but
ubinfo -a shows 928 LEBs are used. Does it use up the whole partition of size of 119MB?
What is the maximum number of LEBs can be used in this configuration?
How to plan the UBIFS size in this NAND configuration (1024 PEBs, maximum bad block is 20, and considering wear leveling)?