ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
รูปภาพ DTB
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
การติดตั้งใช้งาน Android อาจรวมภาพ Device Tree Blob (DTB) ไว้ให้ Bootloader ใช้งาน ตำแหน่งของรูปภาพ DTB (และตัวเลือกในการระบุพารามิเตอร์รูปภาพ DTB) จะแตกต่างกันไปตามรุ่นของ Android
ใน Android 11 อุปกรณ์ที่ใช้อิมเมจเคอร์เนลทั่วไป (GKI) ต้องรองรับพาร์ติชันบูตของเวนเดอร์ ซึ่งประกอบด้วยข้อมูลเฉพาะของเวนเดอร์ทั้งหมดที่ย้ายจากพาร์ติชันบูต เนื่องจากอิมเมจ DTB มีข้อมูลที่เฉพาะเจาะจงของผู้ให้บริการ ตอนนี้อิมเมจจึงเป็นส่วนหนึ่งของพาร์ติชันบูตของผู้ให้บริการ หากต้องการระบุพารามิเตอร์รูปภาพ DTB โปรดดูส่วนหัวการบูตของผู้ให้บริการ
ใน Android 10 อุปกรณ์จะรวมอิมเมจ DTB ไว้ในพาร์ติชันบูตได้ หากต้องการระบุพารามิเตอร์ของรูปภาพ DTB โปรดดูการรวมรูปภาพ DTB ในรูปภาพบูต
ใน Android 9 และต่ำกว่า รูปภาพ DTB จะอยู่ได้ในพาร์ติชันของตัวเองหรือต่อท้ายเคอร์เนล image.gz
เพื่อสร้างรูปภาพเคอร์เนล + DTB (ซึ่งจะส่งต่อไปยัง mkbootimg
เพื่อสร้าง boot.img
)
ใน Android 10 ขึ้นไป รูปภาพ DTB ต้องใช้รูปแบบใดรูปแบบหนึ่งต่อไปนี้
DT Blob ที่ต่อต่อกัน บูตโหลดเดอร์ใช้ช่อง totalsize
ในส่วนหัว FDT แต่ละส่วนเพื่ออ่านและแยกวิเคราะห์ Blob ที่เกี่ยวข้อง
พาร์ติชัน DTB/DTBO บูตโหลดเดอร์มีวิธีที่มีประสิทธิภาพในการเลือกบล็อก DT ที่ถูกต้องโดยการตรวจสอบโครงสร้าง dt_table_entry
(มีฟิลด์ id
, rev
และ custom
) ที่สามารถเก็บข้อมูลระบุฮาร์ดแวร์สำหรับรายการ โปรดดูรายละเอียดที่พาร์ติชัน DTB/DTBO
รวมอิมเมจ DTB ไว้ในอิมเมจบูท
อุปกรณ์ที่ใช้ Android 10 สามารถรวมอิมเมจ DTB ไว้ในอิมเมจบูตได้ ซึ่งทำให้ Android ไม่ต้องรองรับสคริปต์ที่เพิ่มไฟล์ DTB ต่อท้าย image.gz
ในเคอร์เนล และช่วยให้ใช้การทดสอบชุดทดสอบของผู้ให้บริการ (VTS) เพื่อยืนยัน (และกำหนดมาตรฐาน) ตำแหน่ง DTB ได้
นอกจากนี้ สำหรับอุปกรณ์ที่ไม่ใช่ A/B การมี DTB เป็นส่วนหนึ่งของรูปภาพการกู้คืนจะปลอดภัยกว่าการอยู่ในพาร์ติชันแยกต่างหากเพื่อป้องกันปัญหาที่เกิดจาก OTA ที่ถูกขัดจังหวะ ในระหว่างการอัปเดต OTA หากเกิดปัญหาขึ้นหลังจากการอัปเดตพาร์ติชัน DTB (แต่ก่อนที่จะอัปเดตให้เสร็จสมบูรณ์) อุปกรณ์จะพยายามบูตเข้าสู่โหมดการกู้คืนเพื่อทำการอัปเดต OTA ให้เสร็จสมบูรณ์ แต่เนื่องจากพาร์ติชัน DTB ได้รับการอัปเดตแล้ว จึงอาจเกิดความไม่ตรงกันกับอิมเมจการกู้คืน (ซึ่งยังไม่ได้อัปเดต) การมีรูปภาพ DTB เป็นส่วนหนึ่งของรูปแบบรูปภาพสำหรับบูตจะช่วยป้องกันปัญหาดังกล่าวได้ด้วยการทำให้รูปภาพการกู้คืนทำงานได้ด้วยตัวเอง (กล่าวคือ ไม่ขึ้นอยู่กับพาร์ติชันอื่น)
โครงสร้างอิมเมจบูต
อุปกรณ์ที่ใช้ Android 10 สามารถรวมอิมเมจ DTB ได้โดยใช้โครงสร้างอิมเมจบูตต่อไปนี้
ส่วนอิมเมจบูต |
จำนวนหน้า |
ส่วนหัวของบูต (1 หน้า) |
1 |
เคอร์เนล (หน้า l) |
l = (kernel_size + page_size -
1) / page_size |
แรมดิสก์ (หน้า m) |
m = (ramdisk_size + page_size -
1) / page_size |
บูตโหลดเดอร์ระยะที่ 2 (n หน้า) |
n = (second_size + page_size -
1) / page_size |
การกู้คืน DTBO (หน้า o) |
o = (recovery_dtbo_size + page_size -
1) / page_size |
DTB (หน้า p) |
p = (dtb_size + page_size -
1) / page_size |
เส้นทางรูปภาพ DTB
สําหรับอุปกรณ์ที่ใช้ Android 10 คุณสามารถใช้เครื่องมือ mkbootimg.py
และอาร์กิวเมนต์ต่อไปนี้เพื่อระบุเส้นทางไปยังรูปภาพ DTB
อาร์กิวเมนต์ |
คำอธิบาย |
dtb |
เส้นทางไปยังอิมเมจ DTB ที่จะรวมอยู่ในอิมเมจการบูต/การกู้คืน |
dtb_offset |
เมื่อเพิ่มลงในอาร์กิวเมนต์ base จะระบุที่อยู่การโหลดจริงสำหรับต้นไม้อุปกรณ์สุดท้าย เช่น หากอาร์กิวเมนต์ base เป็น 0x10000000 และอาร์กิวเมนต์ dtb_offset เป็น 0x01000000 ระบบจะป้อนข้อมูล dtb_addr_field ในส่วนหัวของภาพบูตเป็น 0x11000000 |
ต้องใช้ตัวแปรการกําหนดค่าบอร์ดและ BOARD_PREBUILT_DTBIMAGE_DIR
เพื่อระบุเส้นทางไปยังรูปภาพ DTB หากมีไฟล์ที่มีนามสกุล *.dtb
มากกว่า 1 ไฟล์ในไดเรกทอรี BOARD_PREBUILT_DTBIMAGE_DIR
ระบบการสร้างของ Android จะต่อไฟล์เข้าด้วยกันเพื่อสร้างรูปภาพ DTB สุดท้ายที่ใช้ในการสร้างรูปภาพบูต
หากต้องการส่งอาร์กิวเมนต์ dtb
ไปยัง mkbootimg.py
พร้อมภาพ DTB จากไดเรกทอรีที่ระบุโดย BOARD_PREBUILT_DTBIMAGE_DIR
คุณต้องตั้งค่าตัวแปรการกําหนดค่าบอร์ดตัว BOARD_INCLUDE_DTB_IN_BOOTIMG
เป็น true
เช่น
BOARD_INCLUDE_DTB_IN_BOOTIMG := true
คุณสามารถเพิ่มอาร์กิวเมนต์ dtb_offset
ต่อท้ายตัวแปร BOARD_MKBOOTIMG_ARGS
board
config ที่มีออฟเซตและเวอร์ชันส่วนหัวอื่นๆ เช่น
BOARD_MKBOOTIMG_ARGS := --ramdisk_offset $(BOARD_RAMDISK_OFFSET) --dtb_offset $(BOARD_DTB_OFFSET) --tags_offset $(BOARD_KERNEL_TAGS_OFFSET) --header_version $(BOARD_BOOTIMG_HEADER_VERSION)
การรองรับ Bootloader
หากต้องการให้ VTS ทำงานบนอุปกรณ์ที่ใช้ Android 10 ได้อย่างสมบูรณ์ โปรแกรมโหลดบูตต้องรองรับอิมเมจบูตที่อัปเดตแล้ว และต้องเพิ่มพารามิเตอร์บรรทัดคำสั่งของเคอร์เนล androidboot.dtb_idx
เพื่อระบุดัชนีของ Device Tree (DT) ที่เลือก คุณระบุดัชนีได้เพียง 1 รายการเท่านั้น ตัวอย่างเช่น พารามิเตอร์ androidboot.dtb_idx=N
จะรายงาน N
เป็นดัชนีฐาน 0 ของต้นไม้อุปกรณ์ที่บูตโหลดเดอร์เลือกจากชุด DTB ที่มีอยู่ในภาพการบูต
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา 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,["# DTB images\n\nAndroid implementations can include a device tree blob (DTB) image for use by\nthe bootloader. The location of the DTB image (and the options for specifying\nDTB image parameters) differs between Android releases.\n\n- In Android 11, devices using the [Generic Kernel\n Image (GKI)](/docs/core/architecture/kernel/generic-kernel-image) must\n support the [vendor boot\n partition](/docs/core/architecture/bootloader/partitions/vendor-boot-partitions),\n which includes all vendor-specific information that was relocated from the\n boot partition. Because the DTB image contains vendor-specific data, it's now\n part of the vendor boot partition. To specify DTB image parameters, see\n [Vendor boot\n header](/docs/core/architecture/bootloader/partitions/vendor-boot-partitions#vendor-boot-header).\n\n- In Android 10, devices can include the DTB image in\n the boot partition. To specify DTB image parameters, see [Including the DTB\n image in the boot image](#dtb-image-include).\n\n- In Android 9 and lower, the DTB image can exist in\n its own partition or be appended to the kernel `image.gz` to create the kernel\n + DTB image (which is then passed to `mkbootimg` to create `boot.img`).\n\nDTB image format\n----------------\n\nIn Android 10 and higher, the DTB image must use one\nof the following formats:\n\n- **DT blobs concatenated one after the other.** The bootloader uses the\n `totalsize` field in each FDT header to read and parse the corresponding blob.\n\n- **DTB/DTBO partitions.** The bootloader has an efficient way to select the\n correct DT blob by examining the `dt_table_entry` struct (contains `id`,\n `rev`, and `custom` fields) that can hold hardware identifying information for\n the entry. For details, see [DTB/DTBO\n Partitions](/docs/core/architecture/dto/partitions#structures).\n\nInclude the DTB image in the boot image\n---------------------------------------\n\nDevices running Android 10 can include the DTB image in\nthe boot image. This removes the need for Android to support scripts that append\nthe DTB image to `image.gz` in the kernel, and enables the use of [Vendor Test\nSuite (VTS)](/docs/compatibility/vts) test to verify (and standardize) DTB\nplacement.\n\nIn addition, for non-A/B devices, it's safer to have the DTB as part of the\nrecovery image rather than in a separate partition to prevent issues caused by\ninterrupted OTAs. During an OTA, if a problem occurs after the DTB partition is\nupdated (but prior to completing the full update), the device tries to boot into\nrecovery mode to complete the OTA; however, because the DTB partition has\nalready been updated, a mismatch could occur with the recovery image (which has\nnot yet been updated). Having the DTB image as part of the boot image format\nprevents such issues by making the recovery image self sufficient (that is, it\ndoesn't depend on another partition).\n\n### Boot image structure\n\nDevices running Android 10 can include a DTB image\nusing the following boot image structure.\n\n| Boot image section | Number of pages |\n|-----------------------------------|------------------------------------------------------------|\n| Boot header (1 page) | 1 |\n| Kernel (l pages) | l = (`kernel_size` + `page_size` - 1) / `page_size` |\n| Ramdisk (m pages) | m = (`ramdisk_size` + `page_size` - 1) / `page_size` |\n| Second stage bootloader (n pages) | n = (`second_size` + `page_size` - 1) / `page_size` |\n| Recovery DTBO (o pages) | o = (`recovery_dtbo_size` + `page_size` - 1) / `page_size` |\n| DTB (p pages) | p = (`dtb_size` + `page_size` - 1) / `page_size` |\n\n### DTB image path\n\nFor devices running Android 10, you can use the\n`mkbootimg.py` tool and the following arguments to specify the path to the DTB\nimage.\n\n| Argument | Description |\n|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `dtb` | Path to the DTB image to be included in the boot/recovery images. |\n| `dtb_offset` | When added to the `base` argument, provides the physical load address for the final device tree. For example, if the `base` argument is `0x10000000` and the `dtb_offset` argument is `0x01000000`, the `dtb_addr_field` in the boot image header is populated as `0x11000000`. |\n\nThe board config variable `BOARD_PREBUILT_DTBIMAGE_DIR` must be used to specify\nthe path to the DTB image. If more than one file with extension `*.dtb` is\npresent in the directory `BOARD_PREBUILT_DTBIMAGE_DIR`, the Android build system\nconcatenates the files to create the final DTB image used in the boot image\ncreation.\n\nTo pass the argument `dtb` to `mkbootimg.py` with the DTB image from the\ndirectory specified by `BOARD_PREBUILT_DTBIMAGE_DIR`, the board config variable\n`BOARD_INCLUDE_DTB_IN_BOOTIMG` must be set to `true`. For example: \n\n BOARD_INCLUDE_DTB_IN_BOOTIMG := true\n\nYou can append the `dtb_offset` argument to the `BOARD_MKBOOTIMG_ARGS` board\nconfig variable with the other offsets and header version. For example: \n\n BOARD_MKBOOTIMG_ARGS := --ramdisk_offset $(BOARD_RAMDISK_OFFSET) --dtb_offset $(BOARD_DTB_OFFSET) --tags_offset $(BOARD_KERNEL_TAGS_OFFSET) --header_version $(BOARD_BOOTIMG_HEADER_VERSION)\n\n### Bootloader support\n\nFor VTS to run successfully on devices running Android\n10, the bootloader must support the updated boot image\nand must add the `androidboot.dtb_idx` kernel command line parameter to indicate\nthe index of the selected device tree (DT). **You can specify only one (1)\nindex.** For example, the parameter `androidboot.dtb_idx=N` reports `N` as the\nzero-based index of the device tree selected by the bootloader from the set of\nDTBs present in the boot image."]]