ubi 的相关概念和解释

设备和卷

设备是抽象在 MTD 上的概念,MTD 分区上首先需要格式化为 UBI 设备

uboot CMD:  ubi part

卷是 UBI 设备上的概念, ubi 设备上可以创建多个卷

uboot CMD: ubi create

对于 mkfs.ubifs 做成的镜像是 ubi 格式的。

需要使用 ubi write 或者 nand write.ubifs 烧写,具体没有测试

ubinize 可以将 ubi 格式的镜像转换为普通 nand write 可以烧写的 raw 镜像

注意有 PMECC 的情况需要去掉因为 ubinize  插值的 0xFF 。使用

nand write.trimffs 烧写。

U-Boot> set mtdids nand0=atmel_nand 
U-Boot> set mtdparts mtdparts=atmel_nand:8M(Bootstrap),125M(system),-(userdata) 
U-Boot> mtdparts

device nand0 <atmel_nand>, # parts = 3 
#: name                size            offset          mask_flags 
0: Bootstrap           0x00800000      0x00000000      0 
1: system              0x07d00000      0x00800000      0 
2: userdata            0x07b00000      0x08500000      0

active partition: nand0,0 - (Bootstrap) 0x00800000 @ 0x00000000

defaults: 
mtdids  : none 
mtdparts: none 
U-Boot> nand 
nand - NAND sub-system

Usage: 
nand info - show available NAND devices 
nand device [dev] - show or set current device 
nand read - addr off|partition size 
nand write - addr off|partition size 
    read/write 'size' bytes starting at offset 'off' 
    to/from memory address 'addr', skipping bad blocks. 
nand read.raw - addr off|partition [count] 
nand write.raw - addr off|partition [count] 
    Use read.raw/write.raw to avoid ECC and access the flash as-is. 
nand write.trimffs - addr off|partition size 
    write 'size' bytes starting at offset 'off' from memory address 
    'addr', skipping bad blocks and dropping any pages at the end 
    of eraseblocks that contain only 0xFF 
nand erase[.spread] [clean] off size - erase 'size' bytes from offset 'off' 
    With '.spread', erase enough for given file size, otherwise, 
    'size' includes skipped bad blocks. 
nand erase.part [clean] partition - erase entire mtd partition' 
nand erase.chip [clean] - erase entire chip' 
nand bad - show bad blocks 
nand dump[.oob] off - dump page 
nand scrub [-y] off size | scrub.part partition | scrub.chip 
    really clean NAND erasing bad blocks (UNSAFE) 
nand markbad off [...] - mark bad block(s) at offset (UNSAFE) 
nand biterr off - make a bit error at offset (UNSAFE) 
U-Boot> ubi part system 
Creating 1 MTD partitions on "nand0": 
0x000000800000-0x000008500000 : "mtd=1" 
UBI: attaching mtd1 to ubi0 
UBI: physical eraseblock size:   131072 bytes (128 KiB) 
UBI: logical eraseblock size:    126976 bytes 
UBI: smallest flash I/O unit:    2048 
UBI: VID header offset:          2048 (aligned 2048) 
UBI: data offset:                4096 
UBI: attached mtd1 to ubi0 
UBI: MTD device name:            "mtd=1" 
UBI: MTD device size:            125 MiB 
UBI: number of good PEBs:        1000 
UBI: number of bad PEBs:         0 
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:             123 
UBI: total number of reserved PEBs: 877 
UBI: number of PEBs reserved for bad PEB handling: 10 
UBI: max/mean erase counter: 1/0 
U-Boot> ubifsmount system 
UBIFS: mounted UBI device 0, volume 0, name "system" 
UBIFS: mounted read-only 
UBIFS: file system size:   108183552 bytes (105648 KiB, 103 MiB, 852 LEBs) 
UBIFS: journal size:       9023488 bytes (8812 KiB, 8 MiB, 72 LEBs) 
UBIFS: media format:       w4/r0 (latest is w4/r0) 
UBIFS: default compressor: LZO 
UBIFS: reserved for root:  0 bytes (0 KiB) 
U-Boot> ubi 
  ubi ubifsmount ubifsumount ubifsls ubifsload 
U-Boot> ubifsls 
<DIR>        3872  Tue Aug 06 03:36:31 2013  app 
<DIR>       11856  Tue Aug 06 03:30:01 2013  bin 
<DIR>        1752  Tue Aug 06 03:39:21 2013  etc 
<DIR>       12840  Tue Aug 06 03:39:20 2013  lib 
<DIR>         496  Tue Aug 06 03:03:59 2013  usr 
<DIR>        2296  Tue Aug 06 03:28:49 2013  xbin 
<DIR>        2048  Tue Aug 06 03:33:58 2013  framework 
            26340  Tue Aug 06 02:56:11 2013  initlogo.rle 
            19044  Tue Aug 06 02:56:11 2013  initlogo_pda.rle 
<DIR>        2096  Tue Aug 06 03:18:02 2013  fonts 
             1352  Tue Aug 06 02:40:59 2013  build.prop 
<DIR>         224  Tue Aug 06 03:27:29 2013  vendor 
U-Boot>

附件是 申波 给的示例

使用分区也可以成功:

done 
Bytes transferred = 113377280 (6c20000 hex) 
U-Boot> nand 
nand - NAND sub-system

Usage: 
nand info - show available NAND devices 
nand device [dev] - show or set current device 
nand read - addr off|partition size 
nand write - addr off|partition size 
    read/write 'size' bytes starting at offset 'off' 
    to/from memory address 'addr', skipping bad blocks. 
nand read.raw - addr off|partition [count] 
nand write.raw - addr off|partition [count] 
    Use read.raw/write.raw to avoid ECC and access the flash as-is. 
nand write.trimffs - addr off|partition size 
    write 'size' bytes starting at offset 'off' from memory address 
    'addr', skipping bad blocks and dropping any pages at the end 
    of eraseblocks that contain only 0xFF 
nand erase[.spread] [clean] off size - erase 'size' bytes from offset 'off' 
    With '.spread', erase enough for given file size, otherwise, 
    'size' includes skipped bad blocks. 
nand erase.part [clean] partition - erase entire mtd partition' 
nand erase.chip [clean] - erase entire chip' 
nand bad - show bad blocks 
nand dump[.oob] off - dump page 
nand scrub [-y] off size | scrub.part partition | scrub.chip 
    really clean NAND erasing bad blocks (UNSAFE) 
nand markbad off [...] - mark bad block(s) at offset (UNSAFE) 
nand biterr off - make a bit error at offset (UNSAFE) 
U-Boot> nand write.trimffs 0x22000000 system 0x6c20000

NAND write: device 0 offset 0x800000, size 0x6c20000 
113377280 bytes written: OK 
U-Boot> ubi part system 
Creating 1 MTD partitions on "nand0": 
0x000000800000-0x000008500000 : "mtd=1" 
UBI: attaching mtd1 to ubi0 
UBI: physical eraseblock size:   131072 bytes (128 KiB) 
UBI: logical eraseblock size:    126976 bytes 
UBI: smallest flash I/O unit:    2048 
UBI: VID header offset:          2048 (aligned 2048) 
UBI: data offset:                4096 
UBI: attached mtd1 to ubi0 
UBI: MTD device name:            "mtd=1" 
UBI: MTD device size:            125 MiB 
UBI: number of good PEBs:        1000 
UBI: number of bad PEBs:         0 
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:             123 
UBI: total number of reserved PEBs: 877 
UBI: number of PEBs reserved for bad PEB handling: 10 
UBI: max/mean erase counter: 1/0 
U-Boot> ubifsmount system 
UBIFS: mounted UBI device 0, volume 0, name "system" 
UBIFS: mounted read-only 
UBIFS: file system size:   108183552 bytes (105648 KiB, 103 MiB, 852 LEBs) 
UBIFS: journal size:       9023488 bytes (8812 KiB, 8 MiB, 72 LEBs) 
UBIFS: media format:       w4/r0 (latest is w4/r0) 
UBIFS: default compressor: LZO 
UBIFS: reserved for root:  0 bytes (0 KiB)

http://blog.csdn.net/jingxia2008/article/details/27536055

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值