1。使用jffs2文件系统
2。使用yaffs2文件系统
规划:64M的nand,前2M存放内核,后面的分别使用jffs2文件系统和yaffs2文件系统。
1。使用jffs2文件系统
这样分区,就像给磁盘分区一样,呵呵
static struct mtd_partition smdk_default_nand_part[] = {
[0] = {
.name = "kernel",
.offset = 0x00000000,
.size = 0x00200000, // 2M
},
[1] = {
.name = "jffs2",
.offset = 0x00200000,
.size = 0x00000000, //2M~end
},
};
在没有烧写文件系统时的panic信息。
List of all partitions:
1f00 2048 mtdblock0 (driver?)
1f01 8192 mtdblock1 (driver?)
1f02 55296 mtdblock2 (driver?)
No filesystem could mount root, tried: vfat msdos iso9660 romfs
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)
glibc好大哦,18.3M,整个文件系统镜像也不过20M而已。
一定要缩减lib,节省空间,以后在说。
lzd> nand erase 0x200000 0x4000000
lzd> nfs 0x30000000 /home/lzd/nfs/jffs2.img
lzd> nand write.jffs2 0x30000000 0x200000 0x14C78E0
lzd> setenv bootargs noinitrd console=ttySAC0 root=/dev/mtdblock1 rootfstype=jffs2
lzd> nfs 0x32000000 /home/lzd/nfs/uImage
lzd> bootm 0x32000000
由于内核没有jffs2的支持
VFS: Cannot open root device "mtdblock1" or unknown-block(31,1)
Please append a correct "root=" boot option; here are the available partitions:
1f00 2048 mtdblock0 (driver?)
1f01 63488 mtdblock1 (driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,1)
给内核加上jffs2文件系统的支持之后
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x01904020: 0x51e5 id
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x01904024: 0x949f id
Further such events for this erase block will not be printed
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x01908000: 0x204c id
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x01908004: 0x5379 id
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x01908008: 0x3639 id
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0190800c: 0x7620 id
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x01908010: 0x3030 id
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x01908014: 0x230a id
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x01908018: 0x6178 id
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0190801c: 0x656c id
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x01908020: 0x776f id
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x01908024: 0x206f id
Further such events for this erase block will not be printed
Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes
empty_blocks 2364, bad_blocks 2, c->nr_blocks 3968
VFS: Cannot open root device "mtdblock1" or unknown-block(31,1)
Please append a correct "root=" boot option; here are the available partitions:
1f00 2048 mtdblock0 (driver?)
1f01 63488 mtdblock1 (driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,1)
选上
[*] NAND ECC Smart Media byte order
CC drivers/mtd/nand/nand_ecc.o
这个选项意义不大
怀疑是mkfs.jffs2工具生成的镜像不正确。
lzd@lzd-laptop:~$ sudo apt-get install mtd-tools
lzd@lzd-laptop:~$ mkfs.jffs2 -n -s 512 -e 16KiB -d nfs -o jffs.img
lzd@lzd-laptop:~$ mkfs.jffs2 -V
mkfs.jffs2: revision 1.50
新生成的镜像不在报错了。
用bless看看镜像,起初的文件系统镜像真的没有0x1985(在bless里是8519),新生成的镜像里就有(最开始的位置)。就是这个问题。
2。使用yaffs2文件系统
下载:
点击 Download GNU tarball
给内核打补丁:
lzd@lzd-laptop:~/yaffs2$ ./patch-ker.sh
usage: ./patch-ker.sh c/l kernelpath
if c/l is c, then copy. If l then link
lzd@lzd-laptop:~/yaffs2$ ./patch-ker.sh c ../linux-2.6.31/
Updating ../linux-2.6.31//fs/Kconfig
Updating ../linux-2.6.31//fs/Makefile
重新修改分区(只是改名字)
/* NAND parititon from 2.4.18-swl5 */
static struct mtd_partition smdk_default_nand_part[] = {
[0] = {
.name = "kernel",
.offset = 0x00000000,
.size = 0x00200000, // 2M
},
[1] = {
.name = "yaffs",
.offset = 0x00200000,
.size = 0x00000000, //2M~end
},
};
使内核支持yaffs2文件系统
lzd@lzd-laptop:~/linux-2.6.31$ make menuconfig
scripts/kconfig/mconf arch/arm/Kconfig
Your display is too small to run Menuconfig!
It must be at least 19 lines by 80 columns.
make[1]: *** [menuconfig] Error 1
make: *** [menuconfig] Error 2
lzd@lzd-laptop:~/linux-2.6.31$
从新打开xterm,ok
选上yaffs2,我用的默认配置,打开这个支持后,new我都没有选,不知道这些new作什么的。
我已经有了一个yaffs2镜像了,直接把他烧进去。
擦出整片,烧写yaffs2到2M位置,yaffs文件镜像肯定是528的整数倍,如果大小不是,说明有问题
其中 nand write.yaffs 命令的最后一个参数也要是528的整数倍,否则会报告错误。
lzd> nand erase
lzd> nfs 0x30000000 /home/lzd/nfs/yaffs.img
lzd> nand write.yaffs 0x30000000 0x200000 0x19EB940
lzd> setenv bootargs noinitrd console=ttySAC0 root=/dev/mtdblock1 rootfstype=yaffs
lzd> nfs 0x32000000 /home/lzd/nfs/uImage
lzd> nfs 0x32000000
出现下列出错信息:
yaffs: dev is 32505857 name is "mtdblock1"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.1, "mtdblock1"
yaffs: block 248 is marked bad
block 249 is bad
yaffs: block 1930 is marked bad
block 1931 is bad
yaffs_read_super: isCheckpointed 0
VFS: Mounted root (yaffs filesystem) on device 31:1.
Freeing init memory: 120K
Warning: unable to open an initial console.
Kernel panic - not syncing: No init found. Try passing init= option to kernel.
我的镜像里应该有busybox的阿,怎么会找不到初始化进程呢?
难道yaffs2镜像有问题?
难道上次我没有给mkyaffsimage工具打补丁?这次打补丁,从新生成yaffs2镜像。
lzd> nand write.yaffs 0x30000000 0x200000 0x1A07AE0
一切ok。真的是原来的mkyaffsimage工具的问题阿。
阅读(5810) | 评论(1) | 转发(0) |