Chinaunix首页 | 论坛 | 博客
  • 博客访问: 107438
  • 博文数量: 46
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 13
  • 用 户 组: 普通用户
  • 注册时间: 2011-05-10 00:03
个人简介

芯片开发爱好人士

文章分类
文章存档

2013年(49)

我的朋友

分类: 嵌入式

2013-05-01 21:35:19

原文地址:3.8 mini2440上 移植yaffs2 作者:时间看来

1. 准备工作

完成了《Mini2440 Linux移植开发实战指南》3.7节的nand flash的移植。

获取yaffs 源码。

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

2. Menuconfig中的顺序并不是这样:

然后进入 yaffs2 源代码目录执行:

#cd yaffs2

#./patch-ker.sh c /opt/FriendlyARM/mini2440/linux-2.6.32.2

 

patch-ker.sh后自动完成下面三点:

1)修改内核fs/Kconfig 增加一行:source "fs/yaffs2/Kconfig"

2)修改内核fs/Makefile 增加一行ojb-$(CONFIG_YAFFS_FS) +=yaffs2/

3) 在内核fs/目录下创建yaffs2目录将yaffs2源码目录下面的Makefile.kernel文件复制为内核fs/yaffs2 /Makefie;yaffs2 源码目录的Kconfig文件复制到内核fs/yaffs2目录下; yaffs2源码目录下的*.c *.h文件复制到内核fs/yaffs2目录下。

 

执行make menuconfig 的时候可以看到menu的顺序不太对。

我用的yaffs_source.tar.gz0712月的啦。有点古老(应该是韦东山那本书光盘里的介绍的)。不知道现在版本的会不会存在这样的问题。

不是:

File Systems --->

--->Miscellaneous filesystems

--->YAFFS2 file system support

而是:

原因是fs/Kconfig中的source "fs/yaffs2/Kconfig"加的位置会影响它所在的层次。其中source应用的Kconfig的顺序基本就是menu的顺序。

menuconfig MISC_FILESYSTEMS

     bool "Miscellaneous filesystems"

……

source "fs/ufs/Kconfig"

source "fs/exofs/Kconfig"

 

# Patched by YAFFS

source "fs/yaffs2/Kconfig"

 

endif # MISC_FILESYSTEMS

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

3. 第一次移植,失败(yaffs2版本过旧)

错误信息:

[root@localhost torvalds-linux-v2.6.32-0]# make zImage

scripts/kconfig/conf -s arch/arm/Kconfig

  CHK     include/linux/version.h

make[1]: include/asm-arm/mach-types.h”是最新的。

  CHK     include/linux/utsrelease.h

  SYMLINK include/asm -> include/asm-arm

  CALL    scripts/checksyscalls.sh

  CHK     include/linux/compile.h

  CC      fs/yaffs2/yaffs_ecc.o

  CC      fs/yaffs2/yaffs_fs.o

fs/yaffs2/yaffs_fs.c:212: error: unknown field `prepare_write' specified in initializer

fs/yaffs2/yaffs_fs.c:212: warning: initialization from incompatible pointer type

fs/yaffs2/yaffs_fs.c:213: error: unknown field `commit_write' specified in initializer

fs/yaffs2/yaffs_fs.c:213: warning: initialization from incompatible pointer type

fs/yaffs2/yaffs_fs.c:287: error: unknown field `read_inode' specified in initializer

fs/yaffs2/yaffs_fs.c:287: warning: initialization from incompatible pointer type

 

错误原因:

内核版本和yaffs2的版本不匹配。

晕死,文档说from CVS。不过现在GIT了啦。没有看懂怎么下载。

强大的CU下载,竟然没有找到yaffs

最后到GITHUB上下载了,原来有各种语言写的这个文件系统,却不知道哪个官方的,就随便找个试试吧,当然要C写的。

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

4. 再次为内核打上yaffs2的补丁

yaffs2没有看到版本号,比较痛苦。

这次#./patch-ker.sh c /opt/FriendlyARM/mini2440/linux-2.6.32.2,出现以下提示:

 

usage:  ./patch-ker.sh  c/l m/s kernelpath

 if c/l is c, then copy. If l then link

 if m/s is m, then use multi version code. If s then use single version code

c/l很好理解。m/s呢?

我还是选择#./patch-ker.sh c m /opt/FriendlyARM/mini2440/linux-2.6.32.2吧。

这次在Kconfig中的menu顺序正确的:

看到一篇帖子,他说以前他都是make clean ,然后make zImage。结果等待时间很长。你有没有犯过这样的错误呢?我也犯过,O(_)O哈哈~

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

5. 第二次移植,失败(ftl_cs: FTL header not found.

这次zImage大小为:2109100 bytes

启动刚才编译的内核,看到如下信息:

Creating 5 MTD partitions on "NAND 256MiB 3,3V 8-bit":

0x000000000000-0x000000040000 : "supervivi"

ftl_cs: FTL header not found.

0x000000040000-0x000000060000 : "param"

ftl_cs: FTL header not found.

0x000000060000-0x000000560000 : "Kernel"

uncorrectable error :

0x000000560000-0x000040560000 : "root"

mtd: partition "root" extends beyond the end of device "NAND 256MiB 3,3V 8-bit" -- size truncated to 0xfaa0000

ftl_cs: FTL header not found.

0x000000000000-0x000040000000 : "nand"

mtd: partition "nand" extends beyond the end of device "NAND 256MiB 3,3V 8-bit" -- size truncated to 0x10000000

uncorrectable error :

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

6. 第三次移植,失败(nand driver部分的提示都看不到)

根据资料[3]ftl_cs: FTL header not found.这是移植不成功的显示啊。同时作者也给出了解决办法:原来应在配置菜单->Device Drivers ->Memory Technology Devices (MTD),将其取消。这我就不理解了,yaffs2不是nand flash上的文件系统吗?这应该是MTD啊。

这次zImage大小为:1927368 bytes

郁闷,这次nand driver部分的提示都看不到。

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

7. 第四次移植,失败(选中FTL support

还是选中MTD在其内选中了FTL support

这次zImage大小为:1938632 bytes

和第三次启动的结果一样。

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

8. menuconfigyaffs2的消失

难道是我配置的时候把它的依赖选项去掉了?

在配置中我很难找到那里变动了。于是cp arch/arm/configs/mini2440_defconfig .config了。再次进入menuconfig就可以找到yaffs2的选项了。这个提醒我每个阶段可以保存一下配置文件。

这次zImage大小为:2061472 bytes

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

9. 第五次移植(选中MTD,但不选FTL support

这次zImage大小为:2058488 bytes

这次如愿以偿地得到以下信息,和nand flash移植中设置的一样:

Creating 5 MTD partitions on "NAND 256MiB 3,3V 8-bit":

0x000000000000-0x000000040000 : "supervivi"

0x000000040000-0x000000060000 : "param"

0x000000060000-0x000000560000 : "Kernel"

0x000000560000-0x000040560000 : "root"

mtd: partition "root" extends beyond the end of device "NAND 256MiB 3,3V 8-bit" -- size truncated to 0xfaa0000

0x000000000000-0x000040000000 : "nand"

mtd: partition "nand" extends beyond the end of device "NAND 256MiB 3,3V 8-bit" -- size truncated to 0x10000000

 

(这个分区,为什么会划到1G呢?搞不明白。)

但这是移植成功的标志吗?和《Mini2440 Linux移植开发实战指南》3.8节里讲得不一样,但和参考[3]比较像了。

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

10. 验证yaffs2是否移植成功

在我没辙的时候,看到(可以使用supervivi“y“功能烧写友善之臂提供的现成的yaffs2文件系统映像root_qtopia-128M.img用以测试)。这真是一个好办法。

结果总是让人失望:

drivers/rtc/hctosys.c: unable to open rtc device (rtc0)

List of all partitions:

1f00             256 mtdblock0 (driver?)

1f01             128 mtdblock1 (driver?)

1f02            5120 mtdblock2 (driver?)

1f03          256640 mtdblock3 (driver?)

1f04          262144 mtdblock4 (driver?)

No filesystem could mount root, tried:  ext3 cramfs vfat msdos romfs

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

Backtrace:

看到Backtrace:,可惜我现在还看不懂。

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

11. 将配置中yaffs2 support选择为了M

之前启动内核一直提示:

List of all partitions:

1f00             256 mtdblock0 (driver?)

1f01             128 mtdblock1 (driver?)

1f02            5120 mtdblock2 (driver?)

1f03          256640 mtdblock3 (driver?)

1f04          262144 mtdblock4 (driver?)

No filesystem could mount root, tried:  ext3 cramfs vfat msdos romfs

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

刚才回去检查了一下配置,原来错误地将配置中yaffs2 support选择为了M,应该编译到内核才对。从新编译好内核,下载测试:(这次zImage 2105704 bytes

drivers/rtc/hctosys.c: unable to open rtc device (rtc0)

yaffs: dev is 32505859 name is "mtdblock3" rw

yaffs: passed flags ""

VFS: Mounted root (yaffs filesystem) on device 31:3.

Freeing init memory: 144K

Warning: unable to open an initial console.

Failed to execute /linuxrc.  Attempting defaults...

Kernel panic - not syncing: No init found.  Try passing init= option to kernel.

这次看起来比较靠谱了,应该写入正确的根文件系统后,就能顺利地启动系统了。

 

下载后内核后,再[y] Download root_yaffs image,将mini2440光盘自带的rootfs_qtopia_qt4.img下载进去测试,提示:

drivers/rtc/hctosys.c: unable to open rtc device (rtc0)

yaffs: dev is 32505859 name is "mtdblock3" rw

yaffs: passed flags ""

VFS: Mounted root (yaffs filesystem) on device 31:3.

Freeing init memory: 144K

Kernel panic - not syncing: Attempted to kill init!

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

12. Yaffs2根文件系统再尝试

Kernel panic - not syncing: Attempted to kill init!

看到很多帖子对这个问题的处理:

2,解决

原来问题在这里

Kernel Features  --->

[*] Use the ARM EABI to compile the kernel                   

[*]   Allow old ABI binaries to run with this kernel (EXPERIMENTA)

把这个选上就可以了

3,重新编译,烧录就可以了。”

 

怎么可以这样呢,记得再前面我把它去掉的,尝试了一下:

[root@localhost torvalds-linux-v2.6.32-0]# make zImage

scripts/kconfig/conf -s arch/arm/Kconfig

  CHK     include/linux/version.h

make[1]: include/asm-arm/mach-types.h”是最新的。

  CHK     include/linux/utsrelease.h

  SYMLINK include/asm -> include/asm-arm

  CC      kernel/bounds.s

cc1: error: invalid option `abi=aapcs-linux'

make[1]: *** [kernel/bounds.s] 错误 1

make: *** [prepare0] 错误 2

 

原因:

我用的arm-linux-gcc version 3.4.5

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

13. arm-linux-gcc 4.4.3版本编译

这次zImage 2113988 bytes

这次没有出现cc1: error: invalid option `abi=aapcs-linux'的错误提示了。不过有警告信息,不知道会产生怎样的影响?:

drivers/net/dm9000.c: In function 'dm9000_init':

drivers/net/dm9000.c:1565: warning: unused variable 'oldval_bankcon4'

……

drivers/usb/host/ohci-hub.c:318: warning: 'ohci_finish_controller_resume' defined but not used

……

lib/decompress_bunzip2.c: In function 'get_next_block':

lib/decompress_bunzip2.c:511: warning: the frame size of 1888 bytes is larger than 1024 bytes


烧入rootfs_qtopia_qt4,这次终于进入终端了:

Freeing init memory: 132K

hwclock: can't open '/dev/misc/rtc': No such file or directory

[01/Jan/1970:00:00:10 +0000] boa: server version Boa/0.94.13

[01/Jan/1970:00:00:10 +0000] boa: server built Jul 26 2010 at 15:58:29.

[01/Jan/1970:00:00:10 +0000] boa: starting server pid=750, port 80

                       

open device leds: No such file or directory

Try to bring eth0 interface up......eth0: link down

Done

 

Please press Enter to activate this console.  

[root@FriendlyARM /]# ls

bin         home        lost+found  proc        sys         var

dev         lib         mnt         root        tmp         www

etc         linuxrc     opt         sbin        usr

[root@FriendlyARM /]#


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

参考:

[1] Mini2440 Linux移植开发实战指南

[2] http://blog.chinaunix.net/space.php?uid=25445243&do=blog&id=199269

[3] http://blog.csdn.net/hl5654/article/details/6978285

阅读(1030) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~