您的位置:首页 > 其它

移植u-boot支持ubi遇到的问题总结

2010-08-31 17:37 246 查看
============================================

作者:yuanlulu
http://blog.csdn.net/yuanlulu
版权没有,但是转载请保留此段声明

============================================

自己最近在移植u-boot.201006到smartarm3250,后来又增加了ubi文件系统的移植。

移植过程中遇到N多问题,自己搞了N久才搞定。在此分享一下自己的错误,希望对各位同仁有用。





(1)u-boot启动后提示“*** Warning - bad CRC or NAND, using default environment”

这一般不是大问题,不理它也没事。它是提醒你在falsh中读不到环境变量,只能使用软件中定义的默认环境变量。如果要解决,只要在u-boot中输入saveenv就行了,下次启动应该不会再出现了,如果还出现,可能是你的nand驱动有问题,也可能是坏块。

u-boot默认使用flash中的环境变量,如果软件中修改了环境变量,最好saveenv一次。



(2)u-boot的12号错误。

这是我加入ubi支持后出现的错误。

UBI error: ubi_init: UBI error: cannot initialize UBI, error -12

UBI init error -12

查阅include/asm-generic/error.h发现12号错误的定义为“#define ENOMEM 12 /* Out of memory */”。经过追踪,是在driver/mtd/ubi/build.c的ubi_attach_mtd_dev函数中第二次 vmalloc时死掉,因此修改smartarm3250.h(我的配置文件)中CONFIG_SYS_MALLOC_LEN,增大到1M(1024*1024)。问题解决。



(3)u-boot的5号错误。

UBI error: ubi_io_write: error -5 while writing 512 bytes to PEB 0:512, written 0 bytes

查阅include/asm-generic/error.h发现5号错误的定义为“#define EIO 5 /* I/O error */”。

http://www.linux-mtd.infradead.org/faq/ubi.html#L_subpage_verify_fail有对这个问题的专门描述:

I get "ubi_io_write: error -5 while writing 512 bytes to PEB 5:512"

If you have a 2048 bytes per NAND page device, and have CONFIG_MTD_NAND_VERIFY_WRITE enabled in your kernel, you will need to turn it off. The code does not currently (as of 2.6.26) perform verification of sub-page writes correctly. As UBI is one of the few
users of sub-page writes, not much else seems to be affected by this bug.

虽然是说Linux内核配置,可是u-boot中同样有CONFIG_MTD_NAND_VERIFY_WRITE ,在smartarm3250.h中将这个宏注释掉,问题解决。看来是内核的问题,既然u-boot很大程度上使用了Linux内核的驱动,应该是ubi驱动的问题。



(4)Cannot start volume update。

在common/cmd_ubi.c中的ubi_volume_write函数中找到打印这句话的地方,打印err发现仍然为12号错误。解决办法在上面第2条。



(5)启动时内核打印出ubi的19号错误(NO SUCH DEVICE)。

也就是内核找不到某个分区,一般应该是u-boot中定义的CONFIG_BOOTARGS不对。

我的正确定义是

#define CONFIG_BOOTARGS "ubi.mtd=4 root=ubi0:rootfs console=ttyS0,115200 mem=64M rootfstype=ubifs rw"

原来的错误写法是#define CONFIG_BOOTARGS "ubi.mtd=6 root=ubi0:rootfs console=ttyS0,115200 mem=64M rootfstype=ubifs rw"。其实原因在于u-boot对nand falsh的分区方式和你所用的Linux内核不一致 。

我的u-boot定义的分区如下:

#if 1

#define MTDIDS_DEFAULT "nand0=nandflash0"

#define MTDPARTS_DEFAULT "mtdparts=nandflash0:"1536k(bootloder)"/

"512k(params)"/

"4m(kernel)"/

"16m(safefs)"/

"-(root)"

#endif //end of yll



(6)linux内核启动时输出以下信息,并停住:

UBIFS error (pid 1): ubifs_read_node: bad node type (0 but expected 6)

UBIFS error (pid 1): ubifs_read_node: bad node at LEB 0:0

List of all partitions:

1f00 1536 mtdblock0 (driver?)

1f01 256 mtdblock1 (driver?)

1f02 4096 mtdblock2 (driver?)

1f03 16384 mtdblock3 (driver?)

1f04 239616 mtdblock4 (driver?)

No filesystem could mount root, tried: ubifs

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

这个问题是由于写入命令错误引起的,原来的写入命令为ubi write 0x01600000 rootfs $(filesize),应该为ubi write 0x080008000 rootfs $(filesize)。

也就是说原来根本没有把文件系统写入flash。

如果你也有此类错误,要么是你的文件系统镜像没有写入(或者没正确写入),要么是你做的文件系统镜像有问题。其他问题可能不大。



(7)软件版本问题。

linux内核启动过程中出现以下信息并停住:

UBIFS error (pid 1): ubifs_check_node: bad CRC: calculated 0x9f186f96, read 0x3baee010

UBIFS error (pid 1): ubifs_check_node: bad node at LEB 0:0

UBIFS error (pid 1): ubifs_read_node: expected node type 6

VFS: Cannot open root device "ubi0:rootfs" or unknown-block(0,0)

Please append a correct "root=" boot option; here are the available partitions:

1f00 1536 mtdblock0 (driver?)

1f01 256 mtdblock1 (driver?)

1f02 4096 mtdblock2 (driver?)

1f03 16384 mtdblock3 (driver?)

1f04 239616 mtdblock4 (driver?)

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

我的文件系统镜像使用mtd-utils2010做的,我后来改为mtd-utils2009,问题解决。

我的内核版本是2.6.27.8。我猜测因为我的内核版本比较旧,所以内核和mtd-utils2010中的crc算法有差异才会出现bad CRC。

如果你也碰到类似问题,请确保内核版本和mtd-utils版本匹配。看是否匹配只要看内核和mtd-utils是不是一年出的就行,或者时间接近。总之,两个出现时间较远的软件协同工作会有可能出错。

mtd-utils下载地址 http://ftp.debian.org/pool/main/m/mtd-utils/ (下载orig.tar.gz结尾的包)



我有时就想,怎么那么多错误都让我给摊上了,其实犯错时一种幸福。你要是找个文档照着做全对,你还学什么。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: