howto.txt 11 KB

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