自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
ODM 分區
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Android 10 支援使用 Android 建構系統建構 odm
分區。
關於 ODM 分區
原始設計製造商 (ODM) 會將晶片系統 (SoC) 供應商的板級支援套件 (BSP) 自訂為特定裝置 (其板級)。這可讓他們為特定板子的元件、特定板子的守護程序,或在硬體抽象層 (HAL) 上實作自己的功能,實作核心模組。他們也可能會想要取代或自訂 SoC 元件。
在較舊的 Android 版本中,這類自訂設定會導致裝置無法使用單一供應商映像檔,即使裝置搭載相同的 SoC (或搭載不同 SoC,但屬於同一家族) 也是如此。在 Android 10 以上版本中,您可以使用單獨的 odm
分割區進行自訂,這樣就能將單一供應商映像檔用於多個硬體 SKU。
使用產品和 ODM 分區
Android 9 新增了建構 product
區隔的支援功能,可讓您使用單一系統映像檔,為不同 product.img
映像檔提供的多個軟體 SKU 提供服務。product
區隔區是用於軟體 SKU,odm
區隔區則是用於硬體 SKU。
透過專屬產品和 ODM 區隔,您可以使用 system
區隔來代管通用程式碼,以便在多個軟體 SKU 之間共用,並使用 vendor
區隔來代管 SoC 專屬 BSP 程式碼,以便在多個裝置之間共用特定 SoC。
使用個別分割區有其缺點,例如難以管理磁碟空間 (例如,您必須為日後的擴充預留有限的空間)。不過,Android 10 支援動態分割區,可解決磁碟問題,並在無線更新 (OTA) 期間重新分割裝置。
ODM 元件
odm
分區包含下列 ODM 專屬元件 (類似 vendor
分區),如下表所列。
ODM 專屬元件 |
位置 |
可載入的核心模組 (LKM) |
/odm/lib/modules/*.ko |
原生程式庫 |
/odm/lib[64] |
HAL |
/odm/lib[64]/hw |
SEPolicy |
/odm/etc/selinux |
VINTF 物件資料 |
/odm/etc/vintf |
init.rc
檔案 |
/odm/etc/init |
系統屬性 |
/odm/build.prop |
執行階段資源覆蓋 (RRO) |
/odm/overlay/*.apk |
應用程式 |
/odm/app/*.apk |
Priv-apps |
/odm/priv-app/*.apk |
Java 程式庫 |
/odm/framework/*.jar |
Android 架構系統設定 |
/odm/etc/sysconfig/* 和/odm/etc/permissions/* |
沒有自訂圖片
請勿使用自訂圖片,因為這類圖片不支援以下功能:
- 將模組安裝到特定目標。自訂映像檔可將構件複製到映像檔,但無法將模組安裝到特定分區,因為您無法將目標分區指定為建構規則的一部分。
- Soong。
custom_images
無法使用 Soong 建構系統進行建構。
- OTA 更新。自訂映像檔可用於無法透過 OTA 更新的出廠 ROM 映像檔。
維護分區之間的 ABI
odm
分區是 vendor
分區的擴充功能。考量應用程式二進位檔介面 (ABI) 穩定性時,請留意下列架構。
圖 1. 在分區之間維護 ABI。
odm
和 vendor
區隔之間沒有 ABI 穩定性。兩個分割區必須同時升級。
odm
和 vendor
分區可以彼此依賴,但 vendor
分區「必須」在沒有 odm
分區的情況下運作。
odm
和 system
之間的 ABI 與 vendor
和 system
之間的 ABI 相同。
product
分區與 vendor
或 odm
分區之間不允許直接互動。(這是由 SEpolicy 強制執行。)
實作 ODM 分區
實作新分割區前,請先查看相關的 AOSP 變更。
設定 ODM 分區
如要設定 odm
分割區,請加入下列建構標記:
BOARD_ODMIMAGE_PARTITION_SIZE
:固定分區大小
PRODUCT_USE_DYNAMIC_PARTITIONS
和 BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE
可用於設定動態分區大小
BOARD_ODMIMAGE_FILE_SYSTEM_TYPE
用於 ODM 映像檔的檔案系統類型
PRODUCT_ODM_PROPERTIES
適用於 /odm/build.prop
,可用於 $(call inherit-product path/to/device.mk)
內,如 PRODUCT_ODM_PROPERTIES += product.abc=ok
在 ODM 分區中安裝模組
使用這些建構標記,將模組安裝至 odm
分區:
Android.bp
的device_specific: true
Android.mk
的LOCAL_ODM_MODULE := true
啟用驗證開機程序
為避免惡意軟體竄改 odm
分區,請為這些分區啟用 Android 驗證啟動 (AVB) (就像為 vendor
和 system
分區啟用 AVB 一樣)。
如要啟用 AVB,請納入建構旗標 BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
。如要進一步瞭解如何在動態分區中設定 AVB,請參閱「AVB 設定變更」。
將 /odm 視為另一個 /vendor 分割區
為確保系統將 odm
分區視為 vendor
分區,請將任何硬式編碼的 vendor
參照替換為一組以硬體為導向的分區 (目前為 odm
和 vendor
)。平台中值得注意的 vendor
參照位置包括動態連結器、套件管理器和 shell/libc
。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。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,["# ODM partitions\n\nAndroid 10 includes support for building\n`odm` partitions using the Android build system.\n\nAbout ODM partitions\n--------------------\n\n\nOriginal design manufacturers (ODMs) customize system-on-chip (SoC) vendor\nboard-support packages (BSPs) to their specific devices (their boards). This\nenables them to implement kernel modules for board-specific components,\nboard-specific daemons, or their own features on hardware abstraction layers\n(HALs). They might also want to replace or customize SoC components.\n\n\nIn lower Android releases, such customizations prevented the use of a single\nvendor image for devices with the same SoC (or with different SoCs, but in the\nsame family). In Android 10 and higher, you can use a\nseparate `odm` partition for customizations, which enables you to\nuse a single vendor image for multiple hardware SKUs.\n\n### Use product and ODM partitions\n\n\nAndroid 9 added support for building\n[`product`\npartitions](/docs/core/architecture/bootloader/partitions/product-partitions), enabling the use of a single system image for multiple software\nSKUs supplied by different `product.img` images. While the\n`product` partition is intended for software SKUs, the\n`odm` partition is intended for hardware SKUs.\n\n\nWith dedicated product and ODM partitions, you can use the `system`\npartition to host generic code for sharing among many software SKUs, and the\n`vendor` partition to host SoC-specific BSP code to share among\nmultiple devices based on the given SoC.\n\n\nUsing separate partitions has disadvantages, such as the difficulty in managing\ndisk space (for example, you must reserve a limited amount of space for future\ngrowth). However, Android 10 support for\n[dynamic partitions](/docs/core/ota/dynamic_partitions)\nremoves the disk issue, and makes repartitioning a device during an\n[over-the-air (OTA)](/docs/core/ota) update possible.\n\n### ODM components\n\n\nThe `odm` partition contains the following ODM-specific components\n(similar to the `vendor` partition), listed in the following table.\n\n| ODM-specific component | Location |\n|-------------------------------------------------------------------------------------------------------------|-----------------------------------------------------|\n| Loadable kernel modules (LKMs) | `/odm/lib/modules/*.ko` |\n| Native libraries | `/odm/lib[64]` |\n| HALs | `/odm/lib[64]/hw` |\n| SEPolicy | `/odm/etc/selinux` |\n| [VINTF object data](/docs/core/architecture/vintf/objects) | `/odm/etc/vintf` |\n| [`init.rc` files](https://android.googlesource.com/platform/system/core/+/android16-release/init/README.md) | `/odm/etc/init` |\n| System properties | `/odm/build.prop` |\n| Runtime resource overlays (RROs) | `/odm/overlay/*.apk` |\n| Apps | `/odm/app/*.apk` |\n| Priv-apps | `/odm/priv-app/*.apk` |\n| Java libraries | `/odm/framework/*.jar` |\n| Android Framework system configs | `/odm/etc/sysconfig/*` and `/odm/etc/permissions/*` |\n\n### No custom images\n\n\nDon't use\n[custom\nimages](https://android.googlesource.com/platform/build/+/bc7e3f98f41108c03a06abbf98add08ad4a05040/cor\ne/tasks/build_custom_images.mk#53) because they lack support for the following:\n\n- **Installation of a module to a specific target.** Custom images support copying artifacts into an image, but can't install a module into a specific partition by specifying the target partition as a part of a build rule.\n- **Soong.** `custom_images` can't be built using the Soong build system.\n- **OTA update.** Custom images are used as factory ROM images that can't be OTA-ed.\n\n### Maintain ABIs between partitions\n\n\nThe `odm` partition is an extension of the `vendor`\npartition. When considering application binary interface (ABI) stability, keep\nthe following architecture in mind.\n\n**Figure 1.** Maintaining ABI between partitions.\n\n- There's no ABI stability between `odm` and `vendor` partitions. Both partitions must be upgraded at the same time.\n- The `odm` and `vendor` partitions can depend on each other, but the `vendor` partition **must** work without an `odm` partition.\n- The ABI between `odm` and `system` is the same as the ABI between `vendor` and `system`.\n\n\nDirect interaction between the `product` partition and the\n`vendor` or `odm` partition **isn't\nallowed**. (This is enforced by SEpolicy.)\n\nImplement ODM partitions\n------------------------\n\n\nBefore implementing a new partition, review the\n[related AOSP\nchanges](https://android-review.googlesource.com/q/topic:odm_partition_+OR+topic:odm_partition+(status:open+OR+status:merged)).\n\n### Set up ODM partitions\n\n\nTo set up `odm` partitions, include these build flags:\n\n- `BOARD_ODMIMAGE_PARTITION_SIZE` for a fixed partition size\n- `PRODUCT_USE_DYNAMIC_PARTITIONS` and `BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE` for a [dynamic partition](/docs/core/ota/dynamic_partitions) size\n- `BOARD_ODMIMAGE_FILE_SYSTEM_TYPE` file system type used for the ODM image\n- `PRODUCT_ODM_PROPERTIES` for `/odm/build.prop` for use within a `$(call inherit-product path/to/device.mk)`, as in `PRODUCT_ODM_PROPERTIES += product.abc=ok`\n\n### Install a module to an ODM partition\n\n\nUse these build flags to install a module to an `odm` partition:\n\n- `device_specific: true` in `Android.bp`\n- `LOCAL_ODM_MODULE := true` in `Android.mk`\n\n### Enable Verified Boot\n\n\nTo prevent malicious software from tampering with `odm` partitions,\nenable [Android Verified Boot\n(AVB)](/docs/security/features/verifiedboot/avb) for those partitions (just as you do for `vendor` and\n`system` partitions).\n\n\nTo enable AVB, include the build flag\n`BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS`. For details on configuring\nAVB on dynamic partitions, see\n[AVB configuration\nchanges](/docs/core/ota/dynamic_partitions/implement#avb-configuration-changes).\n\n### Treat /odm as another /vendor partition\n\n\nTo ensure that the system handles the `odm` partition as a\n`vendor` partition, replace any hard-coded `vendor`\nreferences with a set of hardware-oriented partitions (currently\n`odm` and `vendor`). Notable `vendor`\nreference locations in the platform include\n[dynamic\nlinker](https://android.googlesource.com/platform/bionic/+/android16-release/linker/),\n[package\nmanager](https://android.googlesource.com/platform/frameworks/base/+/android16-release/services/core/java/com/andr\noid/server/pm/PackageManagerService.java), and `shell/libc`."]]