howto.txt 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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. SPL usage
  36. ---------
  37. The SPL can make use of the new image format as well, this traditionally
  38. is used to ship multiple device tree files within one image. Code in the SPL
  39. will choose the one matching the current board and append this to the
  40. U-Boot proper binary to be automatically used up by it.
  41. Aside from U-Boot proper and one device tree blob the SPL can load multiple,
  42. arbitrary image files as well. These binaries should be specified in their
  43. own subnode under the /images node, which should then be referenced from one or
  44. multiple /configurations subnodes. The required images must be enumerated in
  45. the "loadables" property as a list of strings.
  46. If a platform specific image source file (.its) is shipped with the U-Boot
  47. source, it can be specified using the CONFIG_SPL_FIT_SOURCE Kconfig symbol.
  48. In this case it will be automatically used by U-Boot's Makefile to generate
  49. the image.
  50. If a static source file is not flexible enough, CONFIG_SPL_FIT_GENERATOR
  51. can point to a script which generates this image source file during
  52. the build process. It gets passed a list of device tree files (taken from the
  53. CONFIG_OF_LIST symbol).
  54. Example 1 -- old-style (non-FDT) kernel booting
  55. -----------------------------------------------
  56. Consider a simple scenario, where a PPC Linux kernel built from sources on the
  57. development host is to be booted old-style (non-FDT) by U-Boot on an embedded
  58. target. Assume that the outcome of the build is vmlinux.bin.gz, a file which
  59. contains a gzip-compressed PPC Linux kernel (the only data file in this case).
  60. The uImage can be produced using the image source file
  61. doc/uImage.FIT/kernel.its (note that kernel.its assumes that vmlinux.bin.gz is
  62. in the current working directory; if desired, an alternative path can be
  63. specified in the kernel.its file). Here's how to create the image and inspect
  64. its contents:
  65. [on the host system]
  66. $ mkimage -f kernel.its kernel.itb
  67. DTC: dts->dtb on file "kernel.its"
  68. $
  69. $ mkimage -l kernel.itb
  70. FIT description: Simple image with single Linux kernel
  71. Created: Tue Mar 11 17:26:15 2008
  72. Image 0 (kernel)
  73. Description: Vanilla Linux kernel
  74. Type: Kernel Image
  75. Compression: gzip compressed
  76. Data Size: 943347 Bytes = 921.24 kB = 0.90 MB
  77. Architecture: PowerPC
  78. OS: Linux
  79. Load Address: 0x00000000
  80. Entry Point: 0x00000000
  81. Hash algo: crc32
  82. Hash value: 2ae2bb40
  83. Hash algo: sha1
  84. Hash value: 3c200f34e2c226ddc789240cca0c59fc54a67cf4
  85. Default Configuration: 'config-1'
  86. Configuration 0 (config-1)
  87. Description: Boot Linux kernel
  88. Kernel: kernel
  89. The resulting image file kernel.itb can be now transferred to the target,
  90. inspected and booted (note that first three U-Boot commands below are shown
  91. for completeness -- they are part of the standard booting procedure and not
  92. specific to the new image format).
  93. [on the target system]
  94. => print nfsargs
  95. nfsargs=setenv bootargs root=/dev/nfs rw nfsroot=${serverip}:${rootpath}
  96. => print addip
  97. addip=setenv bootargs ${bootargs} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}:${netdev}:off panic=1
  98. => run nfsargs addip
  99. => tftp 900000 /path/to/tftp/location/kernel.itb
  100. Using FEC device
  101. TFTP from server 192.168.1.1; our IP address is 192.168.160.5
  102. Filename '/path/to/tftp/location/kernel.itb'.
  103. Load address: 0x900000
  104. Loading: #################################################################
  105. done
  106. Bytes transferred = 944464 (e6950 hex)
  107. => iminfo
  108. ## Checking Image at 00900000 ...
  109. FIT image found
  110. FIT description: Simple image with single Linux kernel
  111. Created: 2008-03-11 16:26:15 UTC
  112. Image 0 (kernel)
  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. Default Configuration: 'config-1'
  127. Configuration 0 (config-1)
  128. Description: Boot Linux kernel
  129. Kernel: kernel
  130. => bootm
  131. ## Booting kernel from FIT Image at 00900000 ...
  132. Using 'config-1' configuration
  133. Trying 'kernel' kernel subimage
  134. Description: Vanilla Linux kernel
  135. Type: Kernel Image
  136. Compression: gzip compressed
  137. Data Start: 0x009000e0
  138. Data Size: 943347 Bytes = 921.2 kB
  139. Architecture: PowerPC
  140. OS: Linux
  141. Load Address: 0x00000000
  142. Entry Point: 0x00000000
  143. Hash algo: crc32
  144. Hash value: 2ae2bb40
  145. Hash algo: sha1
  146. Hash value: 3c200f34e2c226ddc789240cca0c59fc54a67cf4
  147. Verifying Hash Integrity ... crc32+ sha1+ OK
  148. Uncompressing Kernel Image ... OK
  149. Memory BAT mapping: BAT2=256Mb, BAT3=0Mb, residual: 0Mb
  150. 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
  151. On node 0 totalpages: 65536
  152. zone(0): 65536 pages.
  153. zone(1): 0 pages.
  154. zone(2): 0 pages.
  155. 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
  156. Calibrating delay loop... 307.20 BogoMIPS
  157. Example 2 -- new-style (FDT) kernel booting
  158. -------------------------------------------
  159. Consider another simple scenario, where a PPC Linux kernel is to be booted
  160. new-style, i.e., with a FDT blob. In this case there are two prerequisite data
  161. files: vmlinux.bin.gz (Linux kernel) and target.dtb (FDT blob). The uImage can
  162. be produced using image source file doc/uImage.FIT/kernel_fdt.its like this
  163. (note again, that both prerequisite data files are assumed to be present in
  164. the current working directory -- image source file kernel_fdt.its can be
  165. modified to take the files from some other location if needed):
  166. [on the host system]
  167. $ mkimage -f kernel_fdt.its kernel_fdt.itb
  168. DTC: dts->dtb on file "kernel_fdt.its"
  169. $
  170. $ mkimage -l kernel_fdt.itb
  171. FIT description: Simple image with single Linux kernel and FDT blob
  172. Created: Tue Mar 11 16:29:22 2008
  173. Image 0 (kernel)
  174. Description: Vanilla Linux kernel
  175. Type: Kernel Image
  176. Compression: gzip compressed
  177. Data Size: 1092037 Bytes = 1066.44 kB = 1.04 MB
  178. Architecture: PowerPC
  179. OS: Linux
  180. Load Address: 0x00000000
  181. Entry Point: 0x00000000
  182. Hash algo: crc32
  183. Hash value: 2c0cc807
  184. Hash algo: sha1
  185. Hash value: 264b59935470e42c418744f83935d44cdf59a3bb
  186. Image 1 (fdt-1)
  187. Description: Flattened Device Tree blob
  188. Type: Flat Device Tree
  189. Compression: uncompressed
  190. Data Size: 16384 Bytes = 16.00 kB = 0.02 MB
  191. Architecture: PowerPC
  192. Hash algo: crc32
  193. Hash value: 0d655d71
  194. Hash algo: sha1
  195. Hash value: 25ab4e15cd4b8a5144610394560d9c318ce52def
  196. Default Configuration: 'conf-1'
  197. Configuration 0 (conf-1)
  198. Description: Boot Linux kernel with FDT blob
  199. Kernel: kernel
  200. FDT: fdt-1
  201. The resulting image file kernel_fdt.itb can be now transferred to the target,
  202. inspected and booted:
  203. [on the target system]
  204. => tftp 900000 /path/to/tftp/location/kernel_fdt.itb
  205. Using FEC device
  206. TFTP from server 192.168.1.1; our IP address is 192.168.160.5
  207. Filename '/path/to/tftp/location/kernel_fdt.itb'.
  208. Load address: 0x900000
  209. Loading: #################################################################
  210. ###########
  211. done
  212. Bytes transferred = 1109776 (10ef10 hex)
  213. => iminfo
  214. ## Checking Image at 00900000 ...
  215. FIT image found
  216. FIT description: Simple image with single Linux kernel and FDT blob
  217. Created: 2008-03-11 15:29:22 UTC
  218. Image 0 (kernel)
  219. Description: Vanilla Linux kernel
  220. Type: Kernel Image
  221. Compression: gzip compressed
  222. Data Start: 0x009000ec
  223. Data Size: 1092037 Bytes = 1 MB
  224. Architecture: PowerPC
  225. OS: Linux
  226. Load Address: 0x00000000
  227. Entry Point: 0x00000000
  228. Hash algo: crc32
  229. Hash value: 2c0cc807
  230. Hash algo: sha1
  231. Hash value: 264b59935470e42c418744f83935d44cdf59a3bb
  232. Image 1 (fdt-1)
  233. Description: Flattened Device Tree blob
  234. Type: Flat Device Tree
  235. Compression: uncompressed
  236. Data Start: 0x00a0abdc
  237. Data Size: 16384 Bytes = 16 kB
  238. Architecture: PowerPC
  239. Hash algo: crc32
  240. Hash value: 0d655d71
  241. Hash algo: sha1
  242. Hash value: 25ab4e15cd4b8a5144610394560d9c318ce52def
  243. Default Configuration: 'conf-1'
  244. Configuration 0 (conf-1)
  245. Description: Boot Linux kernel with FDT blob
  246. Kernel: kernel
  247. FDT: fdt-1
  248. => bootm
  249. ## Booting kernel from FIT Image at 00900000 ...
  250. Using 'conf-1' configuration
  251. Trying 'kernel' kernel subimage
  252. Description: Vanilla Linux kernel
  253. Type: Kernel Image
  254. Compression: gzip compressed
  255. Data Start: 0x009000ec
  256. Data Size: 1092037 Bytes = 1 MB
  257. Architecture: PowerPC
  258. OS: Linux
  259. Load Address: 0x00000000
  260. Entry Point: 0x00000000
  261. Hash algo: crc32
  262. Hash value: 2c0cc807
  263. Hash algo: sha1
  264. Hash value: 264b59935470e42c418744f83935d44cdf59a3bb
  265. Verifying Hash Integrity ... crc32+ sha1+ OK
  266. Uncompressing Kernel Image ... OK
  267. ## Flattened Device Tree from FIT Image at 00900000
  268. Using 'conf-1' configuration
  269. Trying 'fdt-1' FDT blob subimage
  270. Description: Flattened Device Tree blob
  271. Type: Flat Device Tree
  272. Compression: uncompressed
  273. Data Start: 0x00a0abdc
  274. Data Size: 16384 Bytes = 16 kB
  275. Architecture: PowerPC
  276. Hash algo: crc32
  277. Hash value: 0d655d71
  278. Hash algo: sha1
  279. Hash value: 25ab4e15cd4b8a5144610394560d9c318ce52def
  280. Verifying Hash Integrity ... crc32+ sha1+ OK
  281. Booting using the fdt blob at 0xa0abdc
  282. Loading Device Tree to 007fc000, end 007fffff ... OK
  283. [ 0.000000] Using lite5200 machine description
  284. [ 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
  285. Example 3 -- advanced booting
  286. -----------------------------
  287. Refer to doc/uImage.FIT/multi.its for an image source file that allows more
  288. sophisticated booting scenarios (multiple kernels, ramdisks and fdt blobs).