Chinaunix首页 | 论坛 | 博客
  • 博客访问: 831202
  • 博文数量: 281
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 2770
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-02 19:45
个人简介

邮箱:zhuimengcanyang@163.com 痴爱嵌入式技术的蜗牛

文章分类
文章存档

2020年(1)

2018年(1)

2017年(56)

2016年(72)

2015年(151)

分类: LINUX

2016-06-18 11:19:42

移植新内核第三课: 移植YAFFS文件系统

上一篇移植并挂接了jffs2文件系统,这篇主要讲如何移植YAFFS文件系统。
移植YAFFS文件系统:

1. 下载yaffs2源代码

    注意:YAFFS文件系统并没有集成在linux内核中
    git clone git://
    

2. 解压,打补丁

    tar xjf yaffs2.tar.bz2
    cd yaffs-dir  比如:cd yaffs2/
    ./patch-ker.sh  c m linux-tree  
   
    这里输入命令,将yaffs源代码解压到linux内核树:/work/system/linux-3.4.2中:
     cd yaffs2/
     ./patch-ker.sh c m /work/system/linux-3.4.2

    

3. 查看yaffs2源码是否安装到linux内核中了

    查看linux源码,可以看到yaffs2源代码全部解压到linux内核中去了
    book@book-desktop:/work/system/linux-3.4.2$ ls fs/yaffs2/
    Kconfig               yaffs_linux.h        yaffs_summary.c
    Makefile              yaffs_mtdif1.c       yaffs_summary.h
    yaffs_allocator.c     yaffs_mtdif1.h       yaffs_tagscompat.c
    yaffs_allocator.h     yaffs_mtdif2.c       yaffs_tagscompat.h
    yaffs_attribs.c       yaffs_mtdif2.h       yaffs_trace.h
    yaffs_attribs.h       yaffs_mtdif.c        yaffs_verify.c
    yaffs_bitmap.c        yaffs_mtdif.h        yaffs_verify.h
    yaffs_bitmap.h        yaffs_nameval.c      yaffs_vfs.c
    yaffs_checkptrw.c     yaffs_nameval.h      yaffs_yaffs1.c
    yaffs_checkptrw.h     yaffs_nand.c         yaffs_yaffs1.h
    yaffs_ecc.c           yaffs_nand.h         yaffs_yaffs2.c
    yaffs_ecc.h           yaffs_packedtags1.c  yaffs_yaffs2.h
    yaffs_getblockinfo.h  yaffs_packedtags1.h  yportenv.h
    yaffs_guts.c          yaffs_packedtags2.c
    yaffs_guts.h          yaffs_packedtags2.h

4. 配置内核支持YAFFS

    make menuconfig

    默认:
    Symbol: YAFFS_DOES_ECC [=n]                                             |
  | Type  : boolean                                                         |
  | Prompt: Lets yaffs do its own ECC                                       |
  |   Defined at fs/yaffs2/Kconfig:51                                       |
  |   Depends on: MISC_FILESYSTEMS [=y] && YAFFS_FS [=n] && YAFFS_YAFFS1 [= |
  |   Location:                                                             |
  |     -> File systems                                                     |
  |       -> Miscellaneous filesystems (MISC_FILESYSTEMS [=y])              |
  |         -> yaffs2 file system support (YAFFS_FS [=n])                   |
  |           -> 512 byte / page devices (YAFFS_YAFFS1 [=n])                |
  |             -> Use older-style on-NAND data format with pageStatus byte

    改成支持YAFFS文件系统:
  | Symbol: YAFFS_DOES_ECC [=n]                                                                                          |
  | Type  : boolean                                                                                                      |
  | Prompt: Lets yaffs do its own ECC                                                                                    |
  |   Defined at fs/yaffs2/Kconfig:51                                                                                    |
  |   Depends on: MISC_FILESYSTEMS [=y] && YAFFS_FS [=y] && YAFFS_YAFFS1 [=y] && !YAFFS_9BYTE_TAGS [=n]                  |
  |   Location:                                                                                                          |
  |     -> File systems                                                                                                  |
  |       -> Miscellaneous filesystems (MISC_FILESYSTEMS [=y])                                                           |
  |         -> yaffs2 file system support (YAFFS_FS [=y])         // 这里表示支持yaffs2文件系统                                                       |
  |           -> 512 byte / page devices (YAFFS_YAFFS1 [=y])                                                             |
  |             -> Use older-style on-NAND data format with pageStatus byte (YAFFS_9BYTE_TAGS [=n])      

5. 编译、使用uImage

    make uImage

    发现一堆错误:
    book@book-desktop:/work/system/linux-3.4.2$ make uImage
      CHK     include/linux/version.h
      CHK     include/generated/utsrelease.h
    make[1]: `include/generated/mach-types.h' is up to date.
      CALL    scripts/checksyscalls.sh
      CHK     include/generated/compile.h
      CC      fs/yaffs2/yaffs_vfs.o
    fs/yaffs2/yaffs_vfs.c:440: warning: initialization from incompatible pointer type
    fs/yaffs2/yaffs_vfs.c:445: warning: initialization from incompatible pointer type
    fs/yaffs2/yaffs_vfs.c:447: warning: initialization from incompatible pointer type
    fs/yaffs2/yaffs_vfs.c: In function 'yaffs_mtd_put_super':
    fs/yaffs2/yaffs_vfs.c:2514: error: 'struct mtd_info' has no member named 'sync'
    fs/yaffs2/yaffs_vfs.c:2515: error: 'struct mtd_info' has no member named 'sync'
    fs/yaffs2/yaffs_vfs.c: In function 'yaffs_internal_read_super':
    fs/yaffs2/yaffs_vfs.c:2702: error: 'struct mtd_info' has no member named 'erase'
    fs/yaffs2/yaffs_vfs.c:2703: error: 'struct mtd_info' has no member named 'read'
    fs/yaffs2/yaffs_vfs.c:2704: error: 'struct mtd_info' has no member named 'write'
    fs/yaffs2/yaffs_vfs.c:2705: error: 'struct mtd_info' has no member named 'read_oob'
    fs/yaffs2/yaffs_vfs.c:2706: error: 'struct mtd_info' has no member named 'write_oob'
    fs/yaffs2/yaffs_vfs.c:2707: error: 'struct mtd_info' has no member named 'block_isbad'
    fs/yaffs2/yaffs_vfs.c:2708: error: 'struct mtd_info' has no member named 'block_markbad'
    fs/yaffs2/yaffs_vfs.c:2732: error: 'struct mtd_info' has no member named 'erase'
    fs/yaffs2/yaffs_vfs.c:2733: error: 'struct mtd_info' has no member named 'block_isbad'
    fs/yaffs2/yaffs_vfs.c:2734: error: 'struct mtd_info' has no member named 'block_markbad'
    fs/yaffs2/yaffs_vfs.c:2734: error: 'struct mtd_info' has no member named 'read'
    fs/yaffs2/yaffs_vfs.c:2734: error: 'struct mtd_info' has no member named 'write'
    fs/yaffs2/yaffs_vfs.c:2736: error: 'struct mtd_info' has no member named 'read_oob'
    fs/yaffs2/yaffs_vfs.c:2736: error: 'struct mtd_info' has no member named 'write_oob'
    fs/yaffs2/yaffs_vfs.c:2757: error: 'struct mtd_info' has no member named 'erase'
    fs/yaffs2/yaffs_vfs.c:2757: error: 'struct mtd_info' has no member named 'read'
    fs/yaffs2/yaffs_vfs.c:2757: error: 'struct mtd_info' has no member named 'write'
    fs/yaffs2/yaffs_vfs.c:2759: error: 'struct mtd_info' has no member named 'read_oob'
    fs/yaffs2/yaffs_vfs.c:2759: error: 'struct mtd_info' has no member named 'write_oob'
    fs/yaffs2/yaffs_vfs.c:2967: error: implicit declaration of function 'd_alloc_root'
    fs/yaffs2/yaffs_vfs.c:2967: warning: assignment makes pointer from integer without a cast
    make[2]: *** [fs/yaffs2/yaffs_vfs.o] Error 1
    make[1]: *** [fs/yaffs2] Error 2
    make: *** [fs] Error 2
    
    修改错误,
    重新编译,直到生成新的内核镜像文件uImage。

6. 制作、烧写yaffs映象

    mkyaffs2image my_fs my_fs.yaffs2
    uboot:
    tftp 30000000 my_fs.yaffs2   //nfs 30000000 192.168.1.10:/work/nfs_root/my_fs.yaffs2
    nand erase.part rootfs
    nand write.yaffs 30000000 260000  $filesize
    

7. 启动

    set bootargs console=ttySAC0,115200 root=/dev/mtdblock3
    tftp 30000000 uImage_yaffs     //或者:nfs 32000000 192.168.1.10:/work/nfs_root/uImage_yaffs
    bootm 30000000
    
    tftp 30000000 uImage_yaffs; bootm 30000000
   

8. 没成功,用替代法查找问题

    8.1 UBOOT可能有问题:换上1.1.6的UBOOT

        tftp 30000000 u-boot.bin
        nand erase.part u-boot
        nand write 30000000 u-boot
        reset
        nfs 30000000 192.168.1.123:/work/nfs_root/fs_mini_mdev_new.yaffs2
        nand erase rootfs
        nand write.yaffs 30000000 260000  $(filesize)
        set bootargs console=ttySAC0,115200 root=/dev/mtdblock3
        nfs 32000000 192.168.1.123:/work/nfs_root/uImage_yaffs
        bootm 32000000

        发现1.1.6的UBOOT没问题,所以就是我们移植的新UBOOT: u-boot-2012.04.01有BUG:
        drivers\mtd\nand\Nand_util.c

            if (!need_skip && !(flags & WITH_DROP_FFS)) {
        改为
            if (!need_skip && !(flags & WITH_DROP_FFS) && !(flags & WITH_YAFFS_OOB)) {

    8.2 YAFFS映象可能有问题

         已经证明是8.1的问题了。

总结:

1. yaffs2文件系统的源代码并没有集成在linux内核中,需要去相关网站下载;
2. 下载,安装yaffs2文件系统到新的内核中;
3. 在新的内核中配置,使其支持yaffs文件系统。
4. 编译新的内核,支持yaffs2文件系统,并利用之前busybox制作的文件系统,使用工具mkyaffs2image 制作yaffs2文件系统。
5. 烧录新的kernel,yaffs2文件系统,测试。
    
阅读(1125) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~