اعتبارًا من 27 آذار (مارس) 2025، ننصحك باستخدام android-latest-release
بدلاً من aosp-main
لإنشاء AOSP والمساهمة فيه. لمزيد من المعلومات، يُرجى الاطّلاع على التغييرات في AOSP.
Cuttlefish: إنشاء جهاز مخصّص
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
توضّح هذه الصفحة كيفية إنشاء جهاز Cuttlefish مخصّص. يتضمّن Cuttlefish
أنواع أجهزة محدّدة مسبقًا بأشكال مختلفة كما هو موضّح في
AndroidProducts.mk
. بالإضافة إلى خيارات تخصيص الجهاز العامة описанة في إضافة جهاز جديد، يمكنك إجراء تخصيصات خاصة بمنصة Cuttlefish، مثل الإعدادات المُعدّة مسبقًا لضبط برمجة لوحة الجهاز الافتراضي (vsoc_x86_64 وvsoc_arm64 وvsoc_riscv64) والبرامج المُعدّة مسبقًا للنواة والبرامج المُعدّة مسبقًا لبرنامج التمهيد وخصائص المورّد وإعدادات النظام ودعم التثبيت المُدمَج للبرامج الافتراضية وخيارات العرض. للحصول على قائمة كاملة ب
مَعلمات وقت الإنشاء التي يمكن تخصيصها، يُرجى الاطّلاع على
device/google/cuttlefish/vsoc_x86_64/phone/aosp_cf.mk
.
توضِّح الخطوات التالية كيفية إنشاء جهاز x86-64
big_phone
خيالي أكبر بعشر مرات من حجم جهاز
Cuttlefish العادي.
اكتساب القيمة من استهداف حالي
للاكتساب من استهداف حالي:
- أنشئ
device/google/cuttlefish/vsoc_x86_64/big_phone
دليلاً.
- أنشئ ملف
aosp_cf.mk
في هذا الدليل.
$(call inherit-product, device/google/cuttlefish/vsoc_x86_64_phone.mk)
PRODUCT_NAME: big_phone
PRODUCT_DEVICE: vsoc_x86_64
PRODUCT_MANUFACTURER := My Company
PRODUCT_MODEL: My Company very large phone
PRODUCT_VENDOR_PROPERTIES += \
ro.soc.manufacturer=$(PRODUCT_MANUFACTURER) \
ro.soc.model=$(PRODUCT_DEVICE)
إضافة هدف لوجبة الغداء
أدخِل استهداف lunch
في ملف
device/google/cuttlefish/AndroidProducts.mk
:
PRODUCT_MAKEFILES := \
...
big_phone:$(LOCAL_DIR)/vsoc_x86_64/big_phone/aosp_cf.mk
...
lunch big_phone
تحديد إعدادات JSON
لتشغيل جهاز Cuttlefish، أنشئ ملف إعدادات JSON باسم
big_phone.json
يتضمّن بنية هرمية تمثّل
سمات الجهاز. على سبيل المثال، في ملف الإعدادات بتنسيق JSON، يمكنك تحديد خيارات مثل ذاكرة الوصول العشوائي المخصّصة للجهاز الظاهري وإعدادات الشاشة. ولا يلزم أن يكون هذا الملف في شجرة AOSP.
لمعرفة تفاصيل عن تنسيق JSON للإعدادات، يُرجى الاطّلاع على
الإعدادات الأساسية.
{
"instances":
[
{
"vm": {
"memory_mb": 40960,
},
"graphics": {
"displays": [
{
"width": 7200,
"height": 12800,
"dpi": 320
}
]
}
}
]
}
لبدء عملية الضبط، شغِّل:
cvd create --config_file=big_phone.json
تشغيل launch_cvd (قديم)
لا تتوفّر بعض خصائص الإعدادات في تنسيق الإعدادات التدرّجية بتنسيق JSON. بالنسبة إلى هذه الإعدادات، يمكنك ضبط قيم launch_cvd
flag
التلقائية من قاموس JSON من مستوى واحد. للحصول على قائمة كاملة بكل خيارات الضبط، يُرجى الاطّلاع على cf_flags_validator.cpp
.
في ما يلي مثال على كيفية إلغاء القيم التلقائية لملف الإعدادات
launch_cvd
خيارات العلامة
باستخدام ملف إعدادات JSON وتفعيل مشغّل Cuttlefish لبدء
الإعدادات المخصّصة.
أنشئ ملف إعدادات JSON،
device/google/cuttlefish/shared/config/config_big_phone.json
،
بقيم مخصّصة.
{
"x_res": 7200,
"y_res": 12800,
"dpi": 320,
"memory_mb": 40960,
"ddr_mem_mb": 49150,
}
لكي يتمكّن مشغّل Cuttlefish من تشغيل ملف الإعدادات big_phone
، تأكَّد من أنّه لديه
إذن بالوصول إلىملف
device/google/cuttlefish/shared/config/config_big_phone.json
من خلال تنفيذ ما يلي:
حدِّد العنصر JSON كعنصر إنشاء من خلال إضافة القسم
prebuilt_etc_host
في ملف
device/google/cuttlefish/shared/config/Android.bp
.
prebuilt_etc_host {
name: "cvd_config_big_phone.json",
src: "config_big_phone.json",
sub_dir: "cvd_config",
}
أضِف بيان عنصر الإنشاء الناتج إلى أداة إطلاق Cuttlefish
من خلال تنفيذ ما يلي في
device/google/cuttlefish/shared/device.mk
.
$(call soong_config_append,cvd,launch_configs,cvd_config_big_phone)
أنشئ ملف android_info.txt
واربط إعدادات big_phone
بالملف
من خلال إضافة السطر التالي إلىملف
device/google/cuttlefish/vsoc_x86_64/big_phone/aosp_cf.mk
:
TARGET_BOARD_INFO_FILE := device/google/cuttlefish/vsoc_x86_64/<var>big_phone</var>/android-info.txt
يمكنك تصنيف نوع الجهاز باستخدام إعدادات big_phone
من خلال تعبئة ملف
device/google/cuttlefish/vsoc_x86_64/big_phone/android-info.txt
بما يلي:
config=big_phone
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ 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,["# Cuttlefish: Create a custom device\n\nThis page describes how to create a customized Cuttlefish device. Cuttlefish\nincludes predefined device types in different form factors as listed in\n[`AndroidProducts.mk`](https://cs.android.com/android/platform/superproject/+/android-latest-release:device/google/cuttlefish/AndroidProducts.mk). In addition to the general device customization\noptions described in\n[Adding a new device](/docs/setup/create/new-device), you can make\nCuttlefish-specific customizations such as virtual device board\nconfiguration presets (vsoc_x86_64, vsoc_arm64, vsoc_riscv64), kernel prebuilts,\nbootloader prebuilts, vendor properties, system configurations, nested\nvirtualization support, and display options. For a full list of the\nbuild time parameters that can be customized, see\n[`device/google/cuttlefish/vsoc_x86_64/phone/aosp_cf.mk`](https://cs.android.com/android/platform/superproject/+/android-latest-release:device/google/cuttlefish/vsoc_x86_64/phone/aosp_cf.mk).\n\nThe following steps describe how to create a fictional x86-64\n\u003cvar translate=\"no\"\u003ebig_phone\u003c/var\u003e device ten times the size of an ordinary\nCuttlefish device.\n\nInherit from an existing target\n-------------------------------\n\nTo inherit from an existing target:\n\n- Create a `device/google/cuttlefish/vsoc_x86_64/`\u003cvar translate=\"no\"\u003ebig_phone\u003c/var\u003e directory.\n- Create an `aosp_cf.mk` file in that directory.\n\n $(call inherit-product, device/google/cuttlefish/vsoc_x86_64_phone.mk)\n\n PRODUCT_NAME: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003ebig_phone\u003c/span\u003e\u003c/var\u003e\n PRODUCT_DEVICE: vsoc_x86_64\n PRODUCT_MANUFACTURER := \u003cvar translate=\"no\"\u003eMy\u003cspan class=\"devsite-syntax-w\"\u003e \u003c/span\u003eCompany\u003c/var\u003e\n PRODUCT_MODEL: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eMy\u003c/span\u003e \u003cspan class=\"devsite-syntax-n\"\u003eCompany\u003c/span\u003e \u003cspan class=\"devsite-syntax-n\"\u003every\u003c/span\u003e \u003cspan class=\"devsite-syntax-n\"\u003elarge\u003c/span\u003e \u003cspan class=\"devsite-syntax-n\"\u003ephone\u003c/span\u003e\u003c/var\u003e\n\n PRODUCT_VENDOR_PROPERTIES += \\\n ro.soc.manufacturer=$(PRODUCT_MANUFACTURER) \\\n ro.soc.model=$(PRODUCT_DEVICE)\n\nAdd a lunch target\n------------------\n\nInsert the `lunch` target into the\n`device/google/cuttlefish/AndroidProducts.mk` file: \n\n PRODUCT_MAKEFILES := \\\n ...\n \u003cvar translate=\"no\"\u003ebig_phone\u003c/var\u003e:$(LOCAL_DIR)/vsoc_x86_64/\u003cvar translate=\"no\"\u003ebig_phone\u003c/var\u003e/aosp_cf.mk\n ...\n\n lunch \u003cvar translate=\"no\"\u003ebig_phone\u003c/var\u003e\n\nDefine JSON configuration\n-------------------------\n\nTo launch the Cuttlefish device, create a JSON configuration file named\n\u003cvar translate=\"no\"\u003ebig_phone\u003c/var\u003e`.json` with a hierarchical structure representing\nthe device properties. For example, in the JSON configuration file, you can\nspecify options such as the RAM allocated for the VM and the display\nconfiguration. This file doesn't have to be in the AOSP tree.\nFor details on the JSON format for configurations, see\n[Canonical configurations](/docs/devices/cuttlefish/multi-tenancy#canonical-configs). \n\n {\n \"instances\":\n [\n {\n \"vm\": {\n \"memory_mb\": 40960,\n },\n \"graphics\": {\n \"displays\": [\n {\n \"width\": 7200,\n \"height\": 12800,\n \"dpi\": 320\n }\n ]\n }\n }\n ]\n }\n\nTo launch the configuration, run: \n\n cvd create --config_file=\u003cvar translate=\"no\"\u003ebig_phone\u003c/var\u003e.json\n\nRun launch_cvd (legacy)\n-----------------------\n\nCertain configuration properties aren't available in the hierarchical JSON\nconfiguration format. For such configurations, you can set `launch_cvd` flag\ndefault values from a single-level JSON dictionary. For a full list of all\nconfiguration options, see\n[`cf_flags_validator.cpp`](https://github.com/google/android-cuttlefish/blob/main/base/cvd/cuttlefish/host/commands/cvd/parser/cf_flags_validator.cpp).\n\nThe following describes an example of how to override the default values of the\n[`launch_cvd` flag options](/docs/devices/cuttlefish/restart#flags)\nusing a JSON configuration file and enable the Cuttlefish launcher to launch the\ncustom configuration.\n\n1. Create a JSON configuration file,\n `device/google/cuttlefish/shared/config/config_`\u003cvar translate=\"no\"\u003ebig_phone\u003c/var\u003e`.json`,\n with custom values.\n\n {\n \"x_res\": 7200,\n \"y_res\": 12800,\n \"dpi\": 320,\n \"memory_mb\": 40960,\n \"ddr_mem_mb\": 49150,\n }\n\n2. For the Cuttlefish launcher to launch the `big_phone` config, ensure it has\n access to the\n `device/google/cuttlefish/shared/config/config_`\u003cvar translate=\"no\"\u003ebig_phone\u003c/var\u003e`.json`\n file by doing the following:\n\n 1. Declare the JSON artifact as a build artifact by adding the\n `prebuilt_etc_host` stanza in the\n `device/google/cuttlefish/shared/config/Android.bp` file.\n\n prebuilt_etc_host {\n name: \"cvd_config_\u003cvar translate=\"no\"\u003ebig_phone\u003c/var\u003e.json\",\n src: \"config_\u003cvar translate=\"no\"\u003ebig_phone\u003c/var\u003e.json\",\n sub_dir: \"cvd_config\",\n }\n\n 2. Add the resulting build artifact declaration into the Cuttlefish\n launcher by running the following in\n `device/google/cuttlefish/shared/device.mk`.\n\n $(call soong_config_append,cvd,launch_configs,cvd_config_\u003cvar translate=\"no\"\u003ebig_phone\u003c/var\u003e)\n\n 3. Create an `android_info.txt` file and tie the `big_phone` config to the\n file by adding the following line to\n `device/google/cuttlefish/vsoc_x86_64/`\u003cvar translate=\"no\"\u003ebig_phone\u003c/var\u003e`/aosp_cf.mk`:\n\n TARGET_BOARD_INFO_FILE := device/google/cuttlefish/vsoc_x86_64/\u003cvar\u003ebig_phone\u003c/var\u003e/android-info.txt\n\n 4. Label the device type with the `big_phone` config by populating\n `device/google/cuttlefish/vsoc_x86_64/`\u003cvar translate=\"no\"\u003ebig_phone\u003c/var\u003e`/android-info.txt`\n with the following:\n\n config=\u003cvar translate=\"no\"\u003ebig_phone\u003c/var\u003e"]]