README.ubi 4.6 KB

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