ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
การวางซ้อนแผนผังอุปกรณ์
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Device Tree (DT) คือโครงสร้างข้อมูลของโหนดและพร็อพเพอร์ตี้ที่มีชื่อซึ่งอธิบายฮาร์ดแวร์ที่ตรวจไม่พบ เคอร์เนล เช่น เคอร์เนล Linux ที่ใช้ใน Android จะใช้ DT เพื่อรองรับการกำหนดค่าฮาร์ดแวร์อันหลากหลายซึ่งอุปกรณ์ที่ขับเคลื่อนโดย Android ใช้ ผู้ให้บริการฮาร์ดแวร์จะจัดหาไฟล์ซอร์สโค้ด (DTS) ของต้นไม้อุปกรณ์ของตนเอง ซึ่งจะคอมไพล์เป็นไฟล์ Device Tree Blob (DTB) โดยใช้คอมไพเลอร์ต้นไม้อุปกรณ์ จากนั้นไฟล์เหล่านี้จะใช้โดยโปรแกรมบูต ไฟล์ DTB มีต้นไม้อุปกรณ์แบบแบนในรูปแบบไบนารี
การวางซ้อนต้นไม้อุปกรณ์ (DTO) ช่วยให้คุณวางซ้อน DTB กลางใน DT ได้ (BLOB ต้นไม้อุปกรณ์สำหรับการวางซ้อน (DTBO)) บูตโหลดเดอร์ที่ใช้ DTO สามารถดูแลรักษา DT ของระบบบนชิป (SoC) และวางซ้อน DT สำหรับอุปกรณ์โดยเฉพาะแบบไดนามิก เพิ่มโหนดลงในต้นไม้ และทําการเปลี่ยนแปลงพร็อพเพอร์ตี้ในต้นไม้ที่มีอยู่
การอัปเดตในรุ่น Android 9
ใน Android 9 บูตโหลดเดอร์ต้องไม่แก้ไขพร็อพเพอร์ตี้ที่กําหนดไว้ใน DTO ก่อนที่จะส่ง DTB แบบรวมไปยังเคอร์เนล
โหลด DT
การโหลด DT ใน Bootloader เกี่ยวข้องกับการสร้าง การแบ่งพาร์ติชัน และการทำงาน

รูปที่ 1 การใช้งานทั่วไปสำหรับการโหลดต้นไม้อุปกรณ์ใน Bootloader
วิธีสร้างและแฟลช DTB
1ก. ใช้ DTC (dtc
) เพื่อคอมไพล์ DTS (.dts
) เป็น DTB (.dtb
)
DTB มีรูปแบบเป็น DT แบบแบน
1ข. แฟลชไฟล์ .dtb
ไปยังตำแหน่งที่เข้าถึงได้แบบรันไทม์ของบูตโหลดเดอร์ (ดูรายละเอียดด้านล่าง)
หากต้องการแบ่งพาร์ติชัน ให้กำหนดตำแหน่งที่เชื่อถือได้และเข้าถึงได้ในช่วงรันไทม์ของ Bootloader ในหน่วยความจำแฟลชเพื่อใส่ .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 UTC
[[["เข้าใจง่าย","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 UTC"],[],[],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)."]]