自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
裝置樹狀架構重疊圖層
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
裝置樹狀結構 (DT) 是命名節點和屬性資料結構,用於描述無法偵測到的硬體。核心 (例如 Android 中使用的 Linux 核心) 會使用 DT 支援 Android 裝置使用的各種硬體設定。硬體供應商會提供自己的裝置樹狀結構來源 (DTS) 檔案,這些檔案會使用裝置樹狀結構編譯器編譯為 裝置樹狀結構 blob (DTB) 檔案。這些檔案隨後會由引導程式使用。DTB 檔案包含以二進位格式編碼的扁平化裝置樹狀結構。
裝置樹狀結構疊加層 (DTO) 可讓中央 DTB 疊加在 DT 上 (裝置樹狀結構 blob 用於疊加 (DTBO))。使用 DTO 的引導程式可以維護系統單晶片 (SoC) DT,並動態重疊裝置專屬的 DT,在樹狀結構中新增節點,並變更現有樹狀結構中的屬性。
Android 9 版本更新
在 Android 9 中,在將統一 DTB 傳遞至核心之前,Bootloader 不得修改 DTO 中定義的屬性。
載入 DT
在系統啟動載入程式中載入 DT 時,需要建構、分割及執行。

圖 1. 在系統啟動載入程式中載入裝置樹狀結構的一般實作方式。
如要建立及刷新 DTB,請按照下列步驟操作:
1a. 使用 DTC (dtc
) 將 DTS (.dts
) 編譯為 DTB (.dtb
)。DTB 的格式為扁平化 DT。1b. 將 .dtb
檔案刷入可供引導程式執行階段存取的位置 (詳情請見下文)。
如要分割區,請在快閃記憶體中找出可供引導程式在執行階段存取且可信的位置,以便放置 .dtb
。範例地點

圖 2. 將 .dtb 放在開機分割區,方法是 附加至 image.gz,並以 "kernel" 的形式傳遞至 mkbootimg。
|

圖 3. 將 .dtb 放在不重複的分區中 (例如 dtb 分區)。
|
如要載入 DTB 並啟動核心,請按照下列步驟操作:
- 將
.dtb
從儲存空間載入記憶體。
- 使用已載入的 DT 記憶體位址啟動核心。
後續步驟
本頁面詳細說明載入 DT 的一般啟動載入程式,並提供常見的 DT 術語清單。本章節的其他頁面會說明如何實作引導程式支援、如何編譯、驗證及最佳化 DTO,以及如何使用多個 DT。您也可以進一步瞭解 DTO 語法和必要的 DTO 和 DTBO 分區格式。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Device tree overlays\n\n\u003cbr /\u003e\n\nA *device tree (DT)* is a data structure of named nodes and properties that\ndescribe non-discoverable hardware. Kernels, such as the Linux kernel\nused in Android, use DTs to support a wide range of hardware configurations used\nby Android-powered devices. Hardware vendors supply their own *device tree\nsource (DTS)* files, which are compiled into the *device tree blob (DTB)* file\nusing the *device tree compiler* . These files are then used by the\nbootloader. The DTB file contains a binary-formatted *flattened device tree*.\n\nA [*device tree overlay (DTO)*](https://lkml.org/lkml/2012/11/5/615)\nenables a central DTB to be overlaid on the DT (a *device tree blob\nfor overlay (DTBO)*). A bootloader using DTO can maintain the system-on-chip\n(SoC) DT and dynamically overlay a device-specific DT, adding nodes to the tree\nand making changes to properties in the existing tree.\n\nUpdates in Android 9 release\n----------------------------\n\nIn Android 9, the bootloader must not modify the\nproperties defined in the DTOs before passing the unified DTB to the kernel.\n\nLoad a DT\n---------\n\nLoading a DT in bootloader involves building, partitioning, and running.\n\n**Figure 1.** Typical implementation for loading device tree in bootloader.\n\n1. To create and flash the DTB:\n\n 1a. Use the DTC (`dtc`) to compile DTS (`.dts`) into a DTB (`.dtb`).\n The DTB is formatted as a flattened DT.\n 1b. Flash the `.dtb` file into a bootloader runtime-accessible location\n (detailed below).\n2. To partition, determine a bootloader runtime-accessible and trusted location\n in flash memory to put `.dtb`. Example locations:\n\n \u003cbr /\u003e\n\n |-----------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------|\n | **Figure 2.** Put .dtb in a boot partition by appending to image.gz and passing as \"kernel\" to mkbootimg. | **Figure 3.** Put .dtb in a unique partition (for example, dtb partition). |\n\n \u003cbr /\u003e\n\n3. To load the DTB and start the kernel:\n\n - Load `.dtb` from storage into memory.\n - Start kernel using the memory address of the loaded DT.\n\nWhat's next?\n------------\n\nThis page details a typical bootloader workflow for loading a DT and provides\na list of common DT terms. Other pages in this section describe how to\n[implement bootloader support](/docs/core/architecture/dto/implement), how to\n[compile](/docs/core/architecture/dto/compile), verify, and\n[optimize your DTO](/docs/core/architecture/dto/optimize), and how to\n[use multiple DTs](/docs/core/architecture/dto/multiple). You can\nalso get details on [DTO syntax](/docs/core/architecture/dto/syntax) and\nrequired\n[DTO and DTBO partition formatting](/docs/core/architecture/dto/partitions)."]]