howto.txt 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  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. The SPL also records to a DT all additional images (called loadables) which are
  55. loaded. The information about loadables locations is passed via the DT node with
  56. fit-images name.
  57. Loadables Example
  58. -----------------
  59. Consider the following case for an ARM64 platform where U-Boot runs in EL2
  60. started by ATF where SPL is loading U-Boot (as loadables) and ATF (as firmware).
  61. /dts-v1/;
  62. / {
  63. description = "Configuration to load ATF before U-Boot";
  64. images {
  65. uboot {
  66. description = "U-Boot (64-bit)";
  67. data = /incbin/("u-boot-nodtb.bin");
  68. type = "firmware";
  69. os = "u-boot";
  70. arch = "arm64";
  71. compression = "none";
  72. load = <0x8 0x8000000>;
  73. entry = <0x8 0x8000000>;
  74. hash {
  75. algo = "md5";
  76. };
  77. };
  78. atf {
  79. description = "ARM Trusted Firmware";
  80. data = /incbin/("bl31.bin");
  81. type = "firmware";
  82. os = "arm-trusted-firmware";
  83. arch = "arm64";
  84. compression = "none";
  85. load = <0xfffea000>;
  86. entry = <0xfffea000>;
  87. hash {
  88. algo = "md5";
  89. };
  90. };
  91. fdt_1 {
  92. description = "zynqmp-zcu102-revA";
  93. data = /incbin/("arch/arm/dts/zynqmp-zcu102-revA.dtb");
  94. type = "flat_dt";
  95. arch = "arm64";
  96. compression = "none";
  97. load = <0x100000>;
  98. hash {
  99. algo = "md5";
  100. };
  101. };
  102. };
  103. configurations {
  104. default = "config_1";
  105. config_1 {
  106. description = "zynqmp-zcu102-revA";
  107. firmware = "atf";
  108. loadables = "uboot";
  109. fdt = "fdt_1";
  110. };
  111. };
  112. };
  113. In this case the SPL records via fit-images DT node the information about
  114. loadables U-Boot image.
  115. ZynqMP> fdt addr $fdtcontroladdr
  116. ZynqMP> fdt print /fit-images
  117. fit-images {
  118. uboot {
  119. os = "u-boot";
  120. type = "firmware";
  121. size = <0x001017c8>;
  122. entry = <0x00000008 0x08000000>;
  123. load = <0x00000008 0x08000000>;
  124. };
  125. };
  126. As you can see entry and load properties are 64bit wide to support loading
  127. images above 4GB (in past entry and load properties where just 32bit).
  128. Example 1 -- old-style (non-FDT) kernel booting
  129. -----------------------------------------------
  130. Consider a simple scenario, where a PPC Linux kernel built from sources on the
  131. development host is to be booted old-style (non-FDT) by U-Boot on an embedded
  132. target. Assume that the outcome of the build is vmlinux.bin.gz, a file which
  133. contains a gzip-compressed PPC Linux kernel (the only data file in this case).
  134. The uImage can be produced using the image source file
  135. doc/uImage.FIT/kernel.its (note that kernel.its assumes that vmlinux.bin.gz is
  136. in the current working directory; if desired, an alternative path can be
  137. specified in the kernel.its file). Here's how to create the image and inspect
  138. its contents:
  139. [on the host system]
  140. $ mkimage -f kernel.its kernel.itb
  141. DTC: dts->dtb on file "kernel.its"
  142. $
  143. $ mkimage -l kernel.itb
  144. FIT description: Simple image with single Linux kernel
  145. Created: Tue Mar 11 17:26:15 2008
  146. Image 0 (kernel)
  147. Description: Vanilla Linux kernel
  148. Type: Kernel Image
  149. Compression: gzip compressed
  150. Data Size: 943347 Bytes = 921.24 kB = 0.90 MB
  151. Architecture: PowerPC
  152. OS: Linux
  153. Load Address: 0x00000000
  154. Entry Point: 0x00000000
  155. Hash algo: crc32
  156. Hash value: 2ae2bb40
  157. Hash algo: sha1
  158. Hash value: 3c200f34e2c226ddc789240cca0c59fc54a67cf4
  159. Default Configuration: 'config-1'
  160. Configuration 0 (config-1)
  161. Description: Boot Linux kernel
  162. Kernel: kernel
  163. The resulting image file kernel.itb can be now transferred to the target,
  164. inspected and booted (note that first three U-Boot commands below are shown
  165. for completeness -- they are part of the standard booting procedure and not
  166. specific to the new image format).
  167. [on the target system]
  168. => print nfsargs
  169. nfsargs=setenv bootargs root=/dev/nfs rw nfsroot=${serverip}:${rootpath}
  170. => print addip
  171. addip=setenv bootargs ${bootargs} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}:${netdev}:off panic=1
  172. => run nfsargs addip
  173. => tftp 900000 /path/to/tftp/location/kernel.itb
  174. Using FEC device
  175. TFTP from server 192.168.1.1; our IP address is 192.168.160.5
  176. Filename '/path/to/tftp/location/kernel.itb'.
  177. Load address: 0x900000
  178. Loading: #################################################################
  179. done
  180. Bytes transferred = 944464 (e6950 hex)
  181. => iminfo
  182. ## Checking Image at 00900000 ...
  183. FIT image found
  184. FIT description: Simple image with single Linux kernel
  185. Created: 2008-03-11 16:26:15 UTC
  186. Image 0 (kernel)
  187. Description: Vanilla Linux kernel
  188. Type: Kernel Image
  189. Compression: gzip compressed
  190. Data Start: 0x009000e0
  191. Data Size: 943347 Bytes = 921.2 kB
  192. Architecture: PowerPC
  193. OS: Linux
  194. Load Address: 0x00000000
  195. Entry Point: 0x00000000
  196. Hash algo: crc32
  197. Hash value: 2ae2bb40
  198. Hash algo: sha1
  199. Hash value: 3c200f34e2c226ddc789240cca0c59fc54a67cf4
  200. Default Configuration: 'config-1'
  201. Configuration 0 (config-1)
  202. Description: Boot Linux kernel
  203. Kernel: kernel
  204. => bootm
  205. ## Booting kernel from FIT Image at 00900000 ...
  206. Using 'config-1' configuration
  207. Trying 'kernel' kernel subimage
  208. Description: Vanilla Linux kernel
  209. Type: Kernel Image
  210. Compression: gzip compressed
  211. Data Start: 0x009000e0
  212. Data Size: 943347 Bytes = 921.2 kB
  213. Architecture: PowerPC
  214. OS: Linux
  215. Load Address: 0x00000000
  216. Entry Point: 0x00000000
  217. Hash algo: crc32
  218. Hash value: 2ae2bb40
  219. Hash algo: sha1
  220. Hash value: 3c200f34e2c226ddc789240cca0c59fc54a67cf4
  221. Verifying Hash Integrity ... crc32+ sha1+ OK
  222. Uncompressing Kernel Image ... OK
  223. Memory BAT mapping: BAT2=256Mb, BAT3=0Mb, residual: 0Mb
  224. 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
  225. On node 0 totalpages: 65536
  226. zone(0): 65536 pages.
  227. zone(1): 0 pages.
  228. zone(2): 0 pages.
  229. 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
  230. Calibrating delay loop... 307.20 BogoMIPS
  231. Example 2 -- new-style (FDT) kernel booting
  232. -------------------------------------------
  233. Consider another simple scenario, where a PPC Linux kernel is to be booted
  234. new-style, i.e., with a FDT blob. In this case there are two prerequisite data
  235. files: vmlinux.bin.gz (Linux kernel) and target.dtb (FDT blob). The uImage can
  236. be produced using image source file doc/uImage.FIT/kernel_fdt.its like this
  237. (note again, that both prerequisite data files are assumed to be present in
  238. the current working directory -- image source file kernel_fdt.its can be
  239. modified to take the files from some other location if needed):
  240. [on the host system]
  241. $ mkimage -f kernel_fdt.its kernel_fdt.itb
  242. DTC: dts->dtb on file "kernel_fdt.its"
  243. $
  244. $ mkimage -l kernel_fdt.itb
  245. FIT description: Simple image with single Linux kernel and FDT blob
  246. Created: Tue Mar 11 16:29:22 2008
  247. Image 0 (kernel)
  248. Description: Vanilla Linux kernel
  249. Type: Kernel Image
  250. Compression: gzip compressed
  251. Data Size: 1092037 Bytes = 1066.44 kB = 1.04 MB
  252. Architecture: PowerPC
  253. OS: Linux
  254. Load Address: 0x00000000
  255. Entry Point: 0x00000000
  256. Hash algo: crc32
  257. Hash value: 2c0cc807
  258. Hash algo: sha1
  259. Hash value: 264b59935470e42c418744f83935d44cdf59a3bb
  260. Image 1 (fdt-1)
  261. Description: Flattened Device Tree blob
  262. Type: Flat Device Tree
  263. Compression: uncompressed
  264. Data Size: 16384 Bytes = 16.00 kB = 0.02 MB
  265. Architecture: PowerPC
  266. Hash algo: crc32
  267. Hash value: 0d655d71
  268. Hash algo: sha1
  269. Hash value: 25ab4e15cd4b8a5144610394560d9c318ce52def
  270. Default Configuration: 'conf-1'
  271. Configuration 0 (conf-1)
  272. Description: Boot Linux kernel with FDT blob
  273. Kernel: kernel
  274. FDT: fdt-1
  275. The resulting image file kernel_fdt.itb can be now transferred to the target,
  276. inspected and booted:
  277. [on the target system]
  278. => tftp 900000 /path/to/tftp/location/kernel_fdt.itb
  279. Using FEC device
  280. TFTP from server 192.168.1.1; our IP address is 192.168.160.5
  281. Filename '/path/to/tftp/location/kernel_fdt.itb'.
  282. Load address: 0x900000
  283. Loading: #################################################################
  284. ###########
  285. done
  286. Bytes transferred = 1109776 (10ef10 hex)
  287. => iminfo
  288. ## Checking Image at 00900000 ...
  289. FIT image found
  290. FIT description: Simple image with single Linux kernel and FDT blob
  291. Created: 2008-03-11 15:29:22 UTC
  292. Image 0 (kernel)
  293. Description: Vanilla Linux kernel
  294. Type: Kernel Image
  295. Compression: gzip compressed
  296. Data Start: 0x009000ec
  297. Data Size: 1092037 Bytes = 1 MB
  298. Architecture: PowerPC
  299. OS: Linux
  300. Load Address: 0x00000000
  301. Entry Point: 0x00000000
  302. Hash algo: crc32
  303. Hash value: 2c0cc807
  304. Hash algo: sha1
  305. Hash value: 264b59935470e42c418744f83935d44cdf59a3bb
  306. Image 1 (fdt-1)
  307. Description: Flattened Device Tree blob
  308. Type: Flat Device Tree
  309. Compression: uncompressed
  310. Data Start: 0x00a0abdc
  311. Data Size: 16384 Bytes = 16 kB
  312. Architecture: PowerPC
  313. Hash algo: crc32
  314. Hash value: 0d655d71
  315. Hash algo: sha1
  316. Hash value: 25ab4e15cd4b8a5144610394560d9c318ce52def
  317. Default Configuration: 'conf-1'
  318. Configuration 0 (conf-1)
  319. Description: Boot Linux kernel with FDT blob
  320. Kernel: kernel
  321. FDT: fdt-1
  322. => bootm
  323. ## Booting kernel from FIT Image at 00900000 ...
  324. Using 'conf-1' configuration
  325. Trying 'kernel' kernel subimage
  326. Description: Vanilla Linux kernel
  327. Type: Kernel Image
  328. Compression: gzip compressed
  329. Data Start: 0x009000ec
  330. Data Size: 1092037 Bytes = 1 MB
  331. Architecture: PowerPC
  332. OS: Linux
  333. Load Address: 0x00000000
  334. Entry Point: 0x00000000
  335. Hash algo: crc32
  336. Hash value: 2c0cc807
  337. Hash algo: sha1
  338. Hash value: 264b59935470e42c418744f83935d44cdf59a3bb
  339. Verifying Hash Integrity ... crc32+ sha1+ OK
  340. Uncompressing Kernel Image ... OK
  341. ## Flattened Device Tree from FIT Image at 00900000
  342. Using 'conf-1' configuration
  343. Trying 'fdt-1' FDT blob subimage
  344. Description: Flattened Device Tree blob
  345. Type: Flat Device Tree
  346. Compression: uncompressed
  347. Data Start: 0x00a0abdc
  348. Data Size: 16384 Bytes = 16 kB
  349. Architecture: PowerPC
  350. Hash algo: crc32
  351. Hash value: 0d655d71
  352. Hash algo: sha1
  353. Hash value: 25ab4e15cd4b8a5144610394560d9c318ce52def
  354. Verifying Hash Integrity ... crc32+ sha1+ OK
  355. Booting using the fdt blob at 0xa0abdc
  356. Loading Device Tree to 007fc000, end 007fffff ... OK
  357. [ 0.000000] Using lite5200 machine description
  358. [ 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
  359. Example 3 -- advanced booting
  360. -----------------------------
  361. Refer to doc/uImage.FIT/multi.its for an image source file that allows more
  362. sophisticated booting scenarios (multiple kernels, ramdisks and fdt blobs).