前段时间移植了Linux-2.6.31到LPC3250上,但是在使用ubifs的时候遇到了一些问题。
原来在2.7.27.8上,ubifs没有任何问题就跑起来了,可是为何在这里却不行?摸索了大半天,终于搞定了,下面是过程。
主要现象是在linux-2.6.27上,ubi信息是:
Creating 1 MTD partitions on "nand0":
0x000000600000-0x000001600000 : "mtd=3"
device_name0:mtd=3
UBI: attaching mtd1 to ubi0
UBI: physical eraseblock size: 131072 bytes (128 KiB)
UBI: logical eraseblock size: 129024 bytes
UBI: smallest flash I/O unit: 2048
UBI: sub-page size: 512
UBI: VID header offset: 512 (aligned 512)
UBI: data offset: 2048
scanning error 0
UBI: attached mtd1 to ubi0
UBI: MTD device name: "mtd=3"
UBI: MTD device size: 16 MiB
UBI: number of good PEBs: 127
UBI: number of bad PEBs: 1
UBI: max. allowed volumes: 128
UBI: wear-leveling threshold: 4096
UBI: number of internal volumes: 1
UBI: number of user volumes: 1
UBI: available PEBs: 0
UBI: total number of reserved PEBs: 127
UBI: number of PEBs reserved for bad PEB handling: 2
UBI: max/mean erase counter: 4/1
在2.6.27上,UBI识别到了sub-page,VID header offset是512.
[ 1.191000] UBI: attaching mtd3 to ubi0
[ 1.195000] UBI: physical eraseblock size: 131072 bytes (128 KiB)
[ 1.201000] UBI: logical eraseblock size: 126976 bytes
[ 1.207000] UBI: smallest flash I/O unit: 2048
[ 1.212000] UBI: VID header offset: 2048 (aligned 2048)
[ 1.218000] UBI: data offset: 4096
[ 1.407000] UBI: attached mtd3 to ubi0
[ 1.411000] UBI: MTD device name: "safefs"
[ 1.416000] UBI: MTD device size: 16 MiB
[ 1.421000] UBI: number of good PEBs: 128
[ 1.426000] UBI: number of bad PEBs: 0
[ 1.430000] UBI: max. allowed volumes: 128
[ 1.435000] UBI: wear-leveling threshold: 4096
[ 1.440000] UBI: number of internal volumes: 1
[ 1.444000] UBI: number of user volumes: 1
[ 1.449000] UBI: available PEBs: 0
[ 1.453000] UBI: total number of reserved PEBs: 128
[ 1.458000] UBI: number of PEBs reserved for bad PEB handling: 2
[ 1.464000] UBI: max/mean erase counter: 2125/17
[ 1.469000] UBI: image sequence number: 0
[ 1.473000] UBI: background thread "ubi_bgt0d" started, PID 325
而在linux-2.6.31上,却没有识别到sub-page,VID header offset是2048。
可是使用的是同一块NAND FLASH,怎么会差别这么大?应该是MTD驱动的原因,暂时不深究了。
当然,上面的对比信息是正确启动后的完整信息。
最初的ubi出错信息是:
[ 1.168000] UBI: attaching mtd3 to ubi0
[ 1.172000] UBI: physical eraseblock size: 131072 bytes (128 KiB)
[ 1.179000] UBI: logical eraseblock size: 126976 bytes
[ 1.184000] UBI: smallest flash I/O unit: 2048
[ 1.189000] UBI: VID header offset: 2048 (aligned 2048)
[ 1.195000] UBI: data offset: 4096
[ 1.201000] UBI error: validate_ec_hdr: bad VID header offset 512, expected 2
048
[ 1.209000] UBI error: validate_ec_hdr: bad EC header
[ 1.214000] UBI error: ubi_io_read_ec_hdr: validation failed for PEB 0
[ 1.221000] UBI error: ubi_init: cannot attach mtd3
[ 1.228000] UBI error: ubi_init: UBI error: cannot initialize UBI, error -22
解决过程:
(1)在U-Boot生成ubi分区,加上2048的VID offset:
ubi part safefs 2048
之后出现的信息是:
但是内核还是无法起来。但是,出现的错误是:
[ 1.122000] Creating 5 MTD partitions on "NAND 256MiB 3,3V 8-bit":
[ 1.129000] 0x000000000000-0x000000180000 : "boot"
[ 1.141000] 0x000000180000-0x0000001c0000 : "prms"
[ 1.152000] 0x000000200000-0x000000600000 : "kernel"
[ 1.163000] 0x000000600000-0x000001600000 : "safefs"
[ 1.174000] 0x000001600000-0x000010000000 : "rootfs"
[ 1.191000] UBI: attaching mtd3 to ubi0
[ 1.195000] UBI: physical eraseblock size: 131072 bytes (128 KiB)
[ 1.202000] UBI: logical eraseblock size: 126976 bytes
[ 1.207000] UBI: smallest flash I/O unit: 2048
[ 1.212000] UBI: VID header offset: 2048 (aligned 2048)
[ 1.218000] UBI: data offset: 4096
[ 1.408000] UBI: attached mtd3 to ubi0
[ 1.412000] UBI: MTD device name: "safefs"
[ 1.417000] UBI: MTD device size: 16 MiB
[ 1.422000] UBI: number of good PEBs: 128
[ 1.426000] UBI: number of bad PEBs: 0
[ 1.431000] UBI: max. allowed volumes: 128
[ 1.435000] UBI: wear-leveling threshold: 4096
[ 1.440000] UBI: number of internal volumes: 1
[ 1.445000] UBI: number of user volumes: 1
[ 1.449000] UBI: available PEBs: 0
[ 1.454000] UBI: total number of reserved PEBs: 128
[ 1.458000] UBI: number of PEBs reserved for bad PEB handling: 2
[ 1.465000] UBI: max/mean erase counter: 4/1
[ 1.469000] UBI: image sequence number: 0
[ 1.473000] UBI: background thread "ubi_bgt0d" started, PID 325
[ 2.431000] UBIFS error (pid 1): validate_sb: LEB size mismatch: 129024 in su
perblock, 126976 real
[ 2.440000] UBIFS error (pid 1): validate_sb: bad superblock, error 1
显然,ubi已经没有问题,现在是ubifs出现问题,问题出现在制作ubifs时候的参数不对,该用内核提示的126976,而不是原来512的时候的129024啦!
(2)修改制作ubi镜像的参数:
命令改为:
mkfs.ubifs -r safefs -m 2048 -e 126976 -c 128 -o safefs.ubi
重新制作安全文件系统,安全文件系统正常启动!
制作ubi镜像:
mkfs.ubifs -r rootfs -m 2048 -e 126976 -c 1872 -o rootfs.img
ubinize -o ubi.img -m 2048 -p 128KiB -s 2048 ubi.cfg
(3)修改烧写ubi镜像的参数:
烧写ubi镜像:
ubiformat /dev/mtd4 -s 2048 -f ubi.img > /dev/null 2>&1
之后,问题解决,系统成功启动。
阅读(4693) | 评论(1) | 转发(3) |