yaff2文件系统在FL2440上的移植

一、移植环境
    主  机:Fedora 14 (kernel-2.6.33.7)
    开发板:FL2440( nandflash:K9F1G08 128MB)
    编译器:arm-linux-gcc-4.3.2
 
二、移植步骤
    FL2440开发板自带的是带有集成了QT的文件系统,本身大小也较大,启动的时候需要加载的模块也比较多,所以导致开机时间比较慢。由于目前阶段我暂时不需要用到QT,所以就想为FL2440移植一个比较简单的文件系统,减少开机时间。具体移植步骤如下。
    1. 移植前的准备。为了进行本次文件系统移植,需要准备三个工具:
    busybox-1.13.1.tar.bz2,用于生成linux所需要的命令和工具,
    mkyaffs2image,用于制作yaffs2文件系统。
    yaffs2补丁,用于给配置内核,使内核支持yaffs2文件系统。
    2. 准备工作目录,进入工作目录,打上yaffs2补丁。
  1.     #mkdir rootfs
  2.     #cd rootfs
  3.     #tar -xzvf yaffs2.tar.gz
  4.     #cd yaffs2
  5.     #./patch-ker.sh c /home/skywalker/linux-2.6.33/
  6.     Updating ../linux-2.6.33.7//fs/Kconfig
  7.     Updating ../linux-2.6.33.7
  出现上述两行字样,则表示已经打好补丁
    3. 配置内核如下,使内核支持yaffs2文件系统。配置完成后重新编译内核,下载。(如果在移植内核的时候已经加入对yaffs2的支持,yaffs2补丁和这一步可以省略)。
  1. File systems --->
  2.     < > Second extended fs support
  3.     < > Ext3 journalling file system support
  4.     < > The Extended 4 (ext4) filesystem
  5.     < > Reiserfs support
  6.     < > JFS filesystem support
  7.     < > XFS filesystem support
  8.     < > OCFS2 file system support
  9.     < > Btrfs filesystem (EXPERIMENTAL) Unstable disk format
  10.     [*] Enable POSIX file locking API
  11.     [*] Dnotify support
  12.     [*] Inotify file change notification support
  13.     [*] Inotify support for userspace
  14.     [ ] Quota support
  15.      Kernel automounter support
  16.      Kernel automounter version 4 support (also supports v3)
  17.      FUSE (Filesystem in Userspace) support
  18.         Caches --->
  19.         CD-ROM/DVD Filesystems --->
  20.             <*> ISO 9660 CDROM file system support
  21.             [ ] Microsoft Joliet CDROM extensions
  22.             [ ] Transparent decompression extension
  23.             < > UDF file system support
  24.         DOS/FAT/NT Filesystems --->
  25.             <*> MSDOS fs support
  26.             <*> VFAT (Windows-95) fs support
  27.             (437) Default codepage for FAT
  28.             (iso8859-1) Default iocharset for FAT
  29.             < > NTFS file system support
  30.         Pseudo filesystems --->
  31.     [*] Miscellaneous filesystems --->
  32.         --- Miscellaneous filesystems
  33.         < > ADFS file system support (EXPERIMENTAL)
  34.         < > Amiga FFS file system support (EXPERIMENTAL)
  35.         < > Apple Macintosh file system support (EXPERIMENTAL)
  36.         < > Apple Extended HFS file system support
  37.         < > BeOS file system (BeFS) support (read only) (EXPERIMENTAL)
  38.         < > BFS file system support (EXPERIMENTAL)
  39.         < > EFS file system support (read only) (EXPERIMENTAL)
  40.         <*> YAFFS2 file system support
  41.         -*- 512 byte / page devices
  42.         [ ] Use older-style on-NAND data format with pageStatus byte
  43.         [ ] Lets Yaffs do its own ECC
  44.         -*- 2048 byte (or larger) / page devices
  45.         [*] Autoselect yaffs2 format
  46.         [ ] Disable lazy loading
  47.         [ ] Turn off wide tnodes
  48.         [ ] Force chunk erase check
  49.         [*] Cache short names in RAM
  50.         <*> Journalling Flash File System v2 (JFFS2) support
  51.         (0) JFFS2 debugging verbosity (0 = quiet, 2 = noisy)
  52.         [*] JFFS2 write-buffering support
  53.         [ ] Verify JFFS2 write-buffer reads
  54.         [*] JFFS2 summary support (EXPERIMENTAL)
  55.         [ ] JFFS2 XATTR support (EXPERIMENTAL)
  56.         [ ] Advanced compression options for JFFS2
  57.         <*> Compressed ROM file system support (cramfs)
  58.          SquashFS 4.0 - Squashed file system support
  59.         [ ] Additional option for memory-constrained systems
  60.         < > FreeVxFS file system support (VERITAS VxFS(TM) compatible)
  61.         < > Minix file system support
  62.         < > SonicBlue Optimized MPEG File System support
  63.         < > OS/2 HPFS file system support
  64.         < > QNX4 file system support (read only)
  65.         <*> ROM file system support
  66.         RomFS backing stores (Block device-backed ROM file system support) --
  67.         < > System V/Xenix/V7/Coherent file system support
  68.         < > UFS file system support (read only)
  69.         < > NILFS2 file system support (EXPERIMENTAL)
  70.     [*] Network File Systems --->
  71.         Partition Types --->
  72.     -*- Native language support --->
  73.     < > Distributed Lock Manager (DLM) --->
    4. 修改busybox顶层Makefile,使busybox支持适应arm平台,并配置busybox,加入或减少必要的参数。
  1.     #tar -xjvf busybox-1.13.1.tar.bz2
  2.     #cd busybox-1.13.1
  3.     #vim Makefile
  4.     CROSS_COMPILE ?= /usr/local/arm/3.4.1/bin/arm-linux- (164行左右)
  5.     ARCH ?= arm    (189行左右)
    配置busybox选项,下面只列出了要注意的地方,没有列出的默认即可 
  1.     #make menuconfig
  2.     Makefile:422: *** Mixed implicit and normal rules. stop
  3.     Makefile:1270: *** Mixed implicit and normal rules. stop
    在make menuconfig的时候出现了上述两个错误,意思是混合隐式和普通的规则。以前并未见过类似的错误,所以看着这两个错误也云里雾里,上百度也找不到解决的办法。最后在一个国外的嵌入式论坛找到原因:是make版本差异导致的,我的fedora14上的make版本是3.82,而这busybox适应的make版本是3.81,所以规则存在差异。解决办法就是打补丁,或者手动修改如下:
把422行
  1.     config %config: scripts_basic outputmakefile FORCE
  2.             $(Q)mkdir -p include
  3.             $(Q)$(MAKE) $(build)=scripts/kconfig $@
  4.             $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease
改为
  1.     %config: scripts_basic outputmakefile FORCE
  2.               $(Q)mkdir -p include
  3.               $(Q)$(MAKE) $(build)=scripts/kconfig $@
  4.               $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease
把1270行
  1.     / %/: prepare scripts FORCE
  2.               $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
  3.               $(build)=$(build-dir)
改为
  1.     %/: prepare scripts FORCE
  2.               $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
  3.               $(build)=$(build-dir)
修改完毕后便可以进行busybox的配置
 
  1. Busybox Settings --->
  2.     General Configuration --->
  3.             Buffer allocation policy (Allocate with Malloc) --->
  4.         [*] Show verbose applet usage messages
  5.         [*] Store applet usage messages in compressed form
  6.         [*] Support --install [-s] to install applet links at runtime
  7.         [*] Enable locale support (system needs locale for this to work)
  8.         [*] Support for --long-options
  9.         [*] Use the devpts filesystem for Unix98 PTYs
  10.         [*] Support writing pidfiles
  11.         [*] Runtime SUID/SGID configuration via /etc/busybox.conf
  12.         [*] Suppress warning message if /etc/busybox.conf is not readable
  13.         (/proc/self/exe) Path to BusyBox executable
  14.     Build Options --->
  15.         [*] Build BusyBox as a static binary (no shared libs)
  16.         [*] Build with Large File Support (for accessing files > 2 GB)
  17.     Installation Options --->
  18.         [ ] Don't use /usr
  19.             Applets links (as soft-links) --->
  20.         (./_install) BusyBox installation prefix
  21.     Busybox Library Tuning --->
  22.         (6) Minimum password length
  23.         (2) MD5: Trade Bytes for Speed
  24.         [*] Faster /proc scanning code (+100 bytes)
  25.         [*] Command line editing
  26.         (1024) Maximum length of input
  27.         [*] vi-style line editing commands
  28.         (15) History size
  29.         [*] History saving
  30.         [*] Tab completion
  31.         [*] Fancy shell prompts
  32.         (4) Copy buffer size, in kilobytes
  33.         [*] Use ioctl names rather than hex values in error messages
  34.         [*] Support infiniband HW
  35. Linux Module Utilities --->
  36.     (/lib/modules) Default directory containing modules
  37.     (modules.dep) Default name of modules.dep
  38.     [*] insmod
  39.     [*] rmmod
  40.     [*] lsmod
  41.     [*] modprobe
  42.     --- Options common to multiple modutils
  43.     [ ] Support version 2.2/2.4 Linux kernels
  44.     [*] Support tainted module checking with new kernels
  45.     [*] Support for module.aliases file
  46.     [*] Support for module.symbols fileLinux System Utilities --->
 
    编译make之后,出现如下错误
  1. [skywalker@localhost busybox-1.13.1]$make
  2. CC networking/interface.o
  3. networking/interface.c:818: error: `ARPHRD_INFINIBAND' undeclared here (not in a function)
  4. networking/interface.c:818: error: initializer element is not constant
  5. networking/interface.c:818: error: (near initialization for `ib_hwtype.type')
  6. make[1]: *** [networking/interface.o] 错误 1
  7. make: *** [networking] 错误 2
  8. [skywalker@localhost busybox-1.13.1]$
    通过查看内核源代码目录中的“include/linux/ifarp.h”文件可得知“ARPHRDINFINIBAND”的值为“32”,然后修改“networking/interface.c”文件,在其中添加如下定义,再重新编译即可通过。
  1.     #vim networking/interface.c
  2.     #define ARPHRD_INFINIBAND 32 /* InfiniBand */

  3.     #make
  4.     #make install
    5. 开始构建文件系统
    1). 新建一个目录root_2.6.33,吧busybox-1.13.1/_install目录下生成bin、linuxrc、sbin、usr全部复制到这个目录,并且在该目录下创建文件系统所需要的其他目录。
     #mkdir root-2.6.33
      #cp -rf busybox-1.13.1/_install/* root-2.6.33/
      #cd root-2.6.33/
      #mkdir dev etc home lib mnt opt proc tmp var www sys

    2).向各目录中添加文件系统所需要的目录或文件,没有提到的就不用添加。这里要注意各种文件的权限,建议都改为777,命令:#chmod 777 文件名。

"dev"目录,创建两个设备文件: 
  1. #mknod console c 5 1
  2. #mknod null c 1 3
"etc"目录,创建各种配置文件并向里面添加内容,没有列出的就不用添加:

boa/boa.conf: boa WEB服务器配置文件,暂时为空。

group: 系统用户组配置文件,内容如下: 
  1. root:*:0:
  2. daemon:*:1:
  3. bin:*:2:
  4. sys:*:3:
  5. adm:*:4:
  6. tty:*:5:
  7. disk:*:6:
  8. lp:*:7:lp
  9. mail:*:8:
  10. news:*:9:
  11. uucp:*:10:
  12. proxy:*:13:
  13. kmem:*:15:
  14. dialout:*:20:
  15. fax:*:21:
  16. voice:*:22:
  17. cdrom:*:24:
  18. floppy:*:25:
  19. tape:*:26:
  20. sudo:*:27:
  21. audio:*:29:
  22. ppp:x:99:
  23. 500:x:500:plg
  24. 501:x:501:fa
inittab: 系统init进程配置文件,内容如下: 
  1. # /etc/inittab
  2. ::sysinit:/etc/init.d/rcS
  3. console::askfirst:-/bin/sh
  4. ::ctrlaltdel:/sbin/reboot
  5. ::shutdown:/bin/umount -a -r
另一选择:
  1. # /etc/inittab

  2. #Startup the system
  3. null::sysinit:/bin/mount -o remount, rw /
  4. null::sysinit:/bin/mount -t proc proc /proc
  5. null::sysinit:/bin/mount -a
  6. #null::sysinit:/bin/hostname -F /etc/sysconfig/HOSTNAME

  7. #now run any rc srcipts
  8. ::sysinit:/etc/init.d/rcS

  9. #now invoke shell
  10. ::askfirst:/bin/sh

  11. #logging junk
  12. null::sysinit:/bin/touch /var/log/messages
  13. null::respawn:/sbin/syslogd -n -m 0
  14. null::respawn:/sbin/klogd -n

  15. #stuff to do for the 3-finger salute
  16. ::ctrlaltdel:/sbin/reboot

  17. #stuff to do before rebooting
  18. null::shutdown:/bin/killall klogd
  19. null::shutdown:/bin/killall syslogd
  20. null::shutdown:/bin/umount -a -r
  21. null::shutdown:/sbin/swapoff -a
 
mime.types: 暂时为空。

passwd: 系统密码文件,内容如下: 
  1. root::0:0:root:/:/bin/sh
  2. ftp::14:50:FTP User:/var/ftp:
  3. bin:*:1:1:bin:/bin:
  4. daemon:*:2:2:daemon:/sbin:
  5. nobody:*:99:99:Nobody:/:
  6. sky::502:502:Linux User,,,:/home/sky:/bin/sh
rc.d/init.d/httpd: 内容如下: 
  1. #!/bin/sh
  2. base=boa
  3. # See how we were called.
  4. case "$1" in
  5.   start)
  6.         /usr/sbin/$base
  7.         ;;
  8.   stop)
  9.     pid=`/bin/pidof $base`
  10.     if [ -n "$pid" ]; then
  11.         kill -9 $pid
  12.     fi
  13.         ;;
  14. esac
  15. exit 0
sysconfig/HOSTNAME: 主机名称文件,内容如下:
  1. yyq2440

fstab: 系统挂载文件系统列表,内容如下: 
  1. # device mount-point type options dump fsck order
  2. none /proc proc defaults 0 0
  3. none /dev/pts devpts mode=0622 0 0
  4. tmpfs /dev/shm tmpfs defaults 0 0
另一选择:
  1. #<file system>    <mount pt>    <type>    <option>    <dump>    <pass>
  2. /dev/root    /        ext2    rw.noauto    0    1
  3. proc        /proc        proc    defaults    0    0
  4. devpts        /dev/pts    devpts    defaults    0    0
  5. tmpfs        /tmp        tmpfs    defaults    0    0
  6. sysfs        /sys        sysfs    defaults    0    0
 
init.d/rcS: 系统启动加载项,内容如下: 
  1. #!/bin/sh

  2. PATH=/sbin:/bin:/usr/sbin:/usr/bin
  3. runlevel=S
  4. prevlevel=N
  5. umask 022
  6. export PATH runlevel prevlevel

  7. #
  8. # Trap CTRL-C &c only in this shell so we can interrupt subprocesses.
  9. #
  10. /bin/mount -t proc none /proc
  11. /bin/mount -t tmpfs none /tmp
  12. /bin/mount -t tmpfs none /var

  13. /bin/mkdir -p /var/log

  14. /bin/hostname -F /etc/sysconfig/HOSTNAME



  15. mdev.conf: mdev设备配置文件,暂时为空。

  16. net.conf: 网络配置文件,暂时为空。

  17. profile: 用户环境配置文件,内容如下:
  18. # Ash profile
  19. # vim: syntax=sh

  20. # No core files by default
  21. #ulimit -S -c 0 > /dev/null 2>&1

  22. USER="`id -un`"
  23. LOGNAME=$USER
  24. PS1='[\u@\h \W]\# '
  25. PATH=$PATH:/usr/local/bin
  26. LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
  27. HOSTNAME=`/bin/hostname`

  28. export USER LOGNAME PS1 PATH LD_LIBRARY_PATH

resolv.conf: DNS配置文件,内容如下: 
  1. nameserver 61.144.56.100

"home"目录:创建一个sky目录,与etc目录passwd文件中的sky相对应

"lib"目录:这个里面放的都是库文件,直接从交叉编译器的库文件目录中拷贝过来,并删除不必要的符号信息,以减小所占容量: 
   #cp -f /usr/local/arm/3.4.1/arm-linux/lib/*so* lib/ -a
   #arm-linux-strip lib/*
    6. 使用mkyaffs2image工具生成yaffs2文件系统。先把mkyaffs2image解压出来并复制到/usr/sbin/目录下,然后执行:
  1. #mkyaffs2image root-2.6.33/ root-2.6.33.bin
    即可生成yaffs2文件系统,下载到开发板启动,这时却出现一个比较烦人的错误。
  1. List of all partitions:
  2. 1f00 128 mtdblock0 (driver?)
  3. 1f01 384 mtdblock1 (driver?)
  4. 1f02 3072 mtdblock2 (driver?)
  5. 1f03 61440 mtdblock3 (driver?)
  6. 1f04 512 mtdblock4 (driver?)
  7. 1f05 60928 mtdblock5 (driver?)
  8. No filesystem could mount root, tried: ext3 ext2 cramfs vfat msdos iso9660 romfs yaffs yaffs2
  9. Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,3)
  10. Backtrace:
  11. [<c00309bc>] (dump_backtrace+0x0/0x104) from [<c0030ad8>] (dump_stack+0x18/0x1c)
  12.  r7:c388c000 r6:c388c037 r5:00000000 r4:c381bf5c
  13. [<c0030ac0>] (dump_stack+0x0/0x1c) from [<c004d008>] (panic+0x3c/0x124)
  14. [<c004cfcc>] (panic+0x0/0x124) from [<c0009044>] (mount_block_root+0x1d8/0x21c)
  15.  r3:00000003 r2:c381bf6f r1:c381bf5c r0:c03a39ac
  16. [<c0008e6c>] (mount_block_root+0x0/0x21c) from [<c0009254>] (mount_root+0xd0/0xf0)
  17. [<c0009184>] (mount_root+0x0/0xf0) from [<c00093e4>] (prepare_namespace+0x170/0x1d0)
  18.  r6:00000000 r5:c0024a0c r4:c042ca54
  19. [<c0009274>] (prepare_namespace+0x0/0x1d0) from [<c0008c1c>] (kernel_init+0xd8/0x10c)
  20.  r5:c00238e8 r4:c042c838
  21. [<c0008b44>] (kernel_init+0x0/0x10c) from [<c004f814>] (do_exit+0x0/0x5a4)
  22.  r5:00000000 r4:00000000
    找了一些资料,这个错误时跟arm-linux-gcc版本有关。原来是我刚才把arm-linux-gcc换成了4.3.2惹的祸,4.*的版本编译出来的内核+yaffs2文件系统一般都会报错:Kernel panic - not syncing: Attempted to kill init!解决办法有两个。
    a. 重新配置内核,选上以下参数:
  1. Kernel Features --->
  2. [*] Use the ARM EABI to compile the kernel
  3. [*] Allow old ABI binaries to run with this kernel (EXPERIMENTA)
    b. 把编译器换成3.*。
    我当然会选择第二种了,于是乎又把编译器换回3.4.1版本。再次重重新编译下载启动,从终端的启动信息可以看到。2.6.33.7内核+yaffs2文件系统顺利启动:
  1. yaffs: dev is 32505859 name is "mtdblock3"
  2. yaffs: passed flags ""
  3. yaffs: Attempting MTD mount on 31.3, "mtdblock3"
  4. yaffs: auto selecting yaffs2
  5. block 122 is bad
  6. block 342 is bad
  7. usb 1-1: new full speed USB device using s3c2410-ohci and address 2
  8. yaffs_read_super: isCheckpointed 0
  9. VFS: Mounted root (yaffs filesystem) on device 31:3.
  10. Freeing init memory: 144K
  11. hub 1-1:1.0: USB hub found
  12. hub 1-1:1.0: 4 ports detected

  13. Please press Enter to activate this console.
  14. [root@yyq2440 /]#
    但这时使用ls命令却又有了新问题。
[root@yyq2440 /]# ls
[1;34mbin[0m         [1;34mhome[0m        [1;34mlost+found[0m  [1;34mproc[0m        [1;34musr[0m
[1;34mdev[0m         [1;34mlib[0m         [1;34mmnt[0m         [1;34msbin[0m        [1;34mvar[0m
[1;34metc[0m         [1;36mlinuxrc[0m     [1;34mopt[0m         [1;34mtmp[0m         [1;34mwww[0m
    造成这样的原因是,busybox配置的时候默认选上了支持色彩附加信息,而DNW不支持色彩信息,所以会显示乱码。如果换成超级终端或者PUTTY就会显示正常,但我用习惯了DNW,还是重新配置以下吧。配置busybox时把下面两项N掉就可解决这个bug。
  1. Coreutils --->
  2.    [*] ls
  3.      [ ] Allow use of color to identify file types
  4.      [ ] Produce colored ls output by default (NEW)
    最后文件系统终于正常工作了,被各种问题折腾的不轻啊。还好耐心地慢慢摸索把问题解决,编译出一个可以运行的文件系统。明天可以安心回家过年了,希望过个好年,好想念家里人和家里的美食啊。O(∩_∩)O哈哈~


2011-1-30



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值