Linux3.4.72内核支持UBI文件系统 (一)

在 Linux3.4.72内核启动分析2 -- 让串口正常工作 这篇文章中串口已经可以正常的工作了,并且在终端上已经可以看到打印信息。但是出现了另外的问题:

.....................
Kernel command line: noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0,115200n8r
......................
config: 8bits/char
setting ulcon to 00000003, brddiv to 26, udivslot 00000808
uart: ulcon = 0x00000003, ucon = 0x00000bc5, ufcon = 0x00000051
name =/dev/root
end_request: I/O error, dev mtdblock2, sector 0
FAT-fs (mtdblock2): unable to read boot sector
VFS: Cannot open root device "mtdblock2" or unknown-block(31,2): error -5
Please append a correct "root=" boot option; here are the available partitions:
1f00              32 mtdblock0  (driver?)
1f01            2048 mtdblock1  (driver?)
1f02          131072 mtdblock2  (driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)
Backtrace: 
[<c000c5c8>] (dump_backtrace+0x0/0x10c) from [<c02e67ac>] (dump_stack+0x18/0x1c)
 r6:c3896000 r5:fffffffb r4:c381ff40
[<c02e6794>] (dump_stack+0x0/0x1c) from [<c02e6838>] (panic+0x88/0x1d4)
[<c02e67b0>] (panic+0x0/0x1d4) from [<c03a6d58>] (mount_block_root+0x1a0/0x2d8)
 r3:00000000 r2:c384bdf4 r1:c381ff40 r0:c035a3fc
[<c03a6bb8>] (mount_block_root+0x0/0x2d8) from [<c03a6ee4>] (mount_root+0x54/0x6c)
[<c03a6e90>] (mount_root+0x0/0x6c) from [<c03a6ffc>] (prepare_namespace+0x100/0x194)
 r5:c03c3a4c r4:c03f3280
[<c03a6efc>] (prepare_namespace+0x0/0x194) from [<c03a63ec>] (kernel_init+0x168/0x1bc)
 r5:c03c3220 r4:c03c71ac
[<c03a6284>] (kernel_init+0x0/0x1bc) from [<c0019b04>] (do_exit+0x0/0x778)

从上面的log信息可以看到u-boot 传递给kernel 的参数是:

Kernel command line: noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0,115200n8r

而出错信息是

VFS: Cannot open root device "mtdblock2" or unknown-block(31,2): error -5, 不能open文件系统。其实原因很简单,我并没有向mtdblock2这块区域烧写文件系统。 

我的移植目标就是UBIFS。那么如何让这个kernel支持ubifs呢?

首先需要了解什么是ubifs。我是直接从官网(http://www.linux-mtd.infradead.org/)开始学习的。 这里就不介绍详细的ubi知识,但是会列出移植过程中遇到的问题。

1.在官方的FAQ(http://www.linux-mtd.infradead.org/faq/ubi.html)中有提到“How do i enable UBI ?”

In the Linux configuration menu, go to "Device Drivers" -> "Memory Technology Devices (MTD)" -> "UBI - Unsorted block images", and mark the "Enable UBI" check-box. UBI may be either compiled into the kernel or be built as a kernel module.

2.在官方的FAQ(http://www.linux-mtd.infradead.org/faq/ubifs.html)中提到: “How do I enable UBFIS”

Then in the Linux configuration menu, go to "File systems" -> "Miscellaneous filesystems", and mark the "UBIFS file system support" check-box. UBIFS may be either compiled into the kernel or be built as a kernel module.

这两个问题都是放在了ubi和ubifs FAQ问题的开始地方。即 如何让kernel 支持UBI 和UBIFS。设置方法写的很明白了,我们照做就可以。但是注意如果在你的kernel中找不到对应的配置选项的话,可能是你的kernel版本太旧了。

既然kernel 已经支持ubi文件系统了,那么如何让ubi文件系统自动挂载呢? 

其实和yaffs2的方法差不多,更改u-boot的启动参数就可以了: 

noinitrd ubi.mtd=2,2048 root=ubi0:rootfs rootfstype=ubifs init=/linuxrc console=ttySAC0,115200n8r 

为什么要设置ubi.mtd=2,2048 root=ubi0:rootfs rootfstype=ubifs ? 答案在http://www.linux-mtd.infradead.org/faq/ubifs.html 里面的"How do i mount UBIFS"。 

那么u-boot已经搞定,接下来就是如何制作UBI文件系统了。其实制作UBI文件系统的方法在官方网站上都有讲。所以一定要详细的读。

在下篇文章中详细的介绍我的ubi文件系统是如何制作的。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值