← Documents Documentation/arch/powerpc/bootwrapper.rst GitHub 원문 ↗

Linux 6.18.37 · Architecture

The PowerPC Boot Wrapper

Firmware별 PowerPC boot image target과 link-time wrapper 조립 방식을 정리합니다.

Source pathDocumentation/arch/powerpc/bootwrapper.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약과 해설

bootwrapper.rst:1-131

Firmware가 DTB를 제공하는지, wrapper가 board data를 보정해야 하는지에 따라 `zImage`, `uImage`, `simpleImage`, `dtbImage`, `treeImage`, `cuImage`를 선택합니다. 모든 wrapper piece는 항상 compile하고 target에 필요한 것만 link합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

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

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

PowerPC boot wrapper와 firmware 형식

1-24

Copyright는 Secret Lab Technologies Ltd.에 있습니다. PowerPC image target은 kernel image `vmlinux`를 압축하고 boot wrapper로 감싸 system firmware가 사용할 수 있게 합니다. 표준 PowerPC firmware interface가 없기 때문에 boot wrapper는 build해야 하는 image 종류마다 적응할 수 있도록 설계되었습니다.

Boot wrapper source는 `arch/powerpc/boot/`에 있으며 그 directory의 Makefile이 사용할 수 있는 모든 image type target을 제공합니다. 서로 다른 type은 PowerPC platform의 다양한 firmware interface를 지원합니다.

Apple, IBM 등의 general-purpose PowerPC system은 주로 OpenFirmware를 사용하고 embedded hardware는 보통 U-Boot를 사용하지만, 널리 쓰이는 다른 firmware 구현도 있습니다. Firmware interface마다 요구하는 image format이 다릅니다.

`arch/powerpc/boot/Makefile`은 `arch/powerpc/boot/wrapper` script를 사용해 target image를 생성합니다.

Boot image format target

25-92
Target용도와 구성
`cuImage.%`Device tree를 이해하지 못하는 오래된 U-Boot와 호환되는 `uImage`입니다. Boot wrapper, kernel, embedded DTB를 U-Boot uImage format 안에 넣고, wrapper가 과거 `bd_info` structure의 data를 device tree에 채운 뒤 kernel로 jump합니다. `bd_info`의 많은 `#ifdef` 때문에 platform-specific이며, init code는 `arch/powerpc/boot/cuboot.*.c`에 있고 wrapper structure가 board별 올바른 code를 선택합니다.
`dtbImage.%``zImage`와 비슷하지만 firmware가 DTB를 전달하는 대신 image 안에 embed합니다. Platform에 따라 ELF 또는 flat binary가 됩니다. Device tree 직접 전달 interface가 없는 system에서 사용하며, board firmware에서 data를 꺼내는 platform-specific code가 있다는 점에서 firmware와 전혀 통신하지 않는 `simpleImage`와 다릅니다. PlayStation 3와 PlanetCore firmware 기반 Embedded Planet board가 사용하며 보통 `arch/powerpc/boot/<platform>.c`가 초기화를 담당하고 wrapper script가 이를 override할 수 있습니다.
`simpleImage.%`특정 firmware interface에 의존하지 않는 compressed flat binary이며 DTB를 embed합니다. RAM의 어느 위치든 load해 jump할 수 있지만 firmware가 configuration data를 kernel에 전달할 수 없으므로 모든 정보를 embedded device tree에 의존합니다.
`treeImage.%`일부 ppc4xx hardware의 OpenBIOS firmware용 image format이며 DTB를 image 안에 embed합니다.
`uImage`U-Boot native image format입니다. Boot code를 추가하지 않고 compressed `vmlinux`를 uImage data structure로 감쌉니다. Boot 시 device tree를 kernel에 전달할 수 있는 U-Boot가 필요하며, 오래된 U-Boot에서는 대신 `cuImage`를 사용해야 합니다.
`zImage.%`Device tree를 embed하지 않는 형식입니다. OpenFirmware처럼 boot 때 device tree를 제공할 수 있는 firmware interface에 사용하며, 보통 general-purpose PowerPC hardware에 적합합니다.
PowerPC image 선택표
TargetDTB 위치Firmware data/fixup
`zImage.%`Firmware 제공Firmware interface 사용
`uImage`U-Boot 제공Boot code 없음
`simpleImage.%`EmbeddedFirmware 통신 없음
`dtbImage.%`EmbeddedPlatform-specific 추출
`treeImage.%`EmbeddedOpenBIOS/ppc4xx
`cuImage.%`EmbeddedLegacy U-Boot `bd_info` 변환

Firmware가 DTB를 제공하는지와 board-specific fixup이 필요한지가 target 선택을 결정합니다.

Embedded DTB와 default target

93-105

DTB를 embed하는 `simpleImage`, `dtbImage`, `treeImage`, `cuImage`는 모두 `arch/powerpc/boot/dts/`의 file로 device-tree blob을 생성합니다. Makefile은 target 이름에서 올바른 device-tree source를 고릅니다.

예를 들어 `make treeImage.walnut`을 실행하면 build system은 `arch/powerpc/boot/dts/walnut.dts`로 `treeImage.walnut`을 만듭니다.

Special target `zImage`와 `zImage.initrd`는 kernel configuration이 선택한 모든 default image를 build합니다. Boot-wrapper Makefile은 `$image-y` variable에 target을 추가해 default image를 선택하며, 사용할 수 있는 target은 `arch/powerpc/boot/Makefile`에서 확인합니다.

Link-time 조립 방식

106-131

`arch/powerpc`는 하나의 `vmlinux` image를 여러 target board에서 boot할 수 있는 multi-platform kernel을 지향합니다. 따라서 boot wrapper도 한 build에서 여러 image type을 감쌀 수 있어야 합니다.

Boot wrapper source에는 `#ifdef` 같은 conditional compilation을 사용하지 않기로 설계했습니다. Kernel configuration과 무관하게 모든 wrapper piece를 언제든 build할 수 있고, 매 kernel build에서 전부 compile하므로 드문 wrapper code도 다양한 environment에서 최소한 compile test를 받습니다.

Image type별 적응은 link time에 필요한 wrapper piece만 연결해서 수행합니다. Makefile이 호출하는 `arch/powerpc/boot/wrapper` script가 image type에 맞는 piece를 고릅니다. Argument는 script comment block에 설명되어 있으며, 주된 선택 기준은 `-p` (`platform`) argument입니다. Script 가운데의 큰 `case "$platform" in` block이 이 결정을 담당하고, link order를 바꾸어 platform-specific fixup도 고를 수 있습니다.

`cuImage`를 다룰 때는 특히 주의해야 합니다. 그 wrapper piece는 board 의존성이 매우 크므로 build하려는 target을 해당 piece가 실제로 지원하는지 확인해야 합니다.

Boot wrapper build pipeline
`vmlinux`모든 wrapper piece compile`wrapper -p <platform>`Target별 link/fixupBoot image

Configuration과 무관하게 compile한 piece를 target별로 link합니다.