UBIFS檔案系統燒寫2

來源:互聯網
上載者:User

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

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.