README.ubi 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. -------------------
  2. UBI usage in U-Boot
  3. -------------------
  4. UBI support in U-Boot is broken down into five separate commands.
  5. The first is the ubi command, which has six subcommands:
  6. => help ubi
  7. ubi - ubi commands
  8. Usage:
  9. ubi part [part] [offset]
  10. - Show or set current partition (with optional VID header offset)
  11. ubi info [l[ayout]] - Display volume and ubi layout information
  12. ubi create[vol] volume [size] [type] - create volume name with size
  13. ubi write[vol] address volume size - Write volume from address with size
  14. ubi read[vol] address volume [size] - Read volume to address with size
  15. ubi remove[vol] volume - Remove volume
  16. [Legends]
  17. volume: character name
  18. size: specified in bytes
  19. type: s[tatic] or d[ynamic] (default=dynamic)
  20. The first command that is needed to be issues is "ubi part" to connect
  21. one mtd partition to the UBI subsystem. This command will either create
  22. a new UBI device on the requested MTD partition. Or it will attach a
  23. previously created UBI device. The other UBI commands will only work
  24. when such a UBI device is attached (via "ubi part"). Here an example:
  25. => mtdparts
  26. device nor0 <1fc000000.nor_flash>, # parts = 6
  27. #: name size offset mask_flags
  28. 0: kernel 0x00200000 0x00000000 0
  29. 1: dtb 0x00040000 0x00200000 0
  30. 2: root 0x00200000 0x00240000 0
  31. 3: user 0x01ac0000 0x00440000 0
  32. 4: env 0x00080000 0x01f00000 0
  33. 5: u-boot 0x00080000 0x01f80000 0
  34. active partition: nor0,0 - (kernel) 0x00200000 @ 0x00000000
  35. defaults:
  36. mtdids : nor0=1fc000000.nor_flash
  37. mtdparts: mtdparts=1fc000000.nor_flash:2m(kernel),256k(dtb),2m(root),27392k(user),512k(env),512k(u-boot)
  38. => ubi part root
  39. Creating 1 MTD partitions on "nor0":
  40. 0x000000240000-0x000000440000 : "mtd=2"
  41. UBI: attaching mtd1 to ubi0
  42. UBI: physical eraseblock size: 262144 bytes (256 KiB)
  43. UBI: logical eraseblock size: 262016 bytes
  44. UBI: smallest flash I/O unit: 1
  45. UBI: VID header offset: 64 (aligned 64)
  46. UBI: data offset: 128
  47. UBI: attached mtd1 to ubi0
  48. UBI: MTD device name: "mtd=2"
  49. UBI: MTD device size: 2 MiB
  50. UBI: number of good PEBs: 8
  51. UBI: number of bad PEBs: 0
  52. UBI: max. allowed volumes: 128
  53. UBI: wear-leveling threshold: 4096
  54. UBI: number of internal volumes: 1
  55. UBI: number of user volumes: 1
  56. UBI: available PEBs: 0
  57. UBI: total number of reserved PEBs: 8
  58. UBI: number of PEBs reserved for bad PEB handling: 0
  59. UBI: max/mean erase counter: 2/1
  60. Now that the UBI device is attached, this device can be modified
  61. using the following commands:
  62. ubi info Display volume and ubi layout information
  63. ubi createvol Create UBI volume on UBI device
  64. ubi removevol Remove UBI volume from UBI device
  65. ubi read Read data from UBI volume to memory
  66. ubi write Write data from memory to UBI volume
  67. Here a few examples on the usage:
  68. => ubi create testvol
  69. Creating dynamic volume testvol of size 1048064
  70. => ubi info l
  71. UBI: volume information dump:
  72. UBI: vol_id 0
  73. UBI: reserved_pebs 4
  74. UBI: alignment 1
  75. UBI: data_pad 0
  76. UBI: vol_type 3
  77. UBI: name_len 7
  78. UBI: usable_leb_size 262016
  79. UBI: used_ebs 4
  80. UBI: used_bytes 1048064
  81. UBI: last_eb_bytes 262016
  82. UBI: corrupted 0
  83. UBI: upd_marker 0
  84. UBI: name testvol
  85. UBI: volume information dump:
  86. UBI: vol_id 2147479551
  87. UBI: reserved_pebs 2
  88. UBI: alignment 1
  89. UBI: data_pad 0
  90. UBI: vol_type 3
  91. UBI: name_len 13
  92. UBI: usable_leb_size 262016
  93. UBI: used_ebs 2
  94. UBI: used_bytes 524032
  95. UBI: last_eb_bytes 2
  96. UBI: corrupted 0
  97. UBI: upd_marker 0
  98. UBI: name layout volume
  99. => ubi info
  100. UBI: MTD device name: "mtd=2"
  101. UBI: MTD device size: 2 MiB
  102. UBI: physical eraseblock size: 262144 bytes (256 KiB)
  103. UBI: logical eraseblock size: 262016 bytes
  104. UBI: number of good PEBs: 8
  105. UBI: number of bad PEBs: 0
  106. UBI: smallest flash I/O unit: 1
  107. UBI: VID header offset: 64 (aligned 64)
  108. UBI: data offset: 128
  109. UBI: max. allowed volumes: 128
  110. UBI: wear-leveling threshold: 4096
  111. UBI: number of internal volumes: 1
  112. UBI: number of user volumes: 1
  113. UBI: available PEBs: 0
  114. UBI: total number of reserved PEBs: 8
  115. UBI: number of PEBs reserved for bad PEB handling: 0
  116. UBI: max/mean erase counter: 4/1
  117. => ubi write 800000 testvol 80000
  118. Volume "testvol" found at volume id 0
  119. => ubi read 900000 testvol 80000
  120. Volume testvol found at volume id 0
  121. read 524288 bytes from volume 0 to 900000(buf address)
  122. => cmp.b 800000 900000 80000
  123. Total of 524288 bytes were the same
  124. Next, the ubifsmount command allows you to access filesystems on the
  125. UBI partition which has been attached with the ubi part command:
  126. => help ubifsmount
  127. ubifsmount - mount UBIFS volume
  128. Usage:
  129. ubifsmount <volume-name>
  130. - mount 'volume-name' volume
  131. For example:
  132. => ubifsmount ubi0:recovery
  133. UBIFS: mounted UBI device 0, volume 0, name "recovery"
  134. UBIFS: mounted read-only
  135. UBIFS: file system size: 46473216 bytes (45384 KiB, 44 MiB, 366 LEBs)
  136. UBIFS: journal size: 6348800 bytes (6200 KiB, 6 MiB, 50 LEBs)
  137. UBIFS: media format: w4/r0 (latest is w4/r0)
  138. UBIFS: default compressor: LZO
  139. UBIFS: reserved for root: 0 bytes (0 KiB)
  140. Note that unlike Linux, U-Boot can only have one active UBI partition
  141. at a time, which can be referred to as ubi0, and must be supplied along
  142. with the name of the filesystem you are mounting.
  143. Once a UBI filesystem has been mounted, the ubifsls command allows you
  144. to list the contents of a directory in the filesystem:
  145. => help ubifsls
  146. ubifsls - list files in a directory
  147. Usage:
  148. ubifsls [directory]
  149. - list files in a 'directory' (default '/')
  150. For example:
  151. => ubifsls
  152. 17442 Thu Jan 01 02:57:38 1970 imx28-evk.dtb
  153. 2998146 Thu Jan 01 02:57:43 1970 zImage
  154. And the ubifsload command allows you to load a file from a UBI
  155. filesystem:
  156. => help ubifsload
  157. ubifsload - load file from an UBIFS filesystem
  158. Usage:
  159. ubifsload <addr> <filename> [bytes]
  160. - load file 'filename' to address 'addr'
  161. For example:
  162. => ubifsload ${loadaddr} zImage
  163. Loading file 'zImage' to addr 0x42000000 with size 2998146 (0x002dbf82)...
  164. Done
  165. Finally, you can unmount the UBI filesystem with the ubifsumount
  166. command:
  167. => help ubifsumount
  168. ubifsumount - unmount UBIFS volume
  169. Usage:
  170. ubifsumount - unmount current volume
  171. For example:
  172. => ubifsumount
  173. Unmounting UBIFS volume recovery!