制作文件系统的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


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值