製作jffs2根檔案系統

來源:互聯網
上載者:User

 

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

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.