自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
啟用 16 KB 切換鈕
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
16 KB 切換鈕可讓您試用 16 KB 核心。這個切換鈕可在 4 KB 核心和 16 KB 核心之間切換,並位於設定應用程式的「開發人員選項」選單中。16 KB 切換鈕可用於檢查應用程式與 16 KB 核心的相容性,但由於在 16 KB 模式下使用子頁面區塊 (使用 EXT4 的 /data
和 /metadata
分區),因此可能無法反映實際的 16 KB 裝置效能。
設定切換按鈕的步驟
請確認裝置已將變數設為不區分頁面 (可同時搭配 4 KB 和 16 KB 頁面大小的核心運作)。建議您直接安裝 16k 核心,確保裝置可在 16 KB 模式下運作,然後再繼續新增開發人員選項。請參閱虛擬裝置範例的目標設定。
PRODUCT_NO_BIONIC_PAGE_SIZE_MACRO := true
PRODUCT_MAX_PAGE_SIZE_SUPPORTED := 16384
設定產品變數,在設定中顯示開發人員選項
PRODUCT_16K_DEVELOPER_OPTION := true
使用 BOARD_KERNEL_PATH_16K
設定核心路徑。這個核心應使用 CONFIG_ARM64_16K_PAGES=y.
建構
BOARD_KERNEL_PATH_16K := kernel/prebuilts/mainline/$(TARGET_KERNEL_ARCH)/16k/kernel-mainline.
設定模組設定路徑變數 BOARD_KERNEL_MODULES_16K
。這個變數會指向支援 16 KB 的核心模組。設定這些參數會在系統分區上建立兩個 OTA:boot_ota_16k.zip
(切換至 16 KB 核心) 和 boot_ota_4k.zip
(切換至 4 KB 核心)。為較小大小的啟動 OTA 設定 BOARD_16K_OTA_USE_INCREMENTAL := true
,啟用遞增 OTA。
BOARD_KERNEL_MODULES_16K += $(wildcard kernel/prebuilts/mainline/$(TARGET_KERNEL_ARCH)/16k/*.ko)
BOARD_KERNEL_MODULES_16K += $(wildcard kernel/prebuilts/common-modules/virtual-device/mainline/$(TARGET_KERNEL_ARCH)/16k/*.ko)
設定 BOARD_16K_OTA_MOVE_VENDOR := true
以將 OTA 移至供應商分區。請只將此值設為將 OTA 從系統移至供應商分區。
驗證
成功設定切換鈕後,請按照下列步驟操作:
- 檢查設定應用程式中是否顯示「以 16 KB 頁面大小啟動」切換鈕。
- 檢查
/system/boot_otas
或 /vendor/boot_otas
是否包含兩個 OTA ZIP 檔案:boot_ota_16k.zip
和 boot_ota_4k.zip
。
使用 16 KB 切換鈕
- 依序前往「設定」>「系統」>「軟體更新」,然後套用任何可用的更新。
- 啟用開發人員選項。如需操作說明,請參閱「設定裝置端開發人員選項」。
- 如果系統偵測到裝置已鎖定 OEM,系統會顯示對話方塊,要求您解鎖手機。如需操作說明,請參閱「鎖定及解除鎖定系統啟動載入程式」。
- 按一下「Boot with 16 KB page size」。如果
/data
和 /metadata
不是 ext4,系統會顯示對話方塊,要求您清除裝置。按一下「清除所有資料」即可清除裝置資料。裝置會遭到清除,您必須再次啟用開發人員選項。
- 按一下「Boot with 16 KB page size」。系統會顯示對話方塊,要求您切換至 16 KB,並在確認後套用啟動 OTA。接著,您就可以在 4 KB 和 16 KB 模式之間來回切換,無須清除資料分區即可測試應用程式行為。
檢查 16 KB 模式
請按照「取得頁面大小」中的步驟驗證頁面大小。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。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,["# Enable 16 KB toggle\n\n16 KB toggle lets you to try a 16 KB kernel. This toggle switches\nbetween a 4 KB kernel and 16 KB kernel and can be found inside the\n\"Developer option\" menu in the settings app. The 16 KB toggle can be used\nto check application compatibility with the 16 KB kernel, but it might not\nreflect performance of actual 16 KB device due to the use of subpage blocks\n(when using EXT4 for `/data` and `/metadata` partitions) in 16 KB mode.\n\nSteps for configuring toggle\n----------------------------\n\n1. Make sure the device has set up the variables to be page-agnostic (to work\n with both 4 KB and 16 KB page size kernels).\n You may want to install the 16k kernel directly to make sure the device works in\n 16 KB mode directly before continuing to add the developer option.\n See the virtual device example [target config](https://cs.android.com/android/platform/superproject/+/android-latest-release:device/google/cuttlefish/vsoc_arm64_pgagnostic/phone/aosp_cf.mk;l=68).\n\n PRODUCT_NO_BIONIC_PAGE_SIZE_MACRO := true\n PRODUCT_MAX_PAGE_SIZE_SUPPORTED := 16384\n\n2. Setup product variable to display developer option in settings\n `PRODUCT_16K_DEVELOPER_OPTION := true`\n\n3. Set kernel path using `BOARD_KERNEL_PATH_16K`.\n This kernel should be built with `CONFIG_ARM64_16K_PAGES=y.`\n\n BOARD_KERNEL_PATH_16K := kernel/prebuilts/mainline/$(TARGET_KERNEL_ARCH)/16k/kernel-mainline.\n\n4. Set modules config path variable `BOARD_KERNEL_MODULES_16K`. This variable\n points to kernel modules which support 16KB. Setting these parameters creates\n two OTAs on the system partition : `boot_ota_16k.zip`(to switch to 16 KB\n kernel) and `boot_ota_4k.zip`(to switch to 4 KB kernel). Enable incremental\n OTAs by setting `BOARD_16K_OTA_USE_INCREMENTAL := true` for smaller size boot\n OTAs.\n\n BOARD_KERNEL_MODULES_16K += $(wildcard kernel/prebuilts/mainline/$(TARGET_KERNEL_ARCH)/16k/*.ko)\n BOARD_KERNEL_MODULES_16K += $(wildcard kernel/prebuilts/common-modules/virtual-device/mainline/$(TARGET_KERNEL_ARCH)/16k/*.ko)\n\n5. Set `BOARD_16K_OTA_MOVE_VENDOR := true` to move OTAs to the vendor partition.\n Only set this to move OTAs from system to vendor partition.\n\n### Verification\n\nAfter successfully configuring the toggle, follow these steps:\n\n1. Check if **Boot with 16 KB page size** toggle is visible in settings app.\n2. Check if `/system/boot_otas` or `/vendor/boot_otas` contains two OTA zip files : `boot_ota_16k.zip` and `boot_ota_4k.zip`.\n\nUse 16 KB toggle\n----------------\n\n1. Go to **Settings \\\u003e System \\\u003e Software updates** and apply any updates which are available.\n2. Enable developer options. For instructions, see [Configure on-device developer options](https://developer.android.com/studio/debug/dev-options).\n3. If the device is detected as OEM locked, a dialog displays asking you to OEM unlock the phone. For instructions, see [Lock and unlock the bootloader](/docs/core/architecture/bootloader/locking_unlocking).\n4. Click **Boot with 16 KB page size** . If `/data` and `/metadata`aren't ext4, a dialog displays asking you to wipe the device. Click **Erase all data** to wipe the device. The device is wiped and you must enable developer options again.\n5. Click **Boot with 16 KB page size**. A dialog displays asking you to switch to 16 KB, and on confirming, boot OTAs are applied. You can then toggle back and forth between 4 KB and 16 KB mode without clearing the data partition to test app behavior.\n\nCheck 16 KB Mode\n----------------\n\nFollow steps at [getting page size](/docs/core/architecture/16kb-page-size/getting-page-size)\nto verify page size."]]