bootwrapper.rst 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. ========================
  2. The PowerPC boot wrapper
  3. ========================
  4. Copyright (C) Secret Lab Technologies Ltd.
  5. PowerPC image targets compresses and wraps the kernel image (vmlinux) with
  6. a boot wrapper to make it usable by the system firmware. There is no
  7. standard PowerPC firmware interface, so the boot wrapper is designed to
  8. be adaptable for each kind of image that needs to be built.
  9. The boot wrapper can be found in the arch/powerpc/boot/ directory. The
  10. Makefile in that directory has targets for all the available image types.
  11. The different image types are used to support all of the various firmware
  12. interfaces found on PowerPC platforms. OpenFirmware is the most commonly
  13. used firmware type on general purpose PowerPC systems from Apple, IBM and
  14. others. U-Boot is typically found on embedded PowerPC hardware, but there
  15. are a handful of other firmware implementations which are also popular. Each
  16. firmware interface requires a different image format.
  17. The boot wrapper is built from the makefile in arch/powerpc/boot/Makefile and
  18. it uses the wrapper script (arch/powerpc/boot/wrapper) to generate target
  19. image. The details of the build system is discussed in the next section.
  20. Currently, the following image format targets exist:
  21. ==================== ========================================================
  22. cuImage.%: Backwards compatible uImage for older version of
  23. U-Boot (for versions that don't understand the device
  24. tree). This image embeds a device tree blob inside
  25. the image. The boot wrapper, kernel and device tree
  26. are all embedded inside the U-Boot uImage file format
  27. with boot wrapper code that extracts data from the old
  28. bd_info structure and loads the data into the device
  29. tree before jumping into the kernel.
  30. Because of the series of #ifdefs found in the
  31. bd_info structure used in the old U-Boot interfaces,
  32. cuImages are platform specific. Each specific
  33. U-Boot platform has a different platform init file
  34. which populates the embedded device tree with data
  35. from the platform specific bd_info file. The platform
  36. specific cuImage platform init code can be found in
  37. `arch/powerpc/boot/cuboot.*.c`. Selection of the correct
  38. cuImage init code for a specific board can be found in
  39. the wrapper structure.
  40. dtbImage.%: Similar to zImage, except device tree blob is embedded
  41. inside the image instead of provided by firmware. The
  42. output image file can be either an elf file or a flat
  43. binary depending on the platform.
  44. dtbImages are used on systems which do not have an
  45. interface for passing a device tree directly.
  46. dtbImages are similar to simpleImages except that
  47. dtbImages have platform specific code for extracting
  48. data from the board firmware, but simpleImages do not
  49. talk to the firmware at all.
  50. PlayStation 3 support uses dtbImage. So do Embedded
  51. Planet boards using the PlanetCore firmware. Board
  52. specific initialization code is typically found in a
  53. file named arch/powerpc/boot/<platform>.c; but this
  54. can be overridden by the wrapper script.
  55. simpleImage.%: Firmware independent compressed image that does not
  56. depend on any particular firmware interface and embeds
  57. a device tree blob. This image is a flat binary that
  58. can be loaded to any location in RAM and jumped to.
  59. Firmware cannot pass any configuration data to the
  60. kernel with this image type and it depends entirely on
  61. the embedded device tree for all information.
  62. treeImage.%; Image format for used with OpenBIOS firmware found
  63. on some ppc4xx hardware. This image embeds a device
  64. tree blob inside the image.
  65. uImage: Native image format used by U-Boot. The uImage target
  66. does not add any boot code. It just wraps a compressed
  67. vmlinux in the uImage data structure. This image
  68. requires a version of U-Boot that is able to pass
  69. a device tree to the kernel at boot. If using an older
  70. version of U-Boot, then you need to use a cuImage
  71. instead.
  72. zImage.%: Image format which does not embed a device tree.
  73. Used by OpenFirmware and other firmware interfaces
  74. which are able to supply a device tree. This image
  75. expects firmware to provide the device tree at boot.
  76. Typically, if you have general purpose PowerPC
  77. hardware then you want this image format.
  78. ==================== ========================================================
  79. Image types which embed a device tree blob (simpleImage, dtbImage, treeImage,
  80. and cuImage) all generate the device tree blob from a file in the
  81. arch/powerpc/boot/dts/ directory. The Makefile selects the correct device
  82. tree source based on the name of the target. Therefore, if the kernel is
  83. built with 'make treeImage.walnut', then the build system will use
  84. arch/powerpc/boot/dts/walnut.dts to build treeImage.walnut.
  85. Two special targets called 'zImage' and 'zImage.initrd' also exist. These
  86. targets build all the default images as selected by the kernel configuration.
  87. Default images are selected by the boot wrapper Makefile
  88. (arch/powerpc/boot/Makefile) by adding targets to the $image-y variable. Look
  89. at the Makefile to see which default image targets are available.
  90. How it is built
  91. ---------------
  92. arch/powerpc is designed to support multiplatform kernels, which means
  93. that a single vmlinux image can be booted on many different target boards.
  94. It also means that the boot wrapper must be able to wrap for many kinds of
  95. images on a single build. The design decision was made to not use any
  96. conditional compilation code (#ifdef, etc) in the boot wrapper source code.
  97. All of the boot wrapper pieces are buildable at any time regardless of the
  98. kernel configuration. Building all the wrapper bits on every kernel build
  99. also ensures that obscure parts of the wrapper are at the very least compile
  100. tested in a large variety of environments.
  101. The wrapper is adapted for different image types at link time by linking in
  102. just the wrapper bits that are appropriate for the image type. The 'wrapper
  103. script' (found in arch/powerpc/boot/wrapper) is called by the Makefile and
  104. is responsible for selecting the correct wrapper bits for the image type.
  105. The arguments are well documented in the script's comment block, so they
  106. are not repeated here. However, it is worth mentioning that the script
  107. uses the -p (platform) argument as the main method of deciding which wrapper
  108. bits to compile in. Look for the large 'case "$platform" in' block in the
  109. middle of the script. This is also the place where platform specific fixups
  110. can be selected by changing the link order.
  111. In particular, care should be taken when working with cuImages. cuImage
  112. wrapper bits are very board specific and care should be taken to make sure
  113. the target you are trying to build is supported by the wrapper bits.