UBIFS文件系统烧写2

UBIFS文件系统烧写2(1)解压方式

需要工具:flash_eraseall ubiattach ubimkvol 
方法简便明了,需要设置的参数很少,缺点是时间稍长。

flash_eraseall /dev/mtd4
ubiattach /dev/ubi_ctrl -m 4
ubimkvol /dev/ubi1 -N rootfs -s 204800KiB
mount -t ubifs ubi1:rootfs /mnt

mount -t vfat /dev/mmcblk0p1 /tmp
tar xf rootfs.tar -C /mnt/

umount /mnt/
umount /tmp/

(2)ubi工具烧写
需要的工具比较多:
HOST :  mkfs.ubifs   ubinize 
TARGET:flash_eraseall ubiformat 

首先在HOST上制作根文件系统的ubifs镜像以及将用于烧写到MTD的ubi镜像。需要的参数比较多,如果参数不正确,得到的结果将是错误的。

获取参数的方法,可以在U-Boot中获取,参考下列信息:

#!/bin/sh
#information about rootfs partion frm U-Boot
#U-Boot$ubi part rootfs
#UBI: mtd1 is detached from ubi0
#Creating 1 MTD partitions on "nand0":
#0x000001600000-0x000010000000 : "mtd=4"
#device_name0:mtd=4
#UBI: attaching mtd1 to ubi0
#UBI: physical eraseblock size: 131072 bytes (128 KiB)
#UBI: logical eraseblock size: 129024 bytes
#UBI: smallest flash I/O unit: 2048
#UBI: sub-page size: 512
#UBI: VID header offset: 512 (aligned 512)
#UBI: data offset: 2048
#scanning error 0
#UBI: attached mtd1 to ubi0
#UBI: MTD device name: "mtd=4"
#UBI: MTD device size: 234 MiB
#UBI: number of good PEBs: 1870
#UBI: number of bad PEBs: 2
#UBI: max. allowed volumes: 128
#UBI: wear-leveling threshold: 4096
#UBI: number of internal volumes: 1
#UBI: number of user volumes: 1
#UBI: available PEBs: 222
#UBI: total number of reserved PEBs: 1648
#UBI: number of PEBs reserved for bad PEB handling: 18
#UBI: max/mean erase counter: 2/1

# -m 2048
# -e 129024
# -c 1872 (1870+2)
# -s 512

mkfs.ubifs -r rootfs -m 2048 -e 129024 -c 1872 -o rootfs.img
ubinize -o ubi.img -m 2048 -p 128KiB -s 512 ubi.cfg

 

然后启动系统,NFS、ramdisk或者安全文件系统都可以,并将得到的ubi.img放到系统可访问的目录或者介质中。在目标系统中运行下列命令,完成UBI镜像的烧写,然后重启系统即可:

flash_eraseall /dev/mtd4 
ubiformat /dev/mtd4 -s 512 -f ubi.img


在主机上用到了一个ubi.cfg文件,如下:

$ cat ubi.cfg
[ubifs]
mode=ubi
image=rootfs.img
vol_id=1
vol_size=200MiB
vol_type=dynamic
vol_name=rootfs
vol_flags=autoresize

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值