自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
系統啟動載入程式總覽
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Bootloader 是供應商專屬的映像檔,負責在裝置上啟動核心。引導程序可保護裝置狀態,並負責初始化受信任的執行環境 (TEE),以及繫結信任根。系統啟動載入程式也會在將執行作業移至核心之前,驗證 boot
和 recovery
分割區的完整性。
系統啟動載入程式流程示例
以下是引導程式流程的示例:
載入並初始化記憶體。
根據驗證開機程序流程驗證裝置。
根據驗證開機程序流程,驗證啟動分區,包括 boot
、dtbo
、init_boot
和 recovery
。在這個步驟中,請檢查 啟動映像檔標頭版本,並據此剖析標頭。
如果使用 A/B 更新,請判斷要啟動的目前插槽。
判斷是否應開機至復原模式。詳情請參閱「支援 OTA 更新」。
載入開機映像檔,例如 boot.img
、vendor_boot.img
、init_boot.img
和其他專屬供應商開機映像檔。這些開機映像檔包含核心和 ramdisk 映像檔。
將核心載入記憶體,做為可自行執行的壓縮二進位檔。核心會自行解壓縮,並開始在記憶體中執行。
將 ramdisk 和 bootconfig 區段載入記憶體,以建立 initramfs
。
其他與啟動載入程式相關的功能
以下列出可實作的其他引導程式相關功能:
裝置樹狀結構疊加層 (DTO)。裝置樹狀結構疊加層可讓引導程式支援不同的硬體設定。DTO 會編譯為系統啟動載入程式使用的裝置樹狀結構 blob (DTB)。
隨機產生核心映像檔虛擬位址。引導程式可隨機產生載入核心映像檔的虛擬位址。如要隨機產生位址,請在核心設定檔中將 RANDOMIZE_BASE
設為 true
。啟動載入程式必須在 /chosen/kaslr-seed
裝置樹狀結構節點中傳遞隨機 u64 值,以提供熵。
驗證開機程序:驗證開機程序可讓啟動載入程式確保所有執行程式碼皆來自可信任的來源。
啟動設定
開機設定可在 Android 12 以上版本中使用,這是一種機制,可將設定詳細資料從建構和啟動載入程式傳遞至作業系統。在 Android 12 之前,會使用前置符號為 androidboot
的核心指令列參數。
無線更新 (OTA)。現場的 Android 裝置可以接收並安裝系統、應用程式軟體和時區規則的 OTA 更新。這項功能會影響您的引導程式導入作業。如需 OTA 的一般資訊,請參閱「OTA 更新」。如需系統啟動載入程式專屬 OTA 實作詳細資訊,請參閱「支援 OTA 更新」。
版本繫結。版本繫結會將安全性金鑰繫結至作業系統和修補程式等級版本。版本繫結可確保攻擊者在舊版系統或 TEE 軟體中發現弱點時,無法將裝置回溯至有安全漏洞的版本,並使用新版建立的金鑰。引導程式必須提供特定資訊,才能支援版本繫結。詳情請參閱「AVB 資源中的版本資訊」。
核心指令列
將以下位置的核心指令列連接起來:
自 Android 12 起,如果需要將 androidboot.*
參數傳遞至 Android 使用者空間,我們可以使用 bootconfig 取代核心指令列。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。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,["# 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."]]