自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
启用 16 KB 切换开关
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
借助 16 KB 切换开关,您可尝试 16 KB 内核。此切换开关可在 4 KB 内核和 16 KB 内核之间切换,可在设置应用的“开发者选项”菜单中找到。16 KB 切换开关可用于检查应用与 16 KB 内核的兼容性,但由于在 16 KB 模式下使用子页面块(针对 /data
和 /metadata
分区使用 EXT4 时),它可能无法反映实际 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
。它指向支持 16KB 的内核模块。设置这些参数会在系统分区上创建两个 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 移至供应商分区。这是可选操作,大多数设备不应设置此项。
验证
成功完成此设置后
- 用户选中“以 16KB 页面大小启动设备”后,“设置”应用中会显示 16 KB 切换开关。
/system/boot_otas
或 /vendor/boot_otas
包含两个 OTA ZIP 文件:boot_ota_16k.zip
和 boot_ota_4k.zip
。
使用 16 KB 切换开关
- 按照开发者选项文档中的指示启用开发者选项。
- 如果检测到设备受 OEM 锁定,系统会显示一个对话框,请用户对手机进行 OEM 解锁。按照相应步骤进行 OEM 解锁。
- 当用户选中“以 16KB 页面大小启动设备”时,
/data
和 /metadata
分区必须为 ext4。否则,系统会显示一个对话框,要求用户擦除设备数据。回答“是”会擦除设备数据,并且您必须再次启用开发者选项。
- 16 KB 切换开关现在会显示一个确认切换到 16 KB 的对话框;用户确认后,系统会应用启动 OTA。然后,您可以在 4 KB 到 16 KB 模式之间来回切换,而无需清空数据分区以测试应用行为。
检查 16 KB 模式
按照获取页面大小中的步骤操作,验证页面大小。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-26。
[null,null,["最后更新时间 (UTC):2025-03-26。"],[],[],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."]]