aboutsummaryrefslogtreecommitdiff
path: root/zh-cn/devices/bootloader/recovery-image.html
blob: 7512ed250e0d707511faa77ca3e8cb3f2a1e9b06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<html devsite><head>
  <title>在非 A/B 设备的恢复映像中添加 DTBO</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.
  -->
   为防止非 A/B 设备上出现 OTA 失败的情况,恢复分区必须“自给自足”,不得依赖于其他分区。

  <p>启动到恢复模式时,引导加载程序必须加载与恢复映像兼容的 DTBO 映像。在执行 OTA 期间,如果在 DTBO 映像更新后(但在完成全部更新之前)出现问题,设备将尝试启动到恢复模式,以完成 OTA。不过,由于 DTBO 分区已更新,恢复映像(尚未更新)可能会出现不匹配的情况。</p>

  <p>为防止出现这种情况,在 Android 9 中,恢复映像也必须包含来自 DTBO 映像的信息。非 A/B 设备的恢复映像还必须包含附加到内核的设备 DTB,以便在更新期间不依赖于 DTB 分区。</p>

  <h2 id="boot-image-changes">启动映像更改</h2>

  <p>要允许恢复映像包含恢复 DTBO,Android 9 中启动映像的格式应如下所示:</p>

  <table>
    <tbody><tr>
      <td>启动标头(1 页)</td>
    </tr>

    <tr>
      <td>内核(<em></em>l 页)</td>
    </tr>

    <tr>
      <td>Ramdisk(<em></em>m 页)</td>
    </tr>

    <tr>
      <td>第二阶段(<em></em>n 页)</td>
    </tr>

    <tr>
      <td>恢复 DTBO(<em></em>o 页)</td>
    </tr>
  </tbody></table>

  <p>此外,用于创建启动映像的 <code>mkbootimg</code> 工具包含下列新参数:</p>

  <table>
    <tbody><tr>
      <th><strong>参数</strong>
      </th>

      <th><strong>说明</strong>
      </th>
    </tr>

    <tr>
      <td><code>header_version</code>
      </td>

      <td>设置启动映像标头版本。标头版本高于或等于 1 的启动映像支持恢复 DTBO 部分。</td>
    </tr>

    <tr>
      <td><code>recovery_dtbo</code>
      </td>

      <td>恢复 DTBO 映像的路径。</td>
    </tr>
  </tbody></table>

  <p>要详细了解对旧版启动映像标头的改动,请参阅 <em><a href="/devices/bootloader/boot-image-header">Android 9 中的启动映像标头版本控制</a></em>。</p>

  <h2 id="implementation">实现</h2>

  <p>虽然搭载 Android 9 的所有设备都必须使用新的启动映像标头(版本 1),但只有非 A/B 设备才必须填充恢复映像的 <code>recovery_dtbo</code> 部分。要在 <code>BoardConfig.mk</code> 设备的 <code>recovery.img</code> 中添加 <code>recovery_dtbo</code>,请执行以下操作:</p>

  <ul>
    <li>将 <code>BOARD_INCLUDE_RECOVERY_DTBO</code> 配置设置为 <code>true</code>:

      <pre class="prettyprint">BOARD_INCLUDE_RECOVERY_DTBO := true</pre>
    </li>
  </ul>

  <ul>
    <li>扩展 <code>BOARD_MKBOOTIMG_ARGS</code> 变量以指定启动映像标头版本:

      <pre class="prettyprint">
      BOARD_MKBOOTIMG_ARGS := --ramdisk_offset $(BOARD_RAMDISK_OFFSET) --tags_offset $(BOARD_KERNEL_TAGS_OFFSET) --header_version $(BOARD_BOOTIMG_HEADER_VERSION)</pre>
    </li>
  </ul>

  <ul>
    <li>确保将 <code>BOARD_PREBUILT_DTBOIMAGE</code> 变量设置为 DTBO 映像的路径。Android 编译系统会使用该变量在创建恢复映像时设置 mkbootimg 工具的 <code>recovery_dtbo</code> 参数。</li>
  </ul>

  <ul>
    <li>如果变量 <code>BOARD_INCLUDE_RECOVERY_DTBO</code>、<code>BOARD_MKBOOTIMG_ARGS</code> 和 <code>BOARD_PREBUILT_DTBOIMAGE</code> 均正确设置,Android 编译系统会将变量 <code>BOARD_PREBUILT_DTBOIMAGE</code> 指定的 DTBO 添加到 <code>recovery.img</code> 中。</li>
  </ul>

  <h2 id="validation">验证</h2>

  <p>对于搭载 Android 9 的所有设备,<a href="/compatibility/vts/">供应商测试套件 (VTS)</a> 会检查启动/恢复映像的格式,以确保启动映像标头使用版本 1。</p>

</body></html>