diff options
Diffstat (limited to 'zh-cn/devices/bootloader/boot-image-header.html')
-rw-r--r-- | zh-cn/devices/bootloader/boot-image-header.html | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/zh-cn/devices/bootloader/boot-image-header.html b/zh-cn/devices/bootloader/boot-image-header.html new file mode 100644 index 00000000..2fd03438 --- /dev/null +++ b/zh-cn/devices/bootloader/boot-image-header.html @@ -0,0 +1,126 @@ +<html devsite><head> + <title>启动映像标头版本编号</title> + <meta name="project_path" value="/_project.yaml"/> + <meta name="book_path" value="/_book.yaml"/> +</head> + +<body> + <!-- + Copyright 2018 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> + + <h2>启动映像标头版本编号</h2> + + <p>从 Android 9 起,启动映像标头开始包含一个用于指示标头版本的字段。引导加载程序必须检查该标头版本字段,并相应地解析标头。通过对启动映像标头进行版本编号,可在将来对标头进行修改,同时保持向后兼容性。</p> + + <p>所有搭载 Android 9 的设备都必须使用启动标头版本 1。</p> + + <h2 id="boot-image-header-changes">启动映像标头更改</h2> + + <p>对于搭载 Android 9 的设备,旧版启动映像标头(如下所示)中的 <code>unused</code> 字段将会转换为标头版本字段。</p> + + <pre class="prettyprint">struct boot_img_hdr +{ + uint8_t magic[BOOT_MAGIC_SIZE]; + uint32_t kernel_size; /* size in bytes */ + uint32_t kernel_addr; /* physical load addr */ + + uint32_t ramdisk_size; /* size in bytes */ + uint32_t ramdisk_addr; /* physical load addr */ + + uint32_t second_size; /* size in bytes */ + uint32_t second_addr; /* physical load addr */ + + uint32_t tags_addr; /* physical addr for kernel tags */ + uint32_t page_size; /* flash page size we assume */ + uint32_t unused; + uint32_t os_version; + uint8_t name[BOOT_NAME_SIZE]; /* asciiz product name */ + uint8_t cmdline[BOOT_ARGS_SIZE]; + uint32_t id[8]; /* timestamp / checksum / sha1 / etc */ + uint8_t extra_cmdline[BOOT_EXTRA_ARGS_SIZE]; +};</pre> + + <p>如果设备搭载 Android 9 之前的版本且使用旧版启动映像标头,则会被视为使用启动映像标头版本 0。所有搭载 Android 9 的设备都必须使用以下启动映像标头结构,同时标头版本设为 1。</p> + + <pre class="prettyprint">struct boot_img_hdr +{ + uint8_t magic[BOOT_MAGIC_SIZE]; + uint32_t kernel_size; /* size in bytes */ + uint32_t kernel_addr; /* physical load addr */ + + uint32_t ramdisk_size; /* size in bytes */ + uint32_t ramdisk_addr; /* physical load addr */ + + uint32_t second_size; /* size in bytes */ + uint32_t second_addr; /* physical load addr */ + + uint32_t tags_addr; /* physical addr for kernel tags */ + uint32_t page_size; /* flash page size we assume */ + uint32_t header_version; + uint32_t os_version; + uint8_t name[BOOT_NAME_SIZE]; /* asciiz product name */ + uint8_t cmdline[BOOT_ARGS_SIZE]; + uint32_t id[8]; /* timestamp / checksum / sha1 / etc */ + uint8_t extra_cmdline[BOOT_EXTRA_ARGS_SIZE]; + uint32_t recovery_dtbo_size; /* size of recovery dtbo image */ + uint64_t recovery_dtbo_offset; /* offset in boot image */ + uint32_t header_size; /* size of boot image header in bytes */ +};</pre> + + <p><code>header_size</code> 字段包含启动映像标头大小。如果启动映像标头版本设为 1,则除了内核、ramdisk 和 second 部分之外,ID 字段还包含启动映像 <code>recovery_dtbo</code> 部分的 SHA1 摘要。要详细了解 <code>recovery_dtbo_size</code> 和 <code>recovery_dtbo_offset</code> 字段,请参阅<em><a href="/devices/bootloader/recovery-image">在非 A/B 设备的恢复映像中添加 DTBO</a></em>。</p> + + <h2 id="implementation">实现</h2> + + <p>用于创建启动映像的 <code>mkbootimg</code> 工具添加了以下参数,以支持新的启动映像标头:</p> + + <table> + <tbody><tr> + <td><strong>参数</strong> + </td> + + <td><strong>说明</strong> + </td> + </tr> + + <tr> + <td><code>header_version</code> + </td> + + <td>设置启动映像标头版本。</td> + </tr> + + <tr> + <td><code>recovery_dtbo</code> + </td> + + <td>要添加到恢复映像的恢复 DTBO 映像的路径。</td> + </tr> + </tbody></table> + + <p>设备 <code>BoardConfig.mk</code> 使用 <code>BOARD_MKBOOTIMG_ARGS</code> 配置,以便将 <code>header version</code> 添加到 <code>mkbootimg</code> 的其他专门针对主板的参数。例如:</p> + + <pre class="prettyprint"> + BOARD_MKBOOTIMG_ARGS := --ramdisk_offset $(BOARD_RAMDISK_OFFSET) --tags_offset $(BOARD_KERNEL_TAGS_OFFSET) --header_version $(BOARD_BOOTIMG_HEADER_VERSION)</pre> + + <p>Android 编译系统使用 BoardConfig 变量 <code>BOARD_PREBUILT_DTBOIMAGE</code>,以便在创建恢复映像期间设置 <code>mkbootimg</code> 工具的 <code>recovery_dtbo</code> 参数。</p> + + <p>要详细了解 Android 开源项目 (AOSP) 的变化,请查看<a href="https://android-review.googlesource.com/q/topic:%22recovery_dtbo%22+(status:open%20OR%20status:merged)">与启动映像标头版本编号相关的更改列表</a>。</p> + + <h2 id="validation">验证</h2> + + <p>对于所有搭载 Android 9 的设备,<a href="/compatibility/vts/">供应商测试套件 (VTS)</a> 都会检查启动/恢复映像的格式,以确保启动映像标头使用版本 1。</p> + +</body></html>
\ No newline at end of file |