unable to attach ubi to mtd partition

送分小仙女□ 提交于 2019-12-05 11:42:38

PEB size (physical erase block) I think needs configuring as part of the ubinize config file, try adding something like this to the file:

[flash]
peb=0x20000
min_io_size=0x800
compress_type=zlib

(I've got a PEB size of 128KiB, so you'll need to change accordingly). Also you might find UBIFS MTD pages useful - there's a question about bad VID header offset. Hope this helps.

As i have mentioned in above answer, I was not able to create a file or folder because filesystem size and partitions size was same.
So i increased the partition size to 128MB(nand_partition in kernel) and i recreated the UBIFS. I flashed the new kernel and UBIFS in NAND. And it started working, now i am able to create folder and/or file anywhere in the root file system.

I used below commands to create ubifs,

$(UBIFS_PATH)/mkfs.ubifs -r  $(TARGET_FS) -m 2048 -e 258048 -c 506 -o ubifs.img
$(UBIFS_PATH)/ubinize -o $(SYSTEM_CFG)_$(HARDWARE_CFG)_ubifs -m 2048 -p 256KiB -O 2048  $(HARDWARE_CFG)_ubinize.cfg

content of ubinize.cfg is as follows,

[ubifs]
peb=0x40000
min_io_size=0x800
compress_type=zlib
mode=ubi
image=ubifs.img
vol_id=0
vol_size=124MiB
vol_type=dynamic
vol_name=rootfs
vol_flags=autoresize

Some calculations which will help understand

For 256Kib and pagesize 2048

Symbol  Meaning     Value for 128MB fs
SP  PEB Size    256KiB
SL  LEB Size    256kib - 2* 2kiB = 252Kib
P   Total number of PEBs on the MTD device  128MiB / 256KiB = 512
B   Number of PEBs reserved for bad PEB handling    1% of P = 5
O   The overhead related to storing EC and VID headers in bytes, i.e. O = SP - SL   4KiB 

UBI Overhead = (B + 4) * SP + O * (P - B - 4) 
      = (5 + 4) * 256Kib + 4 KiB * (512 - 5 - 4)
      = 2304Kib + 2012Kib
      = 4316 KiB 
      = 16.859375 PEBs (round to 17)
512 - 17 = 498 peb = 498*256kiB PEBS = 127488KiB availble for user data
we have to use -c <X> where x = 127488Kib / 252kib = 505.9 = 506

Hope this helps someone facing the similar issue.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!