製作jffs2根文件系統

一、製作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

 

 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章