ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
รูปภาพการกู้คืน
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ในอุปกรณ์ที่ไม่ใช่ A/B รูปภาพการกู้คืนควรมีข้อมูลจาก Device Tree Blob (DTB) หรือรูปภาพวางซ้อน Advanced Configuration and Power Interface (ACPI) เมื่ออุปกรณ์ดังกล่าวบูตเข้าสู่ Recovery แล้ว โปรแกรมโหลดบูตจะโหลดภาพวางซ้อนที่เข้ากันได้กับภาพการกู้คืนได้ อุปกรณ์ที่รองรับการอัปเดต A/B (แบบราบรื่น) ควรใช้การกู้คืนเป็นบูตแทนพาร์ติชันการกู้คืนแยกต่างหาก (ดูรายละเอียดที่การใช้การอัปเดต A/B)
ตัวเลือกในการรวม DTBO/ACPIO สำหรับการกู้คืนเป็นส่วนหนึ่งของภาพการบูต/การกู้คืนจะแตกต่างกันไปตามรุ่นของ Android
รุ่น |
อัปเดตรูปแบบ |
การปฏิบัติตามข้อกำหนดของ GKI |
เวอร์ชันส่วนหัวของบูต (อุปกรณ์ที่เปิดใช้งาน) |
เวอร์ชันส่วนหัวของบูต (การอัปเกรดอุปกรณ์) |
ต้องมีอิมเมจการกู้คืนเฉพาะ |
11 |
A/B, A/B เสมือนจริง |
ใช่ |
3* |
ไม่มี |
ไม่ |
A/B, A/B เสมือนจริง |
ไม่ |
2, 3 |
0, 1, 2, 3 |
ไม่ |
ไม่ใช่ A/B |
ใช่ |
3 |
ไม่มี |
ใช่ |
ไม่ใช่ A/B |
ไม่ |
2, 3 |
0, 1, 2, 3 |
ใช่ |
10 (Q) |
A/B |
ไม่มี |
2 |
0, 1, 2 |
ไม่ |
ไม่ใช่ A/B |
ไม่มี |
2 |
0, 1, 2 |
ใช่ |
9 (P) |
A/B |
ไม่มี |
1 |
0, 1 |
ไม่ |
ไม่ใช่ A/B |
ไม่มี |
1 |
0, 1 |
ใช่ |
8 (O) |
A/B |
ไม่มี |
ไม่มี (ถือว่า 0) |
ไม่มี (ถือว่า 0) |
ไม่ |
ไม่ใช่ A/B |
ไม่มี |
ไม่มี (ถือว่า 0) |
ไม่มี (ถือว่า 0) |
ใช่ |
* อุปกรณ์ A/B ที่ใช้ Android 11 ขึ้นไปและใช้ Generic Kernel Image (GKI) ต้องใช้ส่วนหัวของบูตเวอร์ชัน 3 หลักเพื่อให้ใช้งานร่วมกับพาร์ติชันบูตของผู้ให้บริการได้
ประเด็นสำคัญ
อุปกรณ์ A/B ไม่จำเป็นต้องระบุรูปภาพการกู้คืนเนื่องจากการอัปเดต A/B ใช้พาร์ติชัน 2 ชุด (รวมถึง boot
และ dtbo
) และเปลี่ยนไปมาระหว่างพาร์ติชันดังกล่าวในระหว่างการอัปเดต จึงไม่จำเป็นต้องใช้รูปภาพการกู้คืน อุปกรณ์ A/B จะยังคงใช้ภาพการกู้คืนเฉพาะได้
อุปกรณ์ที่ไม่ใช่ A/B ซึ่งเปิดตัวด้วย Android 11 ขึ้นไปและใช้ส่วนหัวบูตเวอร์ชัน 3 ต้องระบุส่วนหัวบูตเวอร์ชัน 2 อย่างชัดเจนสำหรับรูปภาพการกู้คืนแยกต่างหาก เช่น
BOARD_RECOVERY_MKBOOTIMG_ARGS := --header_version 2
สำหรับสถาปัตยกรรมที่ไม่รองรับ Device Tree อิมเมจการกู้คืนอาจมีอิมเมจ ACPIO แทนอิมเมจ DTBO
เกี่ยวกับการอัปเดต OTA ไม่สำเร็จและรูปภาพการกู้คืน
เพื่อป้องกันไม่ให้มีการอัปเดตผ่านอากาศ (OTA) ล้มเหลวในอุปกรณ์ที่ไม่ใช่ A/B รูปภาพการกู้คืนควรทำงานได้ด้วยตัวเองและแยกจากรูปภาพอื่นๆ ในระหว่างการอัปเดต OTA หากเกิดปัญหาขึ้นหลังจากอัปเดตรูปภาพวางซ้อนแล้ว (แต่ก่อนที่จะอัปเดตให้เสร็จสมบูรณ์) อุปกรณ์จะพยายามบูตเข้าสู่โหมดการกู้คืนเพื่ออัปเดต OTA ให้เสร็จสมบูรณ์ อย่างไรก็ตาม เนื่องจากพาร์ติชันการวางซ้อนได้รับการอัปเดตแล้ว จึงอาจเกิดความไม่ตรงกันกับรูปภาพการกู้คืน (ซึ่งยังไม่ได้อัปเดต)
เพื่อป้องกันไม่ให้การกู้คืนต้องอาศัยพาร์ติชัน DTBO/ACPIO ระหว่างการอัปเดต อุปกรณ์ที่ไม่ใช่ A/B ที่ใช้ Android 9 ขึ้นไปจะระบุรูปภาพ DTBO/ACPIO สำหรับการกู้คืนซึ่งมีข้อมูลจากรูปภาพการวางซ้อนเป็นส่วนแยกต่างหากในรูปแบบรูปภาพสำหรับบูตได้ (ต้องใช้ส่วนหัวสำหรับบูตเวอร์ชัน 1 หรือ 2)
การเปลี่ยนแปลงอิมเมจบูท
หากต้องการให้อิมเมจการกู้คืนมี DTBO หรือ ACPIO สำหรับการกู้คืนในอุปกรณ์ที่ไม่ใช่ A/B ที่ใช้ Android 9 ขึ้นไป ให้อัปเดตโครงสร้างอิมเมจการบูตดังนี้
ส่วนอิมเมจบูต |
จำนวนหน้า |
ส่วนหัวของบูต (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 หรือ ACPIO (หน้า o) |
o = (recovery_[dtbo|acpio]_size + page_size -
1) / page_size |
โปรดดูรายละเอียดเกี่ยวกับอาร์กิวเมนต์ของเครื่องมือ mkbootimg
สำหรับระบุเวอร์ชันส่วนหัวของภาพการบูตและเส้นทางรูปภาพการวางซ้อนที่หัวข้อการกำหนดเวอร์ชันส่วนหัวของภาพการบูต
ใช้งาน DTBO
อุปกรณ์ที่ไม่ใช่ A/B ที่ใช้ Android 9 ขึ้นไปจะป้อนข้อมูลในส่วน recovery_dtbo
ของภาพการกู้คืนได้ หากต้องการรวมrecovery_dtbo
รูปภาพใน recovery.img
ในอุปกรณ์ BoardConfig.mk
ให้ทำดังนี้
ตั้งค่า BOARD_INCLUDE_RECOVERY_DTBO
เป็น true
BOARD_INCLUDE_RECOVERY_DTBO := true
ขยายตัวแปร BOARD_MKBOOTIMG_ARGS
เพื่อระบุเวอร์ชันส่วนหัวของภาพสำหรับบูต ดังนี้
BOARD_MKBOOTIMG_ARGS := --ramdisk_offset $(BOARD_RAMDISK_OFFSET) --tags_offset $(BOARD_KERNEL_TAGS_OFFSET) --header_version $(BOARD_BOOTIMG_HEADER_VERSION)
ตรวจสอบว่ามีการกําหนดตัวแปร BOARD_PREBUILT_DTBOIMAGE
เป็นเส้นทางของรูปภาพ DTBO ระบบบิลด์ Android ใช้ตัวแปรเพื่อตั้งค่าอาร์กิวเมนต์ recovery_dtbo
ของเครื่องมือ mkbootimg
ในระหว่างการสร้างรูปภาพการกู้คืน
หากตั้งค่าตัวแปร BOARD_INCLUDE_RECOVERY_DTBO
, BOARD_MKBOOTIMG_ARGS
และ BOARD_PREBUILT_DTBOIMAGE
อย่างถูกต้อง ระบบการสร้างของ Android จะรวม DTBO ที่ระบุโดยตัวแปร BOARD_PREBUILT_DTBOIMAGE
ใน recovery.img
ใช้งาน ACPIO
อุปกรณ์ที่ไม่ใช่ A/B ที่ใช้ Android 9 ขึ้นไปสามารถใช้รูปภาพวางซ้อน ACPIO (แทนรูปภาพ DTBO) และสามารถป้อนข้อมูลในส่วน recovery_acpio
(แทนที่จะเป็นในส่วน recovery_dtbo
) ของรูปภาพการกู้คืน หากต้องการรวมรูปภาพ recovery_acpio
ใน recovery.img
ในอุปกรณ์ BoardConfig.mk
ให้ทำดังนี้
ตั้งค่า BOARD_INCLUDE_RECOVERY_ACPIO
เป็น true
BOARD_INCLUDE_RECOVERY_ACPIO := true
ขยายตัวแปร BOARD_MKBOOTIMG_ARGS
เพื่อระบุเวอร์ชันส่วนหัวของภาพสำหรับบูต ตัวแปรต้องมากกว่าหรือเท่ากับ 1 เพื่อรองรับการกู้คืน
ACPIO
BOARD_MKBOOTIMG_ARGS += --header_version $(BOARD_BOOTIMG_HEADER_VERSION)
ตรวจสอบว่าได้ตั้งค่าตัวแปร BOARD_RECOVERY_ACPIO
เป็นเส้นทางของรูปภาพ ACPIO ระบบบิลด์ Android ใช้ตัวแปรเพื่อตั้งค่าอาร์กิวเมนต์ recovery_acpio
ของเครื่องมือ mkbootimg
ในระหว่างการสร้างรูปภาพการกู้คืน
หากตั้งค่าตัวแปร BOARD_INCLUDE_RECOVERY_ACPIO
, BOARD_MKBOOTIMG_ARGS
และ BOARD_RECOVERY_ACPIO
อย่างถูกต้อง ระบบบิลด์ Android จะรวม ACPIO ที่ระบุโดยตัวแปร BOARD_RECOVERY_ACPIO
ใน recovery.img
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา 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,["# Recovery images\n\nOn non-A/B devices, the recovery image should contain information from a\n[device tree blob (DTB)](/docs/core/architecture/bootloader/dtb-images) or\n[Advanced Configuration and Power Interface\n(ACPI)](https://uefi.org/acpi/specs) overlay image. When such\ndevices boot into recovery, the bootloader can then load the overlay image that\nis compatible with the recovery image. Devices that support [A/B (seamless)\nupdates](/docs/core/ota/ab) should use recovery as boot instead of a\nseparate recovery partition (for details, see [Implementing A/B\nUpdates](/docs/core/ota/ab/ab_implement)).\n\nThe options for including a recovery DTBO/ACPIO as part of the boot/recovery\nimage differ between Android releases.\n\n| Release | Update scheme | GKI compliance | Boot header version (launching devices) | Boot header version (upgrading devices) | Dedicated recovery image required |\n|---------|------------------|----------------|-----------------------------------------|-----------------------------------------|-----------------------------------|\n| 11 | A/B, Virtual A/B | Yes | 3^\\*^ | N/A | No |\n| 11 | A/B, Virtual A/B | No | 2, 3 | 0, 1, 2, 3 | No |\n| 11 | non-A/B | Yes | 3 | N/A | Yes |\n| 11 | non-A/B | No | 2, 3 | 0, 1, 2, 3 | Yes |\n| 10 (Q) | A/B | N/A | 2 | 0, 1, 2 | No |\n| 10 (Q) | non-A/B | N/A | 2 | 0, 1, 2 | Yes |\n| 9 (P) | A/B | N/A | 1 | 0, 1 | No |\n| 9 (P) | non-A/B | N/A | 1 | 0, 1 | Yes |\n| 8 (O) | A/B | N/A | N/A (considered 0) | N/A (considered 0) | No |\n| 8 (O) | non-A/B | N/A | N/A (considered 0) | N/A (considered 0) | Yes |\n\n**\\*** *A/B devices running Android\n11 or higher and using the [Generic Kernel Image\n(GKI)](/docs/core/architecture/kernel/generic-kernel-image) must use a\nprimary [boot header version of\n3](/docs/core/architecture/bootloader/boot-image-header#header-v3) to be\ncompatible with the [vendor boot\npartition](/docs/core/architecture/bootloader/partitions/vendor-boot-partitions).*\n\nKey points:\n\n- A/B devices don't need to specify a recovery image as A/B updates use two sets\n of partitions (including `boot` and `dtbo`) and switch between them during\n updates, removing the need for a recovery image. A/B devices can\n still use a dedicated recovery image.\n\n- Non-A/B devices launching with Android 11 or higher\n and using a boot header version of 3 must explicitly specify a [boot header\n version of 2](/docs/core/architecture/bootloader/boot-image-header#header-v2)\n for the recovery image separately. For example:\n\n BOARD_RECOVERY_MKBOOTIMG_ARGS := --header_version 2\n\n- For architectures that don't support device trees, the recovery image can\n include an ACPIO image instead of a DTBO image.\n\nAbout OTA failures and recovery images\n--------------------------------------\n\nTo prevent over-the-air (OTA) failures on non-A/B devices, the recovery image\nshould be self-sufficient and independent of other images. During an OTA update,\nif a problem occurs after the overlay image has been updated (but prior to\ncompleting the full update), the device tries to boot into recovery mode to\ncomplete the OTA update. However, because the overlay partition has already been\nupdated, a mismatch could occur with the recovery image (which hasn't been\nupdated yet).\n\nTo prevent recovery from depending on the DTBO/ACPIO partition during an\nupdate, non-A/B devices running Android 9 or higher\ncan specify a recovery DTBO/ACPIO image containing information from the overlay\nimage as a separate section in the boot image format (must use a boot header\nversion of 1 or 2).\n\nBoot image changes\n------------------\n\nTo allow the recovery image to contain the recovery DTBO or ACPIO on non-A/B\ndevices running Android 9 or higher, update the boot\nimage structure as follows.\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 or ACPIO (o pages) | o = (`recovery_[dtbo|acpio]_size` + `page_size` - 1) / `page_size` |\n\nFor details on the `mkbootimg` tool arguments for specifying the boot image\nheader version and overlay image paths, see [Boot Image Header\nVersioning](/docs/core/architecture/bootloader/boot-image-header#implementing-versioning).\n\nImplement DTBO\n--------------\n\nNon-A/B devices running 9 or higher can populate the\n`recovery_dtbo` section of the recovery image. To include the `recovery_dtbo`\nimage in `recovery.img`, in the device `BoardConfig.mk`:\n\n- Set the config `BOARD_INCLUDE_RECOVERY_DTBO` to `true`:\n\n BOARD_INCLUDE_RECOVERY_DTBO := true\n\n- Extend the `BOARD_MKBOOTIMG_ARGS` variable to specify the boot image header\n version:\n\n BOARD_MKBOOTIMG_ARGS := --ramdisk_offset $(BOARD_RAMDISK_OFFSET) --tags_offset $(BOARD_KERNEL_TAGS_OFFSET) --header_version $(BOARD_BOOTIMG_HEADER_VERSION)\n\n- Ensure that the `BOARD_PREBUILT_DTBOIMAGE` variable is set to the path of the\n DTBO image. The Android build system uses the variable to set the\n `recovery_dtbo` argument of the `mkbootimg` tool during the creation of\n recovery image.\n\nIf the `BOARD_INCLUDE_RECOVERY_DTBO`, `BOARD_MKBOOTIMG_ARGS`, and\n`BOARD_PREBUILT_DTBOIMAGE` variables are set correctly, the Android build system\nincludes the DTBO specified by the `BOARD_PREBUILT_DTBOIMAGE` variable in\n`recovery.img`.\n\nImplement ACPIO\n---------------\n\nNon-A/B devices running Android 9 or higher can use\nan ACPIO overlay image (instead of a DTBO image) and can populate the\n`recovery_acpio` section (instead of the `recovery_dtbo` section) of the\nrecovery image. To include the `recovery_acpio` image in `recovery.img`, in the\ndevice `BoardConfig.mk`:\n\n- Set the config `BOARD_INCLUDE_RECOVERY_ACPIO` to `true`:\n\n BOARD_INCLUDE_RECOVERY_ACPIO := true\n\n- Extend the `BOARD_MKBOOTIMG_ARGS` variable to specify the boot image header\n version. The variable must be greater than or equal to 1 to support recovery\n ACPIO.\n\n BOARD_MKBOOTIMG_ARGS += --header_version $(BOARD_BOOTIMG_HEADER_VERSION)\n\n- Ensure that the `BOARD_RECOVERY_ACPIO` variable is set to the path of the\n ACPIO image. The Android build system uses the variable to set the\n `recovery_acpio` argument of the `mkbootimg` tool during the creation of the\n recovery image.\n\nIf the `BOARD_INCLUDE_RECOVERY_ACPIO`, `BOARD_MKBOOTIMG_ARGS`, and\n`BOARD_RECOVERY_ACPIO` variables are set correctly, the Android build system\nincludes the ACPIO specified by the `BOARD_RECOVERY_ACPIO` variable in\n`recovery.img`."]]