Linux kernel 无法将ubi附加到mtd分区

Linux kernel 无法将ubi附加到mtd分区,linux-kernel,flash-memory,ubifs,Linux Kernel,Flash Memory,Ubifs,我们在基于DM365的定制板中使用MT29F8G08ABABA。 我们正在使用NAND引导。 RootFS是UBIFS格式的 下面是NAND的基本结构。 我使用以下命令创建UBIF $(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

我们在基于DM365的定制板中使用MT29F8G08ABABA。 我们正在使用NAND引导。 RootFS是UBIFS格式的

下面是NAND的基本结构。

我使用以下命令创建UBIF

$(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内容如下:

[ubifs]
mode=ubi
image=ubifs.img
vol_id=0
vol_size=37888KiB
vol_type=dynamic
vol_name=rootfs
vol_flags=autoresize
[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
然后我使用以下命令将ubifs设置为NAND

loady 0x82000000 ---> ubifs is loaded to RAM
nand scrub 0x1800000 0x2800000
nand erase 0x1800000 0x2800000
nand write 0x82000000 0x1800000 0x2800000
当我启动内核时,从内核检测UBIF时出错

下面是相同的内核日志

[    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
[0.000000]Linux版本2.6[0.000000]Linux版本2.6.37\u IPNC\u DM368\u 5.1.0(仍然是-image@stillimage-VirtualBox)(gcc版本4.3.3(gcc))#1抢占Sat 2014年1月4日11:09:29
[0.000000]CPU:ARM926EJ-S[41069265]版本5(ARMv5TEJ),cr=00053177
[0.000000]CPU:VIVT数据缓存,VIVT指令缓存
[0.000000]机器:达芬奇DM36x IPNC
[0.000000]内存策略:禁用ECC,数据缓存写回
[0.000000]达芬奇dm36x_rev1.2变型0x8
[0.000000]按区域顺序构建了1个区域列表,移动分组在上。总页数:12192
[    0.000000]内核命令行:mem=48M console=ttys0115200n8 noinitrd ip=off rw ubi.mtd=34096 rootfstype=ubifs root=ubi0:rootfs cmemk.phys_start=0x83000000 cmemk.phys_end=0x88000000 cmemk.phys_start=0x00001000 cmemk.phys_end=0x00008000 cmemk.pool_1=1x28672; 8672 cmemk.allowOverlap=1 cmemk.useheapiool=1 nohz=clockoff highres=acu-pmlpj=1077248
[0.000000]PID哈希表条目:256(顺序:-2,1024字节)
[0.000000]Dentry缓存哈希表条目:8192(顺序:332768字节)
[0.000000]索引节点缓存哈希表条目:4096(顺序:216384字节)
[0.000000]内存:48MB=总共48MB
[0.000000]内存:44772k/44772k可用,4380k保留,0K高内存
[0.000000]虚拟内核内存布局:
[0.000000]向量:0xffff0000-0xffff1000(4KB)
[0.000000]固定映射:0xfff00000-0xfffe0000(896KB)
[0.000000]DMA:0xff000000-0xFF00000(14MB)
[0.000000]vmalloc:0xc3800000-0xfea00000(946MB)
[0.000000]低内存:0xc0000000-0xc3000000(48MB)
[0.000000]模块:0xbf000000-0xc0000000(16 MB)
[0.000000]。初始化:0xc0008000-0xc002c000(144 kB)
[0.000000]。文本:0xc002c000-0xc0390000(3472 kB)
[0.000000]。数据:0xc0390000-0xc03b6600(154KB)
[0.000000]SLUB:genslab=13,HWalign=32,Order=0-3,MinObjects=0,cpu=1,Nodes=1
[0.000000]可抢占分层RCU实现。
[0.000000]基于RCU的暂停CPU检测被禁用。
[0.000000]详细暂停的CPU检测已禁用。
[0.000000]NR_IRQ:245
[0.000000]控制台:彩色虚拟设备80x30
[0.000407]校准延迟回路(跳过)预设值。。215.44波哥米普斯(lpj=1077248)
[0.000494]pid_最大值:默认值:32768最小值:301
[0.000794]安全框架已初始化
[0.001001]装载缓存哈希表条目:512
[0.002188]CPU:测试写入缓冲区一致性:正常
[0.004944]devtmpfs:已初始化
[0.010877]达芬奇:8 gpio IRQ
[0.011931]NET:注册协议系列16
[0.066045]dm365\u rmd\u cs\u rdk\u 150\u wl\u初始
[0.066124]指定索引没有条目
[0.069960]指定索引没有条目
[0.192448]bio:在0处创建楼板
[0.199765]SCSI子系统已初始化
[0.206445]usbcore:已注册的新接口驱动程序usbfs
[0.208607]usbcore:已注册的新接口驱动程序集线器
[0.210484]usbcore:已注册的新设备驱动程序usb
[0.215823]vpss vpss:dm365\U vpss vpss已探测
[0.215919]vpss vpss:dm365\U vpss vpss探测成功
[0.222681]高级Linux声音体系结构驱动程序版本1.0.23。
[0.228358]切换到时钟源定时器0_1
[0.356682]网络:已注册的协议系列2
[0.357150]IP路由缓存哈希表条目:1024(顺序:04096字节)
[0.358399]TCP建立的哈希表条目:2048(顺序:216384字节)
[0.358604]TCP绑定哈希表条目:2048(顺序:18192字节)
[0.358736]TCP:已配置哈希表(已建立2048绑定2048)
[0.358784]TCP雷诺已注册
[0.358845]UDP哈希表条目:256(顺序:0,4096字节)
[0.358939]UDP Lite哈希表条目:256(顺序:0,4096字节)
[0.359791]NET:已注册的协议系列1
[0.466150]壁球:版本4.0(2009/01/31)Phillip Lougher
[0.469156]JFFS2版本2.2。(NAND)©2001-2006红帽公司。
[0.474898]msgmni已设置为87
[0.481735]io计划程序noop已注册(默认)
[0.484414]CSL:模块安装成功,设备主数量=254
[0.484478]CSL:模块版本0.10.00,构建于2013年12月13日22:33:02
[0.484552]I2C:模块安装成功,设备主数量=253
[0.484609]DMA:模块安装成功,设备主数量=252
[0.484654]DRV:模块安装成功
[0.484692]DRV:2013年12月13日建造的模块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模块:于2013年12月13日22:32:35建造
[0.484957]参考Linux版本2.6.37
[0.484996]文件/opt/workdir/OV9715_Ver5_0/dvsdk_ipnctools/linuxutils_2_26_02_05/packages/ti/sdo/linuxutils/edma/src/module/edmak.c
[0.487539]IRQK模块:于2013年12月13日22:32:33构建
[0.487612]参考Linux版本2.6.37
[0.487653]文件/opt/workdir/OV9715_Ver5_0/dvsdk_ipnctools/linuxutils_2_26_02_05/packages/ti/sdo/linuxutils/irq/src/module/irqk.c
[0.490558]irqk已初始化
[0.490663]CMEMK模块:于2013年12月13日22:32:30建成
[0.490723]参考Linux版本2.6.37
[0.490762]文件/opt/workdir/OV9715_Ver5_0/dvsdk_ipnctools/linuxutils_2_26_02_05/packages/ti/sdo/linuxutils/cmem/src/module/cmemk.c
[
$(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
[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
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