制作jffs2根文件系统

来源:互联网 发布:淘宝88元xbox360手柄 编辑:程序博客网 时间:2024/06/10 21:50

一、制作mkfs.jffs2工具 

       首先得准备好两个软件包 ,一个是MTD设备的工具包,另一个是zlib压缩包,在这我的MTD设备工具包为mtd-snapshot-20050519.tart.tar,zlib压缩包是zlib-1.2.3.tar.tar。

步骤:
(1)解压zlib-1.2.3.tar.tar,

$tar xf zlib-1.2.3.tar.tar (在制作mkfs.jffs2过程中需要用到得库);
(2)解压mtd-snapshot-20050519.tar.tar

$tar xf mtd-snapshot-20050519.tar.tar
$ ls

mtd  mtd-snapshot-20050519.tar.tar  zlib-1.2.3  zlib-1.2.3.tar.tar
(3)进入解压后的目录zlib-1.2.3执行:
$ cd zlib-1.2.3/ 
$ ./configure --shared --prefix=/usr/(放入系统目录中);
(4)直接make,进行编译。
$ make
(5)安装编译好的库文件:
$ make install
(6)编译安装mkfs.jffs2工具

$cd mtd/util

$make

$make install (安装命令到系统中)

$which mkfs.jffs2

/usr/sbin/mkfs.jffs2

二、制作jffs2文件系统

          这时你就可以用你制作的mkfs.jfss2工具制作jfffs文件系统了!

$mkfs.jffs2 -n -s 512 -e 16KiB -d filesys -o filesys.jffs2

或$mkfs.jffs2 -r filesys -o filesys.jffs2 -e 0x4000 --pad=0x800000 -n(这个制作的,不管文件系统多大,--pad=0x800000 这个参数都让做成8MB)

 注释:

       上面命令中,"-n"表示不要在每个擦除块上都加上清除标志,"-s 512"指明一页大小为512字节,"-e 16KiB”指明一个擦除块大小为16KB,"-d"表示根文件系统目录,"-o"表示输出文件(目标文件)。"--pad"表示用16进制输出文件的大小,也就是filesys.jffs2的size。

三、jffs2文件系统烧写

#tftp 30008000 filesys.jffs2

#nand erase 200000 800000 (根文件系统所在的分区,kernel启动的时候有显示)

#nand write 30008000 200000 800000   (nand write 下载的地址 偏移地址 大小)

然后设置uboot启动参数

#setenv bootcmd tftp 30800000 zImage\; go 30800000

#setenv bootargs root=/dev/mtdblock2 init=/linuxrc rootfstype=jffs2 rw console=ttySAC0,115200

mkfs.jffs2使用方法
选项含义(man a mkfs.jffs2)

mkfs.jffs2: Usage: mkfs.jffs2 [OPTIONS]Make a JFFS2 file system image from an existing directory treeOptions:

-p, --pad[=SIZE]       用16进制來表示所要输出档案的大小,也就是root.jffs2的size。 很重要的是, 為了不浪费flash空间,这个值最好符合flash driver所规定的区块大小 。果不足则使用0xff来填充补满。                            

 -r, -d, --root=DIR      指定要做成image的原资料夹.(默认:当前文件夹)

-s, --pagesize=SIZE     节点页大小(默认: 4KiB)

-e, --eraseblock=SIZE   设定擦除块的大小为(默认: 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   指明不添加清楚标记(nand flash 有自己的校检块,存放相关的信息。)如果挂载后会出现类 似:          CLEANMARKER node found at 0x0042c000 has totlen 0xc != normal 0x0                     的警告,则加上-n 就会消失。

-o, --output=FILE       指定输出image档案的文件名.(default: stdout)

-l, --little-endian     指定使用小端格式-b, --big-endian        指定使用大端格式

-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       将所有文件的拥有者设为root用户

-P, --squash-perms      Squash permissions on all files     

                                           --with-xattr        stuff all xattr entries into image     

                                          --with-selinux      stuff only SELinux Labels into jffs2 image     

                                          --with-posix-acl    stuff only POSIX ACL entries into jffs2 image

-h, --help              显示这些文字

-v, --verbose           Verbose operation

-V, --version           显示版本

-i, --incremental=FILE     Parse FILE and generate appendage output for it