制作Jffs2格式的文件系统

来源:互联网 发布:淘宝客推广一天赚多少 编辑:程序博客网 时间:2024/05/20 11:47

首先要有一个可用的文件系统,可以根文件系统或者是QT文件系统。

其次,下载并安装相关的制作工具。

  1. http://download.chinaunix.net/download/0008000/7062.shtml 这里有两个mtd-snapshot版本。推荐使用新版本,我在使用旧版本时,make出错。高手可以为之折腾,新手推荐一次到位,能成功就好。本次使用mtd-snapshot-20050519.tar.bz2  执行命令:tar -xvjf mtd-snapshot-20050519.tar.bz2 -> cd ./mtd/util -> make ->make install .这时,在/usr/sbin/下面可以找到刚才安装的mkfs.jffs2工具。这是默认安装路径。因为我在使用时并不能执行./configure 所以没有指定安装路径,使用的是默认的。好像找不到./configure,不过不影响使用。
  2. zlib-1.2.3.xx.rpm或者.tar.gz 。通常情况下安装已经带有的了。但是每个人的情况不一样,所以还是要检查一下。执行:rpm -qa |grep zlib 得到下面结果则说明安装好了,否则要手动安装这个软件包,可以到安装文件的package下面找:
    zlib-devel-1.2.3-3
    zlib-1.2.3-3
做好以上两步,可以了。接下来就是使用该命令来制作jffs2系统了。如果PATH里面没有/usr/sbin/路径,要手动添加。若不添加也可以使用/usr/sbin/mkfs.jffs2 来启动命令。
[root@RHEL util]# mkfs.jffs2 --help
mkfs.jffs2: Usage: mkfs.jffs2 [OPTIONS]
Make a JFFS2 file system image from an existing directory tree


Options:
  -p, --pad[=SIZE]        Pad output to SIZE bytes with 0xFF. If SIZE is
                          not specified, the output is padded to the end of
                          the final erase block
  -r, -d, --root=DIR      Build file system from directory DIR (default: cwd)
  -s, --pagesize=SIZE     Use page size (max data node size) SIZE (default: 4KiB)
  -e, --eraseblock=SIZE   Use erase block size SIZE (default: 64KiB)
  -c, --cleanmarker=SIZE  Size of cleanmarker (default 12)
  -m, --compr-mode=MODE   Select compression mode (default: priortiry)
  -x, --disable-compressor=COMPRESSOR_NAME
                          Disable a compressor
  -X, --enable-compressor=COMPRESSOR_NAME
                          Enable a compressor
  -y, --compressor-priority=PRIORITY:COMPRESSOR_NAME
                          Set the priority of a compressor
  -L, --list-compressors  Show the list of the avaiable compressors
  -t, --test-compression  Call decompress and compare with the original (for test)
  -n, --no-cleanmarkers   Don't add a cleanmarker to every eraseblock
  -o, --output=FILE       Output to FILE (default: stdout)
  -l, --little-endian     Create a little-endian filesystem
  -b, --big-endian        Create a big-endian filesystem
  -D, --devtable=FILE     Use the named FILE as a device table file
  -f, --faketime          Change all file times to '0' for regression testing
  -q, --squash            Squash permissions and owners making all files be owned by root
  -U, --squash-uids       Squash owners making all files be owned by root
  -P, --squash-perms      Squash permissions on all files
  -h, --help              Display this help text
  -v, --verbose           Verbose operation
  -V, --version           Display version information
  -i, --incremental=FILE  Parse FILE and generate appendage output for it

 #mkfs.jffs2 -l -n -s 0x1000 -e 0x20000 --pad=0x2000000 -d qtrootfs/ -o qtrootfs.32M.jffs2  各个参数的意思参考帮助文档。其中,-s -e要根据使用的nandflash的规格设置。本系统使用samsung的K9F2G08nandflash,所以-s -e为上述值。如是-e 参数的值设置过小,会出现Empty at flash xxxxxxx 的错误;而设置过大则有Jffs2_scan_eraseblock(): Magic bitmask ...... 的问题。--pad的大小要是-s的整数倍,并且这个数值要比-d指定的文件要大,否则会生成默认大小,而不是所指定的大小。在nandflash里,-n是要用到,不然会在启动系统时,出现CLEANMARKERnode found at 0x0042c000 has totlen 0xc != normal 0x0  这类的警告,心里会很不爽!