在 ARM64 上使用頁面大小為 16KB 的 Cuttlefish

本頁展示如何在ARM64上建立和啟動支援 16KB 頁面大小的 Cuttlefish。本頁的說明假定您的電腦中安裝了 Cuttlefish。有關安裝說明,請參閱安裝 Cuttlefish

同步和建立與頁面無關的目標

使用與頁面無關的目標建立並啟動 Cuttlefish:

$ mkdir main && cd main
$ repo init -u https://android.googlesource.com/platform/manifest -b main
$ repo sync -c -j32

# Build cf agnostic target.
$ source build/envsetup.sh
$ lunch aosp_cf_arm64_phone_pgagnostic-trunk-userdebug
$ m

# Launch cf with a kernel with 16KB 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

驗證頁面大小和啟動

若要驗證頁面大小和啟動狀態:

  1. 以 root 身分存取 shell:

    $ adb root
    adbd is already running as root
    $ adb shell
    vsoc_arm64_pgagnostic:/ #
    
  2. 驗證頁面大小和啟動狀態:

    vsoc_arm64_pgagnostic:/ # getconf PAGE_SIZE
    16384
    vsoc_arm64_pgagnostic:/ # getprop | grep sys.boot.completed
    sys.boot_completed: 1
    

使用帶有自訂 16KB 頁面大小內核的 Cuttlefish

要使用自訂核心而不是預先建置核心:

  1. 為 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)
    
  2. 建構 16KB 頁大小核心:

    $ 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
    
  3. 驗證建置是否成功執行:

    # Generated files
    $ ls out/android14-6.1/dist/Image
    $ ls out/android14-6.1/dist/initramfs.img
    

使用自訂 16KB 頁面大小核心啟動 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