ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
ภาพรวมของ Bootloader
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Bootloader คืออิมเมจที่เป็นกรรมสิทธิ์ของผู้ให้บริการซึ่งมีหน้าที่เรียกใช้เคอร์เนลในอุปกรณ์ บูตโหลดเดอร์จะปกป้องสถานะของอุปกรณ์และมีหน้าที่ในการเริ่มต้นสภาพแวดล้อมการดำเนินการที่เชื่อถือได้ (TEE) และเชื่อมโยงรูทของความน่าเชื่อถือ นอกจากนี้ บูตโหลดเดอร์จะตรวจสอบความสมบูรณ์ของพาร์ติชัน boot
และ recovery
ก่อนส่งต่อการดำเนินการไปยังเคอร์เนล
ตัวอย่างขั้นตอนของ Bootloader
ตัวอย่างขั้นตอนการทำงานของโปรแกรมโหลดบูตมีดังนี้
โหลดและเริ่มต้นหน่วยความจำ
ยืนยันอุปกรณ์ตามขั้นตอนการเปิดเครื่องที่ยืนยันแล้ว
ยืนยันพาร์ติชันสำหรับบูต ซึ่งรวมถึง boot
, dtbo
, init_boot
และ recovery
ตามขั้นตอนการเปิดเครื่องที่ได้รับการยืนยัน ในขั้นตอนนี้ ให้ตรวจสอบเวอร์ชันของส่วนหัวของภาพสำหรับบูตและแยกวิเคราะห์ส่วนหัวดังกล่าว
หากใช้การอัปเดต A/B ให้ระบุช่องปัจจุบันที่จะบูต
พิจารณาว่าควรบูตโหมดการกู้คืนหรือไม่ ดูข้อมูลเพิ่มเติมได้ในการรองรับการอัปเดต OTA
โหลดอิมเมจบูต เช่น boot.img
, vendor_boot.img
, init_boot.img
และอิมเมจบูตของผู้ให้บริการที่เป็นกรรมสิทธิ์อื่นๆ รูปภาพสำหรับบูตเหล่านี้จะมีรูปภาพเคอร์เนลและแรมดิสก์
โหลดเคอร์เนลลงในหน่วยความจำเป็นไบนารีที่บีบอัดซึ่งสามารถทำงานได้เอง เคอร์เนลจะคลายการบีบอัดตัวเองและเริ่มดำเนินการในหน่วยความจำ
โหลด RAM disk และส่วน bootconfig ลงในหน่วยความจำเพื่อสร้าง initramfs
ฟีเจอร์เพิ่มเติมที่เกี่ยวข้องกับบูตโหลดเดอร์
ต่อไปนี้คือรายการฟีเจอร์เพิ่มเติมที่เกี่ยวข้องกับบูตโหลดเดอร์ที่คุณนำไปใช้ได้
การวางซ้อนแผนผังอุปกรณ์ (DTO)
การวางซ้อน Device Tree ช่วยให้โปรแกรมโหลดบูตรองรับการกำหนดค่าฮาร์ดแวร์ที่แตกต่างกัน DTO จะคอมไพล์เป็น device
tree blob (DTB) ซึ่งบูตโหลดเดอร์ใช้
การสุ่มที่อยู่เสมือนของภาพเคอร์เนล บูตโหลดเดอร์รองรับการทำให้ที่อยู่เสมือนที่จะโหลดรูปภาพเคอร์เนลเป็นแบบสุ่ม หากต้องการสุ่มที่อยู่ ให้ตั้งค่า RANDOMIZE_BASE
เป็น true
ในการกำหนดค่าเคอร์เนล
บูตโหลดเดอร์ต้องระบุข้อมูลความผันผวนโดยการส่งค่า u64 แบบสุ่มในโหนด/chosen/kaslr-seed
Device Tree
การเปิดเครื่องที่ได้รับการยืนยัน การเปิดเครื่องที่ได้รับการยืนยันช่วยให้บูตโหลดเดอร์ตรวจสอบได้ว่าโค้ดที่เรียกใช้ทั้งหมดมาจากแหล่งที่มาที่เชื่อถือได้
การกําหนดค่าการบูต
การกำหนดค่าการบูตพร้อมใช้งานใน Android 12 ขึ้นไป และเป็นกลไกในการส่งรายละเอียดการกำหนดค่าจากบิลด์และบูตโหลดเดอร์ไปยังระบบปฏิบัติการ
ก่อนที่จะมี Android 12 ระบบจะใช้พารามิเตอร์บรรทัดคำสั่งของเคอร์เนลที่มีคำนำหน้าเป็น androidboot
การอัปเดตผ่านอากาศ (OTA) อุปกรณ์ Android ที่ใช้อยู่สามารถรับและติดตั้งการอัปเดต OTA ของระบบ ซอฟต์แวร์แอป และกฎเขตเวลา ฟีเจอร์นี้ส่งผลต่อการใช้งานบูตโหลดเดอร์ ดูข้อมูลทั่วไปเกี่ยวกับ OTA ได้ที่การอัปเดต OTA โปรดดูรายละเอียดการใช้งาน OTA สำหรับบูตโหลดเดอร์ที่เฉพาะเจาะจงที่หัวข้อการรองรับการอัปเดต OTA
การเชื่อมโยงเวอร์ชัน
การเชื่อมโยงเวอร์ชันจะเชื่อมโยงคีย์ความปลอดภัยกับระบบปฏิบัติการและเวอร์ชันระดับแพตช์ การเชื่อมโยงเวอร์ชันช่วยให้มั่นใจได้ว่าผู้โจมตีที่ค้นพบจุดอ่อนในระบบหรือซอฟต์แวร์ TEE เวอร์ชันเก่าจะไม่สามารถย้อนกลับอุปกรณ์กลับไปใช้เวอร์ชันที่มีช่องโหว่และใช้คีย์ที่สร้างขึ้นในเวอร์ชันใหม่ได้ บูตโหลดเดอร์ต้องให้ข้อมูลบางอย่างเพื่อรองรับการเชื่อมโยงเวอร์ชัน ดูข้อมูลเพิ่มเติมได้ที่ข้อมูลเวอร์ชันในพร็อพเพอร์ตี้ AVB
บรรทัดคำสั่งของเคอร์เนล
ต่อบรรทัดคำสั่งเคอร์เนลจากตำแหน่งต่อไปนี้
บรรทัดคำสั่งของ Bootloader: ชุดพารามิเตอร์แบบคงที่และแบบไดนามิกที่ Bootloader กําหนด
แผนผังอุปกรณ์: จากโหนด chosen/bootargs
defconfig
: จาก CONFIG_CMDLINE
boot.img
: จากบรรทัดคำสั่ง (สำหรับออฟเซตและขนาด ให้ดูที่ system/core/mkbootimg/bootimg.h
ตั้งแต่ Android 12 เป็นต้นไป เราจะใช้ bootconfig แทนบรรทัดคำสั่งเคอร์เนลสำหรับพารามิเตอร์ androidboot.*
ที่ต้องส่งไปยังพื้นที่ผู้ใช้ของ Android
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา 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,["# Bootloader overview\n\nA *bootloader* is a vendor-proprietary image responsible for bringing up the\nkernel on a device. The bootloader guards the device state and is responsible\nfor initializing the [Trusted Execution Environment (TEE)](/docs/security/features/trusty)\nand binding its root of trust. The bootloader also verifies the integrity of the\n`boot` and `recovery` partitions before moving execution to the kernel.\n\nExample bootloader flow\n-----------------------\n\nHere's an example bootloader flow:\n\n1. Load and initialize memory.\n\n2. Verify the device according to [Verified Boot flow](/docs/security/features/verifiedboot).\n\n3. Verify the boot partitions, including `boot`, `dtbo`, `init_boot`, and\n `recovery`, according to the Verified Boot flow. As part of this step, check the\n [boot image header](/docs/core/architecture/bootloader/boot-image-header)\n version and parse the header accordingly.\n\n4. If [A/B updates](/docs/core/ota/ab) are used, determine the current slot to\n boot.\n\n5. Determine if recovery mode should be booted. For more\n information, see\n [Supporting OTA Updates](/docs/core/architecture/bootloader/updating).\n\n6. Load the boot images, such as `boot.img`, `vendor_boot.img`,\n `init_boot.img`, and other proprietary vendor boot images. These boot images\n contain the kernel and ramdisk images.\n\n 1. Load the kernel into memory as a self-executable compressed\n binary. The kernel decompresses itself and starts executing into memory.\n\n 2. Load ramdisks and the bootconfig section into memory\n to create `initramfs`.\n\nAdditional bootloader-related features\n--------------------------------------\n\nFollowing is a list of additional bootloader-related features that you can\nimplement:\n\n- *Device tree overlay (DTO).*\n A [device tree overlay](/docs/core/architecture/dto) lets the bootloader to\n support different hardware configurations. A DTO is compiled into a *device\n tree blob (DTB)* which is used by the bootloader.\n\n- *Kernel image virtual address randomization.* The bootloader supports\n randomizing the virtual address at which the kernel image is loaded. To\n randomize the address, set `RANDOMIZE_BASE` to `true` in the kernel config.\n The bootloader must provide entropy by passing a random u64 value in the\n `/chosen/kaslr-seed` device tree node.\n\n- *Verified Boot.* [Verified Boot](/docs/security/features/verifiedboot) lets\n the bootloader to ensure all executed code comes from a trusted source.\n\n- *Boot config.*\n [Boot config](/docs/core/architecture/bootloader/implementing-bootconfig)\n is available in Android 12 and higher and is a mechanism for passing\n configuration details from the build and bootloader to the operating system.\n Prior to Android 12, kernel command-line parameters with the prefix of\n `androidboot` are used.\n\n- *Over-the-air (OTA) updates.* Android devices in the field can receive and\n install OTA updates to the system, app software, and\n time zone rules. This feature has implications on your bootloader\n implementation. For general information on OTA, see\n [OTA updates](/docs/core/ota). For bootloader-specific OTA implementation\n details, see\n [Supporting OTA updates](/docs/core/architecture/bootloader/updating).\n\n- *Version binding* .\n [Version binding](/docs/security/features/keystore/version-binding) binds\n security keys to the operating system and patch level version. Version binding\n ensures that an attacker who discovers a weakness in an old version of the\n system or the TEE software can't roll a device back to the vulnerable version\n and use keys created with the newer version. The bootloader must provide certain\n information to support version binding. For further information, see\n [Version information in AVB properties](/docs/core/architecture/bootloader/version-info-avb).\n\nKernel command line\n-------------------\n\nConcatenate the kernel command line from the following locations:\n\n- Bootloader command line: set of static and dynamic parameters determined by\n the bootloader\n\n- Device tree: from the `chosen/bootargs` node\n\n- `defconfig`: from `CONFIG_CMDLINE`\n\n- `boot.img`: from the command line (for offsets and sized, refer to\n [`system/core/mkbootimg/bootimg.h`](https://android.googlesource.com/platform/system/tools/mkbootimg/+/refs/heads/android16-release/include/bootimg/bootimg.h)\n\nAs of Android 12, for `androidboot.*` parameters that\nwe need to pass to Android userspace, we can use\n[bootconfig](/docs/core/architecture/bootloader/implementing-bootconfig) instead\nof the kernel command line."]]