自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
在 ARM64 上使用页面大小为 16 KB 的 Cuttlefish
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
此设置需要使用 ARM64
Linux 主机。本页介绍了如何在 ARM64
上构建和启动支持 16 KB 页面大小的 Cuttlefish。本页面中的说明假定您的机器中已安装 Cuttlefish 软件包。如需查看安装说明,请参阅安装 Cuttlefish 的第 1 步。
若要启动 Cuttlefish,您可以直接从 Android 持续集成网站下载预构建制品,也可以从 AOSP 构建它们(如果您需要修改源代码)。
通过下载制品来启动 Cuttlefish
前往 Android 持续集成网站,并输入 aosp-main-throttled
作为分支名称。点击 aosp_cf_arm64_phone_pgagnostic
目标的最新 build。现在,请按照安装 Cuttlefish 的第 5 步中的说明操作。
通过从 AOSP 进行构建来启动 Cuttlefish
构建和启动设有与页面无关的目标的 Cuttlefish:
$ mkdir android-latest-branch && cd android-latest-branch
$ repo init -u https://android.googlesource.com/platform/manifest -b android-latest-release
$ repo sync -c -j32
# Build cf agnostic target.
$ source build/envsetup.sh
$ lunch aosp_cf_arm64_phone_pgagnostic-trunk_staging-userdebug
$ m
# Launch cf with a kernel with 16 KB page size support.
$ launch_cvd
...
...
VIRTUAL_DEVICE_DISPLAY_POWER_MODE_CHANGED
virtio_input_hid_handle_status: unknown type 20
virtio_input_hid_handle_status: unknown type 20
virtio_input_hid_handle_status: unknown type 20
virtio_input_hid_handle_status: unknown type 20
Generating new secret with slot ID: 4
VIRTUAL_DEVICE_BOOT_STARTED
VIRTUAL_DEVICE_NETWORK_MOBILE_CONNECTED
验证页面大小和启动状态
如需验证页面大小和启动状态,请执行以下操作:
以 root 身份访问 shell:
$ adb root
adbd is already running as root
$ adb shell
vsoc_arm64_pgagnostic:/ #
验证页面大小和启动状态:
vsoc_arm64_pgagnostic:/ # getconf PAGE_SIZE
16384
vsoc_arm64_pgagnostic:/ # getprop | grep sys.boot.completed
sys.boot_completed: 1
将 Cuttlefish 与自定义 16 KB 页面大小内核搭配使用
如需使用自定义内核,而不是预构建内核,请执行以下操作:
为 Android 通用内核创建 Repo 目录并同步该目录:
$ mkdir common-android14-6.1 && cd common-android14-6.1
$ repo init -u https://android.googlesource.com/kernel/manifest -b common-android14-6.1
$ repo sync -c -j$(nproc)
构建 16 KB 页面大小的内核:
$ tools/bazel run --lto=none //common:kernel_aarch64_16k_dist
$ tools/bazel run --lto=none //common-modules/virtual-device:virtual_device_aarch64_16k_dist -- \
--dist_dir=out/android14-6.1/dist
验证构建是否已成功执行:
# Generated files
$ ls out/android14-6.1/dist/Image
$ ls out/android14-6.1/dist/initramfs.img
使用自定义 16 KB 页面大小的内核启动 Cuttlefish
如需在 Cuttlefish 中使用新构建的内核,请执行以下操作:
$ launch_cvd -kernel_path ~/common-android14-6.1/out/android14-6.1/dist/Image \
-initramfs_path ~/common-android14-6.1/out/android14-6.1/dist/initramfs.img \
--resume=false --userdata_format=ext4 \
--data_policy=always_create --blank_data_image_mb=8000
-userdata_format=ext4
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-05-08。
[null,null,["最后更新时间 (UTC):2025-05-08。"],[],[],null,["# Use Cuttlefish with 16 KB page size on ARM64\n\nThis setup requires an `ARM64` Linux host. This page shows how to build and\nstart Cuttlefish with 16 KB page size support on `ARM64`. The instructions on\nthis page assume that Cuttlefish packages are installed in your machine. For\ninstructions to install them, see Step 1 of [Install Cuttlefish](/docs/devices/cuttlefish/get-started#launch).\n\nYou can launch Cuttlefish by either [downloading the prebuilt\nartifacts](#download-build-artifacts) directly from the Android Continuous\nIntegration site or [build them from AOSP](#sync-build) if you need to modify\nthe source code.\n\nLaunch Cuttlefish by downloading the artifacts\n----------------------------------------------\n\nNavigate to [Android Continuous Integration site](https://ci.android.com) and\nenter `aosp-main-throttled` as the branch name. Click the latest build for the\n`aosp_cf_arm64_phone_pgagnostic` target. Now, follow the instructions from Step\n5 of [Install Cuttlefish](/docs/devices/cuttlefish/get-started#launch).\n\nLaunch Cuttlefish by building from AOSP\n---------------------------------------\n\nBuild and launch Cuttlefish with a page-agnostic target: \n\n $ mkdir android-latest-branch && cd android-latest-branch\n $ repo init -u https://android.googlesource.com/platform/manifest -b android-latest-release\n $ repo sync -c -j32\n\n # Build cf agnostic target.\n $ source build/envsetup.sh\n $ lunch aosp_cf_arm64_phone_pgagnostic-trunk_staging-userdebug\n $ m\n\n # Launch cf with a kernel with 16 KB page size support.\n $ launch_cvd\n ...\n ...\n VIRTUAL_DEVICE_DISPLAY_POWER_MODE_CHANGED\n virtio_input_hid_handle_status: unknown type 20\n virtio_input_hid_handle_status: unknown type 20\n virtio_input_hid_handle_status: unknown type 20\n virtio_input_hid_handle_status: unknown type 20\n Generating new secret with slot ID: 4\n VIRTUAL_DEVICE_BOOT_STARTED\n VIRTUAL_DEVICE_NETWORK_MOBILE_CONNECTED\n\nVerify page size and boot\n-------------------------\n\nTo verify page size and boot status:\n\n1. Access the shell as root:\n\n $ adb root\n adbd is already running as root\n $ adb shell\n vsoc_arm64_pgagnostic:/ #\n\n2. Verify page size and boot status:\n\n vsoc_arm64_pgagnostic:/ # getconf PAGE_SIZE\n 16384\n vsoc_arm64_pgagnostic:/ # getprop | grep sys.boot.completed\n sys.boot_completed: 1\n\nUse Cuttlefish with custom 16 KB page size kernel\n-------------------------------------------------\n\nTo use a custom kernel, instead of a prebuilt kernel:\n\n1. Create a repo directory for an android common kernel and sync the directory:\n\n $ mkdir common-android14-6.1 && cd common-android14-6.1\n $ repo init -u https://android.googlesource.com/kernel/manifest -b common-android14-6.1\n $ repo sync -c -j$(nproc)\n\n2. Build 16 KB page size kernel:\n\n $ tools/bazel run --lto=none //common:kernel_aarch64_16k_dist\n $ tools/bazel run --lto=none //common-modules/virtual-device:virtual_device_aarch64_16k_dist -- \\\n --dist_dir=out/android14-6.1/dist\n\n3. Verify that the build executed successfully:\n\n # Generated files\n $ ls out/android14-6.1/dist/Image\n $ ls out/android14-6.1/dist/initramfs.img\n\n### Start Cuttlefish with the custom 16 KB page size kernel\n\nTo use your newly built kernel in Cuttlefish: \n\n $ launch_cvd -kernel_path ~/common-android14-6.1/out/android14-6.1/dist/Image \\\n -initramfs_path ~/common-android14-6.1/out/android14-6.1/dist/initramfs.img \\\n --resume=false --userdata_format=ext4 \\\n --data_policy=always_create --blank_data_image_mb=8000\n -userdata_format=ext4"]]