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

這個設定需要 ARM64 Linux 主機。本頁面說明如何在 ARM64 上建構並啟動支援 16 KB 頁面大小的 Cuttlefish。本頁面的操作說明假設您已在電腦上安裝 Cuttlefish 套件。如需安裝操作說明,請參閱「安裝 Cuttlefish」的步驟 1。

您可以直接從 Android 持續整合網站下載預先建構的構件,或從 AOSP 建構構件 (如果您需要修改原始碼)。

下載構件來啟動 Cuttlefish

前往 Android 持續整合網站,然後輸入 aosp-main-throttled 做為分支版本名稱。按一下 aosp_cf_arm64_phone_pgagnostic 目標的最新版本。接著,請按照「安裝 Cuttlefish」中的步驟 5 操作。

透過 Android 開放原始碼計畫建構,啟動 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_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

驗證頁面大小和啟動

如要確認頁面大小和開機狀態,請按照下列步驟操作:

  1. 以根使用者身分存取 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
    

使用 Cuttlefish 搭配自訂 16 KB 頁面大小的核心

如要使用自訂核心而非預先建構的核心,請按照下列步驟操作:

  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. 建構 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
    
  3. 確認建構作業是否已成功執行:

    # 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