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