We are using MT29F8G08ABABA in our DM365 based custom board. We are using NAND boot. RootFS is in UBIFS format,
Below is basic achitecture of the NAND.
I am using following commands to create ubifs,
$(UBIFS_PATH)/mkfs.ubifs -r $(TARGET_FS) -m 4096 -e 520192 -c 75 -o ubifs.img
$(UBIFS_PATH)/ubinize -o $(SYSTEM_CFG)_$(HARDWARE_CFG)_ubifs -m 4096 -p 512KiB $(HARDWARE_CFG)_ubinize.cfg
dm368_ubinize.cfg content is as follows,
[ubifs]
mode=ubi
image=ubifs.img
vol_id=0
vol_size=37888KiB
vol_type=dynamic
vol_name=rootfs
vol_flags=autoresize
Then i put this ubifs to NAND using following commands,
loady 0x82000000 ---> ubifs is loaded to RAM
nand scrub 0x1800000 0x2800000
nand erase 0x1800000 0x2800000
nand write 0x82000000 0x1800000 0x2800000
and when i boot the kernel there is error while detecting UBIFS from kernel,
Below is kernel log for the same,
[ 0.000000] Linux version 2.6[ 0.000000] Linux version 2.6.37_IPNC_DM368_5.1.0 (still-image@stillimage-VirtualBox) (gcc version 4.3.3 (GCC) ) #1 PREEMPT Sat Jan 4 11:09:29 IST 2014
[ 0.000000] CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
[ 0.000000] CPU: VIVT data cache, VIVT instruction cache
[ 0.000000] Machine: DaVinci DM36x IPNC
[ 0.000000] Memory policy: ECC disabled, Data cache writeback
[ 0.000000] DaVinci dm36x_rev1.2 variant 0x8
[ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 12192
[ 0.000000] Kernel command line: mem=48M console=ttyS0,115200n8 noinitrd ip=off rw ubi.mtd=3,4096 rootfstype=ubifs root=ubi0:rootfs cmemk.phys_start=0x83000000 cmemk.phys_end=0x88000000 cmemk.phys_start_1=0x00001000 cmemk.phys_end_1=0x00008000 cmemk.pools_1=1x28672 cmemk.allowOverlap=1 cmemk.useHeapIfPoolUnavailable=1 nohz=off highres=off clocksource=acpi_pm lpj=1077248
[ 0.000000] PID hash table entries: 256 (order: -2, 1024 bytes)
[ 0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
[ 0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
[ 0.000000] Memory: 48MB = 48MB total
[ 0.000000] Memory: 44772k/44772k available, 4380k reserved, 0K highmem
[ 0.000000] Virtual kernel memory layout:
[ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
[ 0.000000] fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
[ 0.000000] DMA : 0xff000000 - 0xffe00000 ( 14 MB)
[ 0.000000] vmalloc : 0xc3800000 - 0xfea00000 ( 946 MB)
[ 0.000000] lowmem : 0xc0000000 - 0xc3000000 ( 48 MB)
[ 0.000000] modules : 0xbf000000 - 0xc0000000 ( 16 MB)
[ 0.000000] .init : 0xc0008000 - 0xc002c000 ( 144 kB)
[ 0.000000] .text : 0xc002c000 - 0xc0390000 (3472 kB)
[ 0.000000] .data : 0xc0390000 - 0xc03b6600 ( 154 kB)
[ 0.000000] SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[ 0.000000] Preemptable hierarchical RCU implementation.
[ 0.000000] RCU-based detection of stalled CPUs is disabled.
[ 0.000000] Verbose stalled-CPUs detection is disabled.
[ 0.000000] NR_IRQS:245
[ 0.000000] Console: colour dummy device 80x30
[ 0.000407] Calibrating delay loop (skipped) preset value.. 215.44 BogoMIPS (lpj=1077248)
[ 0.000494] pid_max: default: 32768 minimum: 301
[ 0.000794] Security Framework initialized
[ 0.001001] Mount-cache hash table entries: 512
[ 0.002188] CPU: Testing write buffer coherency: ok
[ 0.004944] devtmpfs: initialized
[ 0.010877] DaVinci: 8 gpio irqs
[ 0.011931] NET: Registered protocol family 16
[ 0.066045] dm365_rmd_cs_rdk_150_wl_init
[ 0.066124] No entry for the specified index
[ 0.069960] No entry for the specified index
[ 0.192448] bio: create slab <bio-0> at 0
[ 0.199765] SCSI subsystem initialized
[ 0.206445] usbcore: registered new interface driver usbfs
[ 0.208607] usbcore: registered new interface driver hub
[ 0.210484] usbcore: registered new device driver usb
[ 0.215823] vpss vpss: dm365_vpss vpss probed
[ 0.215919] vpss vpss: dm365_vpss vpss probe success
[ 0.222681] Advanced Linux Sound Architecture Driver Version 1.0.23.
[ 0.228358] Switching to clocksource timer0_1
[ 0.356682] NET: Registered protocol family 2
[ 0.357150] IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.358399] TCP established hash table entries: 2048 (order: 2, 16384 bytes)
[ 0.358604] TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
[ 0.358736] TCP: Hash tables configured (established 2048 bind 2048)
[ 0.358784] TCP reno registered
[ 0.358845] UDP hash table entries: 256 (order: 0, 4096 bytes)
[ 0.358939] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[ 0.359791] NET: Registered protocol family 1
[ 0.466150] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[ 0.469156] JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
[ 0.474898] msgmni has been set to 87
[ 0.481735] io scheduler noop registered (default)
[ 0.484414] CSL: Module install successful, device major num = 254
[ 0.484478] CSL: Module version 0.10.00, built on Dec 13 2013 22:33:02
[ 0.484552] I2C: Module install successful, device major num = 253
[ 0.484609] DMA: Module install successful, device major num = 252
[ 0.484654] DRV: Module install successful
[ 0.484692] DRV: Module built on Dec 13 2013 22:33:04
[ 0.484733] DRV: EDMACC.QUEPRI = 00002777
[ 0.484769] DRV: SYSTEM.MSTPRI0 = 00440011
[ 0.484804] DRV: SYSTEM.MSTPRI1 = 00000444
[ 0.484839] DRV: ISP.BCR = 00000002
[ 0.484874] DRV: SYSTEM.MISC = 00000399
[ 0.484911] EDMAK module: built on Dec 13 2013 at 22:32:35
[ 0.484957] Reference Linux version 2.6.37
[ 0.484996] File /opt/workdir/OV9715_Ver5_0/dvsdk_ipnctools/linuxutils_2_26_02_05/packages/ti/sdo/linuxutils/edma/src/module/edmak.c
[ 0.487539] IRQK module: built on Dec 13 2013 at 22:32:33
[ 0.487612] Reference Linux version 2.6.37
[ 0.487653] File /opt/workdir/OV9715_Ver5_0/dvsdk_ipnctools/linuxutils_2_26_02_05/packages/ti/sdo/linuxutils/irq/src/module/irqk.c
[ 0.490558] irqk initialized
[ 0.490663] CMEMK module: built on Dec 13 2013 at 22:32:30
[ 0.490723] Reference Linux version 2.6.37
[ 0.490762] File /opt/workdir/OV9715_Ver5_0/dvsdk_ipnctools/linuxutils_2_26_02_05/packages/ti/sdo/linuxutils/cmem/src/module/cmemk.c
[ 0.498082] allocated heap buffer 0xc4000000 of size 0x5000000
[ 0.498145] heap fallback enabled - will try heap if pool buffer is not available
[ 0.498205] CMEM Range Overlaps Kernel Physical - allowing overlap
[ 0.498257] CMEM phys_start (0x1000) overlaps kernel (0x80000000 -> 0x83000000)
[ 0.498473] cmemk initialized
[ 0.498551] Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled
[ 0.611337] serial8250.0: ttyS0 at MMIO 0x1c20000 (irq = 40) is a 16550A
[ 1.137052] console [ttyS0] enabled
[ 1.211160] serial8250.0: ttyS1 at MMIO 0x1d06000 (irq = 41) is a 16550A
[ 1.254825] brd: module loaded
[ 1.272762] NAND device: Manufacturer ID: 0x2c, Chip ID: 0x38 (Micron )
[ 1.281908] Bad block table not found for chip 0
[ 1.287959] Bad block table not found for chip 0
[ 1.292787] Scanning device for bad blocks
[ 1.729485] Creating 7 MTD partitions on "davinci_nand.0":
[ 1.735177] 0x000000000000-0x000000c00000 : "bootloader"
[ 1.748031] 0x000000c00000-0x000001400000 : "params"
[ 1.760990] 0x000001400000-0x000001800000 : "kernel"
[ 1.773829] 0x000001800000-0x000004000000 : "filesystem1"
[ 1.787411] 0x000004000000-0x000004800000 : "data1"
[ 1.800510] 0x000004800000-0x000007000000 : "filesystem2"
[ 1.813667] 0x000007000000-0x000040000000 : "data2"
[ 1.828113] davinci_nand davinci_nand.0: controller rev. 2.3
[ 1.839036] UBI: attaching mtd3 to ubi0
[ 1.843400] UBI: physical eraseblock size: 262144 bytes (256 KiB)
[ 1.849714] UBI: logical eraseblock size: 256000 bytes
[ 1.855391] UBI: smallest flash I/O unit: 2048
[ 1.860292] UBI: sub-page size: 512
[ 1.864953] UBI: VID header offset: 4096 (aligned 4096)
[ 1.871094] UBI: data offset: 6144
[ 1.877230] UBI error: validate_ec_hdr: bad data offset 8192, expected 6144
[ 1.884383] UBI error: validate_ec_hdr: bad EC header
[ 1.889484] UBI error: ubi_io_read_ec_hdr: validation failed for PEB 0
[ 1.896907] UBI error: ubi_init: cannot attach mtd3
[ 1.905311] spi_davinci spi_davinci.0: Controller at 0xfec66000
[ 1.970163] davinci_mdio davinci_mdio.0: davinci mdio revision 1.4
[ 1.976404] davinci_mdio davinci_mdio.0: no live phy, scanning all
[ 1.983779] davinci_mdio: probe of davinci_mdio.0 failed with error -5
[ 1.993145] i2c /dev entries driver
[ 2.000461] Linux media interface: v0.10
[ 2.005482] Linux video capture interface: v2.00
[ 2.013867] vpbe-osd vpbe-osd: OSD sub device probe success
[ 2.021111] vpbe-venc vpbe-venc: VENC sub device probe success
[ 2.028379] vpbe-v4l2 vpbe-v4l2: vpbe v4l2 device registered
[ 2.034923] Setting default output to Composite
[ 2.039507] Setting default mode to ntsc
[ 2.043823] vpbe-v4l2 vpbe-v4l2: Trying to register VPBE display device.
[ 2.050741] vpbe-v4l2 vpbe-v4l2: layer=c2989a00,layer->video_dev=c2989ae8
[ 2.059118] vpbe-v4l2 vpbe-v4l2: Trying to register VPBE display device.
[ 2.066191] vpbe-v4l2 vpbe-v4l2: layer=c2989c00,layer->video_dev=c2989ce8
[ 2.076313] watchdog watchdog: heartbeat 60 sec
[ 2.090661] Error: Driver 'davinci-mcbsp' is already registered, aborting...
[ 2.102840] asoc: cq93vc-hifi <-> davinci-vcif mapping ok
[ 2.115028] ALSA device list:
[ 2.118092] #0: DaVinci DM365 EVM
[ 2.123853] nf_conntrack version 0.5.0 (699 buckets, 2796 max)
[ 2.133076] ip_tables: (C) 2000-2006 Netfilter Core Team
[ 2.138907] TCP cubic registered
[ 2.142616] NET: Registered protocol family 17
[ 2.163517] UBIFS error (pid 1): ubifs_mount: cannot open "ubi0:rootfs", error -19
[ 2.171615] VFS: Cannot open root device "ubi0:rootfs" or unknown-block(0,0)
[ 2.178710] Please append a correct "root=" boot option; here are the available partitions:
[ 2.187357] 1f00 12288 mtdblock0 (driver?)
[ 2.192678] 1f01 8192 mtdblock1 (driver?)
[ 2.197807] 1f02 4096 mtdblock2 (driver?)
[ 2.203056] 1f03 40960 mtdblock3 (driver?)
[ 2.208184] 1f04 8192 mtdblock4 (driver?)
[ 2.213414] 1f05 40960 mtdblock5 (driver?)
[ 2.218542] 1f06 933888 mtdblock6 (driver?)
[ 2.223740] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[ 2.232105] Backtrace:
[ 2.234600] Function entered at [<c0030504>] from [<c030ec74>]
[ 2.240524] r7:00008000 r6:c2813000 r5:c00263ec r4:c03b6e00
[ 2.246275] Function entered at [<c030ec5c>] from [<c030ecd4>]
[ 2.252188] Function entered at [<c030ec78>] from [<c0008fdc>]
[ 2.258049] r3:00000000 r2:c2824000 r1:c2825f78 r0:c0331f90
[ 2.263847] Function entered at [<c0008d78>] from [<c0009134>]
[ 2.269707] Function entered at [<c00090a0>] from [<c00084b4>]
[ 2.275614] r5:c002597c r4:c03b6618
[ 2.279248] Function entered at [<c00083a4>] from [<c0046a58>]
[ 2.285156] r5:c00083a4 r4:00000000
Now my doubt is why kernel is reporting physical eraseblock size as 256KiB? from architecture of NAND it looks to be 512KiB.
Any suggestions/pointer for the errors ?
Thank you in advance
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.
来源:https://stackoverflow.com/questions/20917921/unable-to-attach-ubi-to-mtd-partition