之前我们制作了jffs根文件,现在要来制作yaffs2根文件.
cd /work/nfs/
mkyaffs2image root rootfs.yaffs2
(
其中,root是busybox的安装路径,rootfs.yaffs2是目标文件.
这条命令需要到mkyaffs2image,记得先安装mkyaffs2image:
http://download.csdn.net/detail/guet_kite/9859634
先下载好yaffs_source_util_larger_small_page_nand.tar.bz2压缩包.
tar xjvf yaffs_source_util_larger_small_page_nand.tar.bz2
cd Development_util_ok/yaffs2/utils/
make
sudo cp mkyaffs2image /usr/bin/
sudo chmod 777 /usr/bin/mkyaffs2image
mkyaffs2image
出现:
mkyaffs2image: image building tool for YAFFS2 built May 11 2017
usage: mkyaffs2image dir image_file [convert]
dir the directory tree to be converted
image_file the output file to hold the image
'convert' produce a big-endian image from a little-endian machine
即是安装成功.
)
之前我们已经给Kernel打了yaffs2补丁了,下载我们把uImage以及rootfs.yaffs2根文件下载进板子上.
发现:
yaffs: dev is 32505859 name is "mtdblock3" rw
yaffs: passed flags ""
VFS: Mounted root (yaffs2 filesystem) on device 31:3.
Freeing unused kernel memory: 176K (c06be000 - c06ea000)
Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = c0104000
[00000000] *pgd=00000000
Internal error: Oops: 5 [#1] ARM
Modules linked in:
CPU: 0 PID: 1 Comm: swapper Not tainted 4.4.66 #4
Hardware name: SMDK2440
task: c381faa0 ti: c3822000 task.ti: c3822000
PC is at kfree+0x48/0xbc
LR is at path_openat+0x338/0xeb4
pc : [
sp : c3823dc8 ip : c3401088 fp : c3823e30
r10: c30a8980 r9 : c3401088 r8 : 00000021
r7 : 00000000 r6 : c3823eb0 r5 : a0000013 r4 : c3823e70
r3 : c3fe4460 r2 : c3fe4474 r1 : c30312c0 r0 : c3823eb0
Flags: nZCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment none
Control: c000717f Table: 30104000 DAC: 00000053
Process swapper (pid: 1, stack limit = 0xc3822190)
Stack: (0xc3823dc8 to 0xc3824000)
3dc0: c3823e70 c3fe4474 00020020 c3823e70 c3823f14 00020020
3de0: 00000000 c01ad490 c071c7e0 0000000a c3823eb0 c3401088 c06f94c0 00000041
3e00: 00000000 00000000 c3823e78 c30a8988 c3401220 c3409ce8 c06f94c0 c014305c
3e20: c073dd60 c3823e48 c39550f0 c3401220 00000000 00000000 c3409bc0 00000000
3e40: 00000000 0110dd24 c0708a88 c3823e70 c3823f14 00000001 c06ee870 c06ee900
3e60: 00000000 c381faa0 00000000 c01ae070 c39550f0 c3401088 fe37573a 00000007
3e80: c30312c7 c0141ae8 c39550f0 c3401e58 c3409ce8 00000101 00000000 0000001a
3ea0: 00000000 00000000 00000001 c3823eb0 c39550f0 c3401a18 c30312c0 00000000
3ec0: c3409e10 00000000 00000038 00000000 00000000 c072f782 00000000 c014262c
3ee0: c307c000 00000000 00000002 ffffff9c c072f782 c307c000 c307c000 c3ba8a00
3f00: c06ee870 c01a5bbc c06ee900 c31a2280 c31a2280 00020020 00000000 00000021
3f20: 00000100 00000001 c3ba8a00 c307c000 ffffff9c c3ba8a00 c06ee870 c01a764c
3f40: c06ec0f4 c0164774 c39550f0 c381fc90 0000002b 0000000b c06ec1b8 00000000
3f60: 00000000 c071be60 c061f324 00000000 00000000 00000000 00000000 00000000
3f80: 00000000 c01a7b88 00000000 c061f324 00000000 c01097cc c071be60 c05591d4
3fa0: 00000000 c055925c 00000000 c010a4b0 00000000 00000000 00000000 00000000
3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
3fe0: 00000000 00000000 00000000 00000000 00000013 00000000 73de33cf 33ce33cc
[
[
[
[
[
[
[
[
Code: e3120001 e58d2004 12423001 e593701c (e5974000)
---[ end trace 2b8bfb6afb01a088 ]---
Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
random: nonblocking pool is initialized
好了,现在重点来了!!!注意笔记!!听课听课了后排的同学!!!
exitcode=0x0000000b
说明是内存错误,应该是指针指向了某个错误的地方.
我们看下log:[
说明在kfree这个函数应该有问题.
在yaffs_vfs.c里看到如下内容:
void yaffs_put_link(struct inode *inode,void *alias)
{
kfree(alias);
}
因为之前我们修改了alias的保存位置,所以应该是这里出了问题,现在修改为:
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 66)/*这里我们用的是4.4.66版本,会执行else分支*/
void yaffs_put_link(struct dentry *dentry, struct nameidata *nd, void *alias)
#else
void yaffs_put_link(struct inode *inode,void *alias)
#endif
{
kfree(alias);
}
修改了好保存,继续make uImage
然后下载到板子上,还是不能成功启动yaffs2文件:
Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel
Control: c000717f Table: 30104000 DAC: 00000017
Process swapper (pid: 1, stack limit = 0xc38261b8)
Stack: (0xc3827ec0 to 0xc3828000)
7ec0: c3405c80 c3401f58 c3827f0c c3ac08a0 c3826000 c02774c4 c3812430 c3401f58
7ee0: c06535ac 00000007 c06535ac 000040d0 c3857920 c3821d60 c3405c80 c02775f4
7f00: c3821d90 c3401f58 00000020 00000000 00000000 00000000 00000000 00000000
7f20: c3acbdc0 00000000 00000000 c3857920 c3ac08a0 c3405c80 c3ac08a0 c3af55d8
7f40: c3acbdc0 c0624418 c0624390 c019debc c0624390 c019cd90 00000002 c3826000
7f60: c3856000 c3ac08a0 c3af55d8 c019e26c 00000008 c3acbdf4 c3825bf8 00000000
7f80: 00000000 c0653d00 c04af57c 00000000 00000000 00000000 00000000 00000000
7fa0: 00000000 c04af5e0 00000000 c0109778 00000000 00000000 00000000 00000000
7fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
7fe0: 00000000 00000000 00000000 00000000 00000013 00000000 d3de73cf f3fe73cc
[
[
[
[
[
[
Code: e1a06003 e3120002 e5915134 1a00000f (e5954008)
---[ end trace c5cb40e8a330a2bc ]---
Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
然后我们看到:
[
知道应该在yaffs_getxattr这里出错了,然后看下源码,
发现真的难改.........改不下去了..........................
我看了下4.4.66的Linux Kernel,是在2017年5月发布的,
yaffs2源码也是在2017年5月发布的,但是,
我猜是,yaffs2的支持技术是更不上Kernel的更新速度的,
与其我在这花大量的时间精力去移植,不如选个适合的Kernel版本.移植这些事情还是交给官方维护人员去做吧..........
去yaffs2的官网看了下,yaffs2文件大概五个月更新一次,那我就选一个五个月之前发布的Kernel吧.
看到Kernel4.8.17是2017年1月发布的,刚好,下载下来编译,给Kernel打yaffs2文件的补丁,编译直接成功,无需任何修改,很完美。
如果用Kernel4.4.66版本,可能要等到10月份左右发布的yaffs2源码了,到时可以试试.