自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
管理啟動時間
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
開機程序是一系列動作,從開機 ROM 開始,接著是系統啟動載入程式、核心、Init、Zygote 和系統伺服器 (粗體字代表 Android 專屬的開機程序)。在汽車專用開機程序中,後視攝影機 (RVC) 等早期服務必須在核心開機期間啟動。
訂購 |
元件 |
Android |
Android Automotive |
1 |
開機 ROM |
將啟動載入程式的第一階段載入至內部 RAM。 |
2 |
系統啟動載入程式 |
初始化記憶體、驗證安全性,並載入核心。 |
3 |
核心 |
設定中斷控制器、記憶體保護、快取和排程;啟動使用者空間程序。 |
後視攝影機 (RVC) 程序會在核心啟動時啟動。程序啟動後,來自 VMCU 的 GPIO 會觸發 RVC,並顯示在螢幕上。 |
4 |
初始化程序 |
剖析 init.rc 指令碼、掛載檔案系統、啟動 Zygote、啟動系統程序。 |
Vehicle HAL (VHAL) 會在初始化階段啟動,做為核心服務的一部分。可根據 ServiceManager 移至較早的狀態;需要移除對共用程式庫的依附元件 (例如 init)。 |
5 |
合子 |
為 Android 物件設定 Java 執行階段和初始化記憶體。 |
6 |
系統伺服器 |
系統中的第一個 Java 元件,可啟動核心 Android 服務。 |
CarService 會在所有系統服務啟動後啟動。 |
縮短啟動時間
如要縮短系統的啟動時間,請遵循下列指南:
為協助您進行最佳化,Google 提供下列工具:
提早啟動服務
在開機順序中,部分服務可能會在 Android 開始開機前啟動。
後視鏡頭
後視攝影機 (RVC) 應在核心中處理。當車輛切換為倒車時,VMCU 會通知原生核心程序,接著原生核心程序會將 RCV 圖像顯示在螢幕上。車輛 HAL 可使用 hardware/libhardware/include/hardware/vehicle_camera.h
控制 RVC。
車輛 HAL (VHAL)
在等待使用者空間服務啟動 (會在啟動序列的後期發生) 時,某些系統可能需要在啟動序列的早期階段讀取及緩衝 CAN 資料 (例如車速、變速箱狀態)。在這種情況下,VNS、HAL 和 CAN 控制器必須盡早啟動,通常在幾秒內。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。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,["# Manage boot time\n\nThe boot process is a chain of actions starting from the boot ROM, followed by the bootloader,\nkernel, **Init** , **Zygote** , and **system server** (bold\nindicates Android-specific boot process). In the automotive-specific boot process, early services\nsuch as rearview camera (RVC) must start during the kernel boot.\n\n| Order | Component | Android | Android Automotive |\n|-------|---------------|----------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| 1 | Boot ROM | Loads the first stage of the boot loader into internal RAM. ||\n| 2 | Bootloader | Inits memories, verifies for security, and loads kernel. ||\n| 3 | Kernel | Sets up interrupt controllers, memory protection, caches, and scheduling; launches user space processes. | **Rearview camera (RVC)** process starts early in kernel boot. After the process is up, GPIO from VMCU triggers RVC to show on display. |\n| 4 | Init process | Parses `init.rc` scripts, mounts file systems, launches Zygote, launches system process. | **Vehicle HAL (VHAL)** starts during init phase as part of core services. Can be moved to earlier states depending on ServiceManager; requires removing dependencies on shared libraries (such as init). |\n| 5 | Zygote | Sets up Java Runtime and init memory for Android objects. ||\n| 6 | System server | First Java component in the system, starts core Android services. | **CarService** starts after all system services are started. |\n\nOptimize boot time\n------------------\n\nTo improve boot time in your system, use the following guidelines:\n\n- **Kernel.** Load only the modules in use and initialize only the hardware\n components in use.\n\n- `init.rc`\n\n - Watch for blocking operations (service compared to command invocation).\n - Start only what is used.\n - Setting correct priority for services.\n- **Zygote.** Class preloading optimization (specify the list of classes to\n load).\n\n- **Package Manager**\n\n - Optimize product image to include only APKs in use.\n\n - [Enable DEX\n preoptimization](/docs/core/runtime/configure#compilation_options).\n\n- **System server.** Start only the system services that are used.\n\nFor help with optimization, Google provides the following tools:\n\n- Use `packages/services/Car/tools/bootanalyze/bootanalyze.py` to analyze logcat and\n dmesg logs.\n\n- Use `packages/services/Car/tools/bootio/` to record I/O for processes during the\n boot. You must compile the kernel with specific flags (refer to the `README.md`\n file).\n\nStart services early\n--------------------\n\nIn the boot sequence, some services might start before Android starts to boot.\n\n### Rearview camera\n\nThe rearview camera (RVC) should be handled in the kernel. The VMCU notifies the native kernel\nprocess when the vehicle shifts into Reverse, after which the native kernel process displays the\nRVC image onto the display. The vehicle HAL can control the RVC using\n`hardware/libhardware/include/hardware/vehicle_camera.h`.\n\n### Vehicle HAL (VHAL)\n\nSome systems might need to read and buffer CAN data (for example, vehicle speed, gear status)\nduring the early stages of the boot sequence while waiting for the user-space service to start\n(which occurs later in the boot sequence). This scenario requires VNS and the HAL and CAN\ncontrollers to start very early, typically within a few seconds.\n\n- Systems that can quickly mount `/system` can simply launch service manager then\n VNS early.\n\n- System that can't quickly mount `/system` must move both service manager and VNS\n to the kernel boot image and link all dependent libraries statically."]]