howto.txt 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. How to use images in the new image format
  2. =========================================
  3. Author: Bartlomiej Sieka <tur@semihalf.com>
  4. Overview
  5. --------
  6. The new uImage format allows more flexibility in handling images of various
  7. types (kernel, ramdisk, etc.), it also enhances integrity protection of images
  8. with sha1 and md5 checksums.
  9. Two auxiliary tools are needed on the development host system in order to
  10. create an uImage in the new format: mkimage and dtc, although only one
  11. (mkimage) is invoked directly. dtc is called from within mkimage and operates
  12. behind the scenes, but needs to be present in the $PATH nevertheless. It is
  13. important that the dtc used has support for binary includes -- refer to
  14. git://git.kernel.org/pub/scm/utils/dtc/dtc.git
  15. for its latest version. mkimage (together with dtc) takes as input
  16. an image source file, which describes the contents of the image and defines
  17. its various properties used during booting. By convention, image source file
  18. has the ".its" extension, also, the details of its format are given in
  19. doc/uImage.FIT/source_file_format.txt. The actual data that is to be included in
  20. the uImage (kernel, ramdisk, etc.) is specified in the image source file in the
  21. form of paths to appropriate data files. The outcome of the image creation
  22. process is a binary file (by convention with the ".itb" extension) that
  23. contains all the referenced data (kernel, ramdisk, etc.) and other information
  24. needed by U-Boot to handle the uImage properly. The uImage file is then
  25. transferred to the target (e.g., via tftp) and booted using the bootm command.
  26. To summarize the prerequisites needed for new uImage creation:
  27. - mkimage
  28. - dtc (with support for binary includes)
  29. - image source file (*.its)
  30. - image data file(s)
  31. Here's a graphical overview of the image creation and booting process:
  32. image source file mkimage + dtc transfer to target
  33. + ---------------> image file --------------------> bootm
  34. image data file(s)
  35. Example 1 -- old-style (non-FDT) kernel booting
  36. -----------------------------------------------
  37. Consider a simple scenario, where a PPC Linux kernel built from sources on the
  38. development host is to be booted old-style (non-FDT) by U-Boot on an embedded
  39. target. Assume that the outcome of the build is vmlinux.bin.gz, a file which
  40. contains a gzip-compressed PPC Linux kernel (the only data file in this case).
  41. The uImage can be produced using the image source file
  42. doc/uImage.FIT/kernel.its (note that kernel.its assumes that vmlinux.bin.gz is
  43. in the current working directory; if desired, an alternative path can be
  44. specified in the kernel.its file). Here's how to create the image and inspect
  45. its contents:
  46. [on the host system]
  47. $ mkimage -f kernel.its kernel.itb
  48. DTC: dts->dtb on file "kernel.its"
  49. $
  50. $ mkimage -l kernel.itb
  51. FIT description: Simple image with single Linux kernel
  52. Created: Tue Mar 11 17:26:15 2008
  53. Image 0 (kernel@1)
  54. Description: Vanilla Linux kernel
  55. Type: Kernel Image
  56. Compression: gzip compressed
  57. Data Size: 943347 Bytes = 921.24 kB = 0.90 MB
  58. Architecture: PowerPC
  59. OS: Linux
  60. Load Address: 0x00000000
  61. Entry Point: 0x00000000
  62. Hash algo: crc32
  63. Hash value: 2ae2bb40
  64. Hash algo: sha1
  65. Hash value: 3c200f34e2c226ddc789240cca0c59fc54a67cf4
  66. Default Configuration: 'config@1'
  67. Configuration 0 (config@1)
  68. Description: Boot Linux kernel
  69. Kernel: kernel@1
  70. The resulting image file kernel.itb can be now transferred to the target,
  71. inspected and booted (note that first three U-Boot commands below are shown
  72. for completeness -- they are part of the standard booting procedure and not
  73. specific to the new image format).
  74. [on the target system]
  75. => print nfsargs
  76. nfsargs=setenv bootargs root=/dev/nfs rw nfsroot=${serverip}:${rootpath}
  77. => print addip
  78. addip=setenv bootargs ${bootargs} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}:${netdev}:off panic=1
  79. => run nfsargs addip
  80. => tftp 900000 /path/to/tftp/location/kernel.itb
  81. Using FEC device
  82. TFTP from server 192.168.1.1; our IP address is 192.168.160.5
  83. Filename '/path/to/tftp/location/kernel.itb'.
  84. Load address: 0x900000
  85. Loading: #################################################################
  86. done
  87. Bytes transferred = 944464 (e6950 hex)
  88. => iminfo
  89. ## Checking Image at 00900000 ...
  90. FIT image found
  91. FIT description: Simple image with single Linux kernel
  92. Created: 2008-03-11 16:26:15 UTC
  93. Image 0 (kernel@1)
  94. Description: Vanilla Linux kernel
  95. Type: Kernel Image
  96. Compression: gzip compressed
  97. Data Start: 0x009000e0
  98. Data Size: 943347 Bytes = 921.2 kB
  99. Architecture: PowerPC
  100. OS: Linux
  101. Load Address: 0x00000000
  102. Entry Point: 0x00000000
  103. Hash algo: crc32
  104. Hash value: 2ae2bb40
  105. Hash algo: sha1
  106. Hash value: 3c200f34e2c226ddc789240cca0c59fc54a67cf4
  107. Default Configuration: 'config@1'
  108. Configuration 0 (config@1)
  109. Description: Boot Linux kernel
  110. Kernel: kernel@1
  111. => bootm
  112. ## Booting kernel from FIT Image at 00900000 ...
  113. Using 'config@1' configuration
  114. Trying 'kernel@1' kernel subimage
  115. Description: Vanilla Linux kernel
  116. Type: Kernel Image
  117. Compression: gzip compressed
  118. Data Start: 0x009000e0
  119. Data Size: 943347 Bytes = 921.2 kB
  120. Architecture: PowerPC
  121. OS: Linux
  122. Load Address: 0x00000000
  123. Entry Point: 0x00000000
  124. Hash algo: crc32
  125. Hash value: 2ae2bb40
  126. Hash algo: sha1
  127. Hash value: 3c200f34e2c226ddc789240cca0c59fc54a67cf4
  128. Verifying Hash Integrity ... crc32+ sha1+ OK
  129. Uncompressing Kernel Image ... OK
  130. Memory BAT mapping: BAT2=256Mb, BAT3=0Mb, residual: 0Mb
  131. Linux version 2.4.25 (m8@hekate) (gcc version 4.0.0 (DENX ELDK 4.0 4.0.0)) #2 czw lip 5 17:56:18 CEST 2007
  132. On node 0 totalpages: 65536
  133. zone(0): 65536 pages.
  134. zone(1): 0 pages.
  135. zone(2): 0 pages.
  136. Kernel command line: root=/dev/nfs rw nfsroot=192.168.1.1:/opt/eldk-4.1/ppc_6xx ip=192.168.160.5:192.168.1.1::255.255.0.0:lite5200b:eth0:off panic=1
  137. Calibrating delay loop... 307.20 BogoMIPS
  138. Example 2 -- new-style (FDT) kernel booting
  139. -------------------------------------------
  140. Consider another simple scenario, where a PPC Linux kernel is to be booted
  141. new-style, i.e., with a FDT blob. In this case there are two prerequisite data
  142. files: vmlinux.bin.gz (Linux kernel) and target.dtb (FDT blob). The uImage can
  143. be produced using image source file doc/uImage.FIT/kernel_fdt.its like this
  144. (note again, that both prerequisite data files are assumed to be present in
  145. the current working directory -- image source file kernel_fdt.its can be
  146. modified to take the files from some other location if needed):
  147. [on the host system]
  148. $ mkimage -f kernel_fdt.its kernel_fdt.itb
  149. DTC: dts->dtb on file "kernel_fdt.its"
  150. $
  151. $ mkimage -l kernel_fdt.itb
  152. FIT description: Simple image with single Linux kernel and FDT blob
  153. Created: Tue Mar 11 16:29:22 2008
  154. Image 0 (kernel@1)
  155. Description: Vanilla Linux kernel
  156. Type: Kernel Image
  157. Compression: gzip compressed
  158. Data Size: 1092037 Bytes = 1066.44 kB = 1.04 MB
  159. Architecture: PowerPC
  160. OS: Linux
  161. Load Address: 0x00000000
  162. Entry Point: 0x00000000
  163. Hash algo: crc32
  164. Hash value: 2c0cc807
  165. Hash algo: sha1
  166. Hash value: 264b59935470e42c418744f83935d44cdf59a3bb
  167. Image 1 (fdt@1)
  168. Description: Flattened Device Tree blob
  169. Type: Flat Device Tree
  170. Compression: uncompressed
  171. Data Size: 16384 Bytes = 16.00 kB = 0.02 MB
  172. Architecture: PowerPC
  173. Hash algo: crc32
  174. Hash value: 0d655d71
  175. Hash algo: sha1
  176. Hash value: 25ab4e15cd4b8a5144610394560d9c318ce52def
  177. Default Configuration: 'conf@1'
  178. Configuration 0 (conf@1)
  179. Description: Boot Linux kernel with FDT blob
  180. Kernel: kernel@1
  181. FDT: fdt@1
  182. The resulting image file kernel_fdt.itb can be now transferred to the target,
  183. inspected and booted:
  184. [on the target system]
  185. => tftp 900000 /path/to/tftp/location/kernel_fdt.itb
  186. Using FEC device
  187. TFTP from server 192.168.1.1; our IP address is 192.168.160.5
  188. Filename '/path/to/tftp/location/kernel_fdt.itb'.
  189. Load address: 0x900000
  190. Loading: #################################################################
  191. ###########
  192. done
  193. Bytes transferred = 1109776 (10ef10 hex)
  194. => iminfo
  195. ## Checking Image at 00900000 ...
  196. FIT image found
  197. FIT description: Simple image with single Linux kernel and FDT blob
  198. Created: 2008-03-11 15:29:22 UTC
  199. Image 0 (kernel@1)
  200. Description: Vanilla Linux kernel
  201. Type: Kernel Image
  202. Compression: gzip compressed
  203. Data Start: 0x009000ec
  204. Data Size: 1092037 Bytes = 1 MB
  205. Architecture: PowerPC
  206. OS: Linux
  207. Load Address: 0x00000000
  208. Entry Point: 0x00000000
  209. Hash algo: crc32
  210. Hash value: 2c0cc807
  211. Hash algo: sha1
  212. Hash value: 264b59935470e42c418744f83935d44cdf59a3bb
  213. Image 1 (fdt@1)
  214. Description: Flattened Device Tree blob
  215. Type: Flat Device Tree
  216. Compression: uncompressed
  217. Data Start: 0x00a0abdc
  218. Data Size: 16384 Bytes = 16 kB
  219. Architecture: PowerPC
  220. Hash algo: crc32
  221. Hash value: 0d655d71
  222. Hash algo: sha1
  223. Hash value: 25ab4e15cd4b8a5144610394560d9c318ce52def
  224. Default Configuration: 'conf@1'
  225. Configuration 0 (conf@1)
  226. Description: Boot Linux kernel with FDT blob
  227. Kernel: kernel@1
  228. FDT: fdt@1
  229. => bootm
  230. ## Booting kernel from FIT Image at 00900000 ...
  231. Using 'conf@1' configuration
  232. Trying 'kernel@1' kernel subimage
  233. Description: Vanilla Linux kernel
  234. Type: Kernel Image
  235. Compression: gzip compressed
  236. Data Start: 0x009000ec
  237. Data Size: 1092037 Bytes = 1 MB
  238. Architecture: PowerPC
  239. OS: Linux
  240. Load Address: 0x00000000
  241. Entry Point: 0x00000000
  242. Hash algo: crc32
  243. Hash value: 2c0cc807
  244. Hash algo: sha1
  245. Hash value: 264b59935470e42c418744f83935d44cdf59a3bb
  246. Verifying Hash Integrity ... crc32+ sha1+ OK
  247. Uncompressing Kernel Image ... OK
  248. ## Flattened Device Tree from FIT Image at 00900000
  249. Using 'conf@1' configuration
  250. Trying 'fdt@1' FDT blob subimage
  251. Description: Flattened Device Tree blob
  252. Type: Flat Device Tree
  253. Compression: uncompressed
  254. Data Start: 0x00a0abdc
  255. Data Size: 16384 Bytes = 16 kB
  256. Architecture: PowerPC
  257. Hash algo: crc32
  258. Hash value: 0d655d71
  259. Hash algo: sha1
  260. Hash value: 25ab4e15cd4b8a5144610394560d9c318ce52def
  261. Verifying Hash Integrity ... crc32+ sha1+ OK
  262. Booting using the fdt blob at 0xa0abdc
  263. Loading Device Tree to 007fc000, end 007fffff ... OK
  264. [ 0.000000] Using lite5200 machine description
  265. [ 0.000000] Linux version 2.6.24-rc6-gaebecdfc (m8@hekate) (gcc version 4.0.0 (DENX ELDK 4.1 4.0.0)) #1 Sat Jan 12 15:38:48 CET 2008
  266. Example 3 -- advanced booting
  267. -----------------------------
  268. Refer to doc/uImage.FIT/multi.its for an image source file that allows more
  269. sophisticated booting scenarios (multiple kernels, ramdisks and fdt blobs).