製作文件系統的JFFS2鏡像

一、環境
Ubuntu 10.04
U-Boot 1.3.3(支持tftp)
二、過程
1、製作jffs2鏡像需要使用mkfs.jffs2工具,首先 安裝mkfs.jffs2工具
   sudo apt-get install mtd-tools
2、退到已做好的rootfs目錄的上一級
   ~/rootfs$ cd ..
   #mkfs.jffs2 -r rootfs -o rootfs.jffs2 -e 0x4000 --pad=0x500000 -s 0x200 -n
    即可生成 rootfs.jffs2


 注:
 各參數的意義:
 (1)-r : 指定要做成image的目錄名。
 (2)-o : 指定輸出image的文件名。
 (3)-e : 每一塊要擦除的block size,默認是64KB.要注意,不同的flash, 其block size會不一樣,這裏用的是三星的K9F1208U0B。
 (4)--pad (-p): 用16進制來表示所要輸出文件的大小,也就是rootfs.jffs2的size。很重要的是, 爲了不浪費flash空間, 這個值最好符合flash driver所規劃的分區的大小。
 (5)如果掛載後會出現類似:CLEANMARKER node found at 0x0042c000 has totlen 0xc != normal 0x0  的警告,則加上 -n 就會消失。
 (6) 還有的選項,自己看幫助!-h


3、啓動u-boot,將rootfs.jffs2下載到ram並燒寫到nand flash的某個分區上。
   nand flash 的分區爲:
 Creating 6 MTD partitions on "NAND 64MiB 3,3V 8-bit":
 0x00000000-0x00030000 : "bootloader"
 0x00030000-0x00200000 : "kernel"
 0x00200000-0x00400000 : "ramdisk"
 0x00400000-0x00800000 : "cramfs"
 0x00800000-0x01000000 : "jffs2"
 0x01000000-0x04000000 : "data"


   我們可以將rootfs.cramfs燒寫到0x800000上,對應的結點爲/dev/mtdblock/4。
  tftp 32000000 rootfs.jffs2
  nand erase 800000 1000000
  nand write.jffs2 32000000 800000 500000
4、要從cramfs啓動,可將u-boot的啓動參數改爲:
  root="/dev/mtdblock/4" rootfstype="jffs2" rw console="ttySAC0",115200 init="/linuxrc" noinitrd mem="64M"
   即可。


注意:使用jffs2文件系統時,對內核進行配置時需要選上對jffs2的支持。
注:經驗表明,如果jffs2分區太大,可能會出現以下問題:
jffs2: Erase block size too small (16KiB). Using virtual blocks size (32KiB) instead
Empty flash at 0x00003ffc ends at 0x00004000
Empty flash at 0x0000bffc ends at 0x0000c000
Empty flash at 0x00013ffc ends at 0x00014000
Empty flash at 0x0001bffc ends at 0x0001c000
Empty flash at 0x00023ffc ends at 0x00024000
Empty flash at 0x0002bf40 ends at 0x0002c000
Empty flash at 0x0003bffc ends at 0x0003c000
Empty flash at 0x00043fb0 ends at 0x00044000
Empty flash at 0x0004bf98 ends at 0x0004c000
Empty flash at 0x00053ffc ends at 0x00054000
Empty flash at 0x0005bfc8 ends at 0x0005c000
Empty flash at 0x00063fd0 ends at 0x00064000
Empty flash at 0x0006bf50 ends at 0x0006c000
Empty flash at 0x00073ffc ends at 0x00074000
Empty flash at 0x0007bf74 ends at 0x0007c000



   如果需要在其它文件系統中掛載該jffs2文件系統,可以這樣做
  #cd /tmp
  #mkdir jffs2
  #mount -t jffs2 /dev/mtdblock/4 jffs2


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