Stefan Roese | 03cf0a7 | 2010-10-19 14:58:02 +0200 | [diff] [blame] | 1 | ------------------- |
| 2 | UBI usage in U-Boot |
| 3 | ------------------- |
| 4 | |
| 5 | Here the list of the currently implemented UBI commands: |
| 6 | |
| 7 | => help ubi |
| 8 | ubi - ubi commands |
| 9 | |
| 10 | Usage: |
| 11 | ubi part [part] [offset] |
| 12 | - Show or set current partition (with optional VID header offset) |
| 13 | ubi info [l[ayout]] - Display volume and ubi layout information |
| 14 | ubi create[vol] volume [size] [type] - create volume name with size |
| 15 | ubi write[vol] address volume size - Write volume from address with size |
| 16 | ubi read[vol] address volume [size] - Read volume to address with size |
| 17 | ubi remove[vol] volume - Remove volume |
| 18 | [Legends] |
| 19 | volume: character name |
| 20 | size: specified in bytes |
| 21 | type: s[tatic] or d[ynamic] (default=dynamic) |
| 22 | |
| 23 | |
| 24 | The first command that is needed to be issues is "ubi part" to connect |
| 25 | one mtd partition to the UBI subsystem. This command will either create |
| 26 | a new UBI device on the requested MTD partition. Or it will attach a |
| 27 | previously created UBI device. The other UBI commands will only work |
| 28 | when such a UBI device is attached (via "ubi part"). Here an example: |
| 29 | |
| 30 | => mtdparts |
| 31 | |
| 32 | device nor0 <1fc000000.nor_flash>, # parts = 6 |
| 33 | #: name size offset mask_flags |
| 34 | 0: kernel 0x00200000 0x00000000 0 |
| 35 | 1: dtb 0x00040000 0x00200000 0 |
| 36 | 2: root 0x00200000 0x00240000 0 |
| 37 | 3: user 0x01ac0000 0x00440000 0 |
| 38 | 4: env 0x00080000 0x01f00000 0 |
| 39 | 5: u-boot 0x00080000 0x01f80000 0 |
| 40 | |
| 41 | active partition: nor0,0 - (kernel) 0x00200000 @ 0x00000000 |
| 42 | |
| 43 | defaults: |
| 44 | mtdids : nor0=1fc000000.nor_flash |
| 45 | mtdparts: mtdparts=1fc000000.nor_flash:2m(kernel),256k(dtb),2m(root),27392k(user),512k(env),512k(u-boot) |
| 46 | |
| 47 | => ubi part root |
| 48 | Creating 1 MTD partitions on "nor0": |
| 49 | 0x000000240000-0x000000440000 : "mtd=2" |
| 50 | UBI: attaching mtd1 to ubi0 |
| 51 | UBI: physical eraseblock size: 262144 bytes (256 KiB) |
| 52 | UBI: logical eraseblock size: 262016 bytes |
| 53 | UBI: smallest flash I/O unit: 1 |
| 54 | UBI: VID header offset: 64 (aligned 64) |
| 55 | UBI: data offset: 128 |
| 56 | UBI: attached mtd1 to ubi0 |
| 57 | UBI: MTD device name: "mtd=2" |
| 58 | UBI: MTD device size: 2 MiB |
| 59 | UBI: number of good PEBs: 8 |
| 60 | UBI: number of bad PEBs: 0 |
| 61 | UBI: max. allowed volumes: 128 |
| 62 | UBI: wear-leveling threshold: 4096 |
| 63 | UBI: number of internal volumes: 1 |
| 64 | UBI: number of user volumes: 1 |
| 65 | UBI: available PEBs: 0 |
| 66 | UBI: total number of reserved PEBs: 8 |
| 67 | UBI: number of PEBs reserved for bad PEB handling: 0 |
| 68 | UBI: max/mean erase counter: 2/1 |
| 69 | |
| 70 | |
| 71 | Now that the UBI device is attached, this device can be modified |
| 72 | using the following commands: |
| 73 | |
| 74 | ubi info Display volume and ubi layout information |
| 75 | ubi createvol Create UBI volume on UBI device |
| 76 | ubi removevol Remove UBI volume from UBI device |
| 77 | ubi read Read data from UBI volume to memory |
| 78 | ubi write Write data from memory to UBI volume |
| 79 | |
| 80 | |
| 81 | Here a few examples on the usage: |
| 82 | |
| 83 | => ubi create testvol |
| 84 | Creating dynamic volume testvol of size 1048064 |
| 85 | |
| 86 | => ubi info l |
| 87 | UBI: volume information dump: |
| 88 | UBI: vol_id 0 |
| 89 | UBI: reserved_pebs 4 |
| 90 | UBI: alignment 1 |
| 91 | UBI: data_pad 0 |
| 92 | UBI: vol_type 3 |
| 93 | UBI: name_len 7 |
| 94 | UBI: usable_leb_size 262016 |
| 95 | UBI: used_ebs 4 |
| 96 | UBI: used_bytes 1048064 |
| 97 | UBI: last_eb_bytes 262016 |
| 98 | UBI: corrupted 0 |
| 99 | UBI: upd_marker 0 |
| 100 | UBI: name testvol |
| 101 | |
| 102 | UBI: volume information dump: |
| 103 | UBI: vol_id 2147479551 |
| 104 | UBI: reserved_pebs 2 |
| 105 | UBI: alignment 1 |
| 106 | UBI: data_pad 0 |
| 107 | UBI: vol_type 3 |
| 108 | UBI: name_len 13 |
| 109 | UBI: usable_leb_size 262016 |
| 110 | UBI: used_ebs 2 |
| 111 | UBI: used_bytes 524032 |
| 112 | UBI: last_eb_bytes 2 |
| 113 | UBI: corrupted 0 |
| 114 | UBI: upd_marker 0 |
| 115 | UBI: name layout volume |
| 116 | |
| 117 | => ubi info |
| 118 | UBI: MTD device name: "mtd=2" |
| 119 | UBI: MTD device size: 2 MiB |
| 120 | UBI: physical eraseblock size: 262144 bytes (256 KiB) |
| 121 | UBI: logical eraseblock size: 262016 bytes |
| 122 | UBI: number of good PEBs: 8 |
| 123 | UBI: number of bad PEBs: 0 |
| 124 | UBI: smallest flash I/O unit: 1 |
| 125 | UBI: VID header offset: 64 (aligned 64) |
| 126 | UBI: data offset: 128 |
| 127 | UBI: max. allowed volumes: 128 |
| 128 | UBI: wear-leveling threshold: 4096 |
| 129 | UBI: number of internal volumes: 1 |
| 130 | UBI: number of user volumes: 1 |
| 131 | UBI: available PEBs: 0 |
| 132 | UBI: total number of reserved PEBs: 8 |
| 133 | UBI: number of PEBs reserved for bad PEB handling: 0 |
| 134 | UBI: max/mean erase counter: 4/1 |
| 135 | |
| 136 | => ubi write 800000 testvol 80000 |
| 137 | Volume "testvol" found at volume id 0 |
| 138 | |
| 139 | => ubi read 900000 testvol 80000 |
| 140 | Volume testvol found at volume id 0 |
| 141 | read 524288 bytes from volume 0 to 900000(buf address) |
| 142 | |
| 143 | => cmp.b 800000 900000 80000 |
| 144 | Total of 524288 bytes were the same |