blob: a571b45c0f711221bff7bf01456e75cf9c489277 [file] [log] [blame]
<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.
-->
<p>设备树 (DT) 是用于描述“不可发现”硬件的命名节点和属性的数据结构。操作系统(例如在 Android 中使用的 Linux 内核)会使用 DT 来支持 Android 设备使用的各种硬件配置。硬件供应商会提供自己的 DT 源文件,接下来 Linux 会将这些文件编译到引导加载程序使用的设备树 Blob (DTB) 文件中。</p>
<p><a href="https://lkml.org/lkml/2012/11/5/615" class="external">设备树叠加层</a> (DTO) 可让主要的设备树 Blob (DTB) 叠加在设备树上。使用 DTO 的引导加载程序可以维护系统芯片 (SoC) DT,并动态叠加针对特定设备的 DT,从而向树中添加节点并对现有树中的属性进行更改。</p>
<p>本页详细介绍了引导加载程序加载 DT 的典型工作流程,并列出了常见的 DT 术语。本节的其他页介绍了如何<a href="/devices/architecture/dto/implement.html">为 DTO 实现引导加载程序支持</a>,如何<a href="/devices/architecture/dto/compile.html">编译</a>、验证和<a href="/devices/architecture/dto/optimize.html">优化 DTO 实现</a>以及如何<a href="/devices/architecture/dto/multiple.html">使用多个 DT</a>。您还可以获取关于 <a href="/devices/architecture/dto/syntax.html">DTO 语法</a>和必需的 <a href="/devices/architecture/dto/partitions.html">DTO/DTBO 分区格式</a>的详细信息。</p>
<h2 id="p-update">Android 9 版本中的更新</h2>
<p>在 Android 9 中,在将统一设备树 Blob 传递给内核之前,引导加载程序不得修改设备树叠加层中定义的属性。</p>
<h2 id="load-dt">加载设备树</h2>
<p>在引导加载程序中加载设备树会涉及到编译、分区和运行。</p>
<figure id="treble_dto_bootloader">
<img src="../images/treble_dto_bootloader.png"/>
<figcaption><strong>图 1.</strong> 用于在引导加载程序中加载设备树的典型实现。</figcaption>
</figure>
<ol>
<li>要进行编译,请执行以下操作:<ul>
<li>使用设备树编译器 (<code>dtc</code>) 将设备树源 (<code>.dts</code>) 编译为设备树 blob (<code>.dtb</code>)(格式化为扁平化设备树)。</li>
<li><code>.dtb</code> 文件刷写到引导加载程序在运行时可访问的位置(详见下文)。</li>
</ul>
</li>
<li>要进行分区,请确定闪存中引导加载程序在运行时可访问和可信的位置以放入 <code>.dtb</code>。位置示例:
<div style="width:75%">
<div class="attempt-left">
<table><tbody><tr><th style="text-align: center;">启动分区</th></tr></tbody></table>
<figure id="treble_dto_partition_1">
<img src="../images/treble_dto_partition_1.png" style="display:block; margin:0 auto"/>
<figcaption>
<strong>图 2.</strong><code>.dtb</code> 附加到 <code>image.gz</code> 并作为“<code>kernel</code>”传递到 <code>mkbootimg</code>,从而将其放入启动分区。
</figcaption>
</figure>
</div>
<div class="attempt-right">
<table><tbody><tr><th style="text-align: center;">唯一的分区</th></tr></tbody></table>
<figure id="treble_dto_partition_2">
<img src="../images/treble_dto_partition_2.png" style="display:block; margin:0 auto"/>
<figcaption>
<strong>图 3.</strong><code>.dtb</code> 放在唯一的分区(例如 <code>dtb</code> 分区)中。
</figcaption>
</figure>
</div>
</div>
</li>
<li style="clear:both">要运行,请执行以下操作:
<ul>
<li><code>.dtb</code> 从存储加载到内存中。</li>
<li>启动内核(已给定所加载 DT 的内存地址)。</li>
</ul>
</li>
</ol>
<h2 id="terms">术语</h2>
<p>本节使用以下设备树术语:</p>
<table>
<tbody>
<tr>
<th>DT</th>
<td>设备树</td>
</tr>
<tr>
<th>DTB</th>
<td>设备树 Blob</td>
</tr>
<tr>
<th>DTBO</th>
<td>用于叠加的设备树 Blob</td>
</tr>
<tr>
<th>DTC</th>
<td>设备树编译器</td>
</tr>
<tr>
<th>DTO</th>
<td>设备树叠加层</td>
</tr>
<tr>
<th>DTS</th>
<td>设备树源</td>
</tr>
<tr>
<th>FDT</th>
<td>扁平化设备树,一种包含在 <code>.dtb</code> blob 文件中的二进制格式</td>
</tr>
</tbody>
</table>
</body></html>