از 27 مارس 2025، توصیه می کنیم از android-latest-release به جای aosp-main برای ساختن و کمک به AOSP استفاده کنید. برای اطلاعات بیشتر، به تغییرات AOSP مراجعه کنید.
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
می توانید از کامپایلر درخت دستگاه (DTC) برای کامپایل فایل های منبع درخت دستگاه (DTS) استفاده کنید. با این حال، قبل از اعمال درخت دستگاه پوشش (DT) بر روی DT اصلی هدف، باید با شبیه سازی رفتار پوشش درخت دستگاه (DTO) نیز نتیجه را تأیید کنید.
کامپایل با DTC
هنگام استفاده از dtc برای کامپایل .dts ، باید گزینه -@ را اضافه کنید تا یک گره __symbols__ در .dtbo حاصل اضافه کنید. گره __symbols__ حاوی لیستی از تمام گره هایی است که با یک برچسب مشخص شده اند، که کتابخانه DTO می تواند برای مراجع استفاده کند.
راستیآزمایی میتواند به شما در شناسایی خطاهایی که ممکن است هنگام قرار دادن DT روی DT اصلی رخ دهد، کمک کند. قبل از بهروزرسانی هدف، میتوانید با شبیهسازی رفتار DTO با استفاده از /include/ در .dts ، نتیجه همپوشانی DT روی میزبان را تأیید کنید.
شکل 1. از دستور /include/ برای شبیه سازی DTO در میزبان استفاده کنید.
یک کپی از همپوشانی .dts ایجاد کنید. در کپی، هدر خط اول را حذف کنید. مثال:
/dts-v1/;
/plugin/;
فایل را به عنوان my_overlay_dt_wo_header.dts (یا هر نام فایلی که می خواهید) ذخیره کنید.
یک کپی از .dts اصلی ایجاد کنید. در کپی، بعد از آخرین خط، دستور include را برای فایلی که در مرحله 1 ایجاد کردید اضافه کنید. به عنوان مثال:
/include/ "my_overlay_dt_wo_header.dts"
فایل را به عنوان my_main_dt_with_include.dts (یا هر نام فایلی که می خواهید) ذخیره کنید.
از dtc برای کامپایل my_main_dt_with_include.dts استفاده کنید تا DT ادغام شده را بدست آورید، که باید همان نتیجه DTO باشد. به عنوان مثال:
اندروید 9 به یک پارتیشن پوششی حباب درختی دستگاه (DTBO) نیاز دارد. برای افزودن گره ها یا ایجاد تغییرات در ویژگی های SoC DT، بوت لودر باید به صورت پویا یک DT خاص دستگاه را روی SoC DT پوشش دهد.
پوشش های اعمال شده را نشان دهید
برای فعال کردن مجموعه تست فروشنده (VTS) برای ارزیابی درستی برنامه همپوشانی، فروشندگان باید یک پارامتر خط فرمان هسته جدید androidboot.dtbo_idx اضافه کنند که همپوشانی های انتخاب شده از پارتیشن DTBO را نشان می دهد. در اندروید 12 با استفاده از هسته نسخه 5.10 یا بالاتر، این پارامتر از طریق bootconfig عبور می کند. به عنوان مثال، پارامتر androidboot.dtbo_idx=x,y,zx ، y و z را به عنوان شاخصهای مبتنی بر صفر DTOها از پارتیشن DTBO اعمال شده (به ترتیب) توسط بوت لودر به DT پایه گزارش میکند.
همپوشانیها میتوانند روی گرههای DT اصلی اعمال شوند یا گرههای جدیدی اضافه کنند، اما نمیتوانند به گرهای که در همپوشانی قبلی اضافه شده است اشاره کنند. این محدودیت ضروری است زیرا برنامه همپوشانی جدول نمادهای همپوشانی را با جدول نمادهای اصلی DT ادغام نمی کند (ادغام نکردن از تداخل در نام نمادها و پیچیدگی وابستگی ها بین همپوشانی ها جلوگیری می کند).
مثال: همپوشانی نامعتبر
در این مثال، overlay_2.dts به گره e اشاره دارد که توسط overlay_1.dts اضافه شده است. پس از اعمال overlay_1 به DT اصلی، اگر تلاش برای اعمال overlay_2 به DT حاصل شود، برنامه همپوشانی با خطای عدم وجود نماد e در جدول نماد DT پایه شکست میخورد.
main.dts
overlay_1.dts
overlay_2.dts
[main.dts]
/dts-v1/;
/ {
a: a {};
b: b {};
c: c {};
};
در این مثال، overlay_2.dts فقط به گره b از DTS اصلی اشاره دارد. هنگامی که overlay_1 روی پایه DT اعمال می شود، سپس برنامه overlay_2 به دنبال آن اعمال می شود، مقدار ویژگی prop در گره e (تنظیم شده توسط overlay_1.dts ) با مقدار تنظیم شده توسط overlay_2.dts بازنویسی می شود.
main.dts
overlay_1.dts
overlay_2.dts
[final.dts]
/dts-v1/;
/ {
a: a {};
b: b {};
c: c {};
};
برای پیاده سازی پارتیشن DTBO مورد نیاز، مطمئن شوید که بوت لودر می تواند کارهای زیر را انجام دهد:
بردی را که روی آن اجرا می شود شناسایی کنید و پوشش های مربوطه را برای اعمال انتخاب کنید.
پارامتر androidboot.dtbo_idx به خط فرمان هسته اضافه کنید.
این پارامتر باید شاخصهای مبتنی بر صفر DTOها را از تصویر پارتیشن DTBO که روی DT پایه اعمال میکند (به همان ترتیب) نشان دهد.
شاخص ها باید به موقعیت پوشش در پارتیشن DTBO اشاره کنند.
برای جزئیات بیشتر در مورد ساختار پارتیشن DTBO، به همپوشانی درخت دستگاه مراجعه کنید.
پارتیشن DTBO را اعتبار سنجی کنید
می توانید از VTS برای تأیید موارد زیر استفاده کنید:
وجود پارامتر خط فرمان هسته androidboot.dtbo_idx (با بررسی اینکه Init به طور خودکار ویژگی سیستم مربوطه ro.boot.dtbo_idx را تنظیم کرده است).
اعتبار ویژگی سیستم ro.boot.dtbo_idx (با بررسی اینکه این ویژگی حداقل یک شاخص تصویر DTBO معتبر را مشخص می کند).
اعتبار پارتیشن DTBO (همچنین همپوشانی های موجود در پارتیشن DTBO که روی DT پایه اعمال می شوند را تأیید می کند).
گره های اضافی یا تغییرات ویژگی در DT حاصل به هسته لینوکس ارائه می شوند.
به عنوان مثال، در همپوشانیهای زیر و DT نهایی، افزودن androidboot.dtbo_idx=5,3 به خط فرمان کرنل اعتبارسنجی را انجام میدهد اما افزودن androidboot.dtbo_idx=3,5 به خط فرمان هسته اعتبارسنجی را تأیید نمیکند.
/dts-v1/;
/ {
a {
phandle = <0x1>;
};
b {
phandle = <0x2>;
};
c {
phandle = <0x3>;
prop = <0xfe>;
};
__symbols__ {
a = "/a";
b = "/b";
c = "/c";
};
};
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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-29 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Compile and verify\n\nYou can use device tree compiler (DTC) to compile the device tree source (DTS)\nfiles. However, before applying the overlay device tree (DT) on the target main DT, you\nshould also verify the result by simulating the behavior of the device tree overlay (DTO).\n\nCompile with DTC\n----------------\n\nWhen using `dtc` to compile `.dts`, you must add\noption `-@` to add a `__symbols__` node in the\nresulting `.dtbo`. The `__symbols__` node contains a\nlist of all nodes that are marked with a label, which the DTO library can use\nfor references.\n\nSample command to build main DT `.dts`: \n\n```\ndtc -@ -O dtb -o my_main_dt.dtb my_main_dt.dts\n```\n\nSample command to build the overlay DT `.dts`: \n\n```\ndtc -@ -O dtb -o my_overlay_dt.dtbo my_overlay_dt.dts\n```\n| **Note:** If you encounter the DTC build error: `invalid option --'@'`, you might need to update your DTC version. Upstream of AOSP, the official DTC supports DTO as of [version\n| 1.4.4](https://github.com/dgibson/dtc/tree/v1.4.4) and most patches are merged after December 2016. For DTO support, we recommend using the [external/dtc](https://android.googlesource.com/platform/external/dtc/) in AOSP, which is synced with the latest DTC (with DTO patches merged as needed).\n\nVerify DTO results on the host\n------------------------------\n\nVerification can help you identify errors that might occur when placing\nthe overlay DT on the main DT. Before updating the target, you can verify the\nresult of overlaying DT on the host by simulating the behavior of DTO using\n`/include/` in `.dts`.\n| **Note:** `/include/` does NOT support the use of `__overlay__` in overlay DT sources.\n\n**Figure 1.** Use syntax /include/ to simulate DTO on the host.\n\n1. Create a copy of the overlay `.dts`. In the copy, remove the first line header. Example: \n\n ```\n /dts-v1/;\n /plugin/;\n ```\n Save the file as `my_overlay_dt_wo_header.dts` (or any filename you want).\n2. Create a copy of the main `.dts`. In the copy, after the last line, append the include syntax for the file you created in step 1. For example: \n\n ```\n /include/ \"my_overlay_dt_wo_header.dts\"\n ```\n Save the file as `my_main_dt_with_include.dts` (or any filename you want).\n3. Use `dtc` to compile `my_main_dt_with_include.dts` to get the merged DT, which should be the same result as DTO. For example: \n\n ```\n dtc -@ -O dtb -o my_merged_dt.dtb my_main_dt_with_include.dts\n ```\n4. Use `dtc` to dump `my_merged_dt.dto`. \n\n ```\n dtc -O dts -o my_merged_dt.dts my_merged_dt.dtb\n ```\n\nVerify DTO in Android 9\n-----------------------\n\nAndroid 9 requires a device tree blob overlay\n(DTBO) partition. To add nodes or make changes to the properties in the SoC\nDT, the bootloader must dynamically overlay a device specific DT over\nthe SoC DT.\n\n### Indicate applied overlays\n\nTo enable the [Vendor Test Suite (VTS)](/docs/core/tests/vts) to assess the correctness of overlay\napp, vendors must add a new kernel command line parameter\n`androidboot.dtbo_idx` that indicates the overlays selected from\nthe DTBO partition. In Android 12 using kernel version\n5.10 or greater, this parameter passes through bootconfig.\nFor example, the parameter `androidboot.dtbo_idx=x,y,z` reports\n`x`, `y` and `z` as the zero-based indices of\nthe DTOs from the DTBO partition applied (in that order)\nby the bootloader to the base DT.\n\nOverlays can apply to nodes from the main DT or add new nodes,\nbut **can't** refer to a node added in a previous overlay. This\nrestriction is necessary because the overlay app doesn't merge the\noverlay symbol table with the main DT symbol table (not merging avoids\nconflicts in symbol names and complication of dependencies between\noverlays).\n\n#### Example: Invalid overlays\n\nIn this example, `overlay_2.dts` refers to node\n**`e`** , which was added by\n`overlay_1.dts`. After `overlay_1` is applied to the\nmain DT, if an attempt is made to apply `overlay_2` to the\nresultant DT, the overlay app fails with an error that the symbol\n**`e`** isn't present in the symbol table for the\nbase DT.\n\n| main.dts | overlay_1.dts | overlay_2.dts |\n|----------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------|\n| ``` [main.dts] /dts-v1/; / { a: a {}; b: b {}; c: c {}; }; ``` | ``` [overlay_1.dts] /dts-v1/; /plugin/; &b { ref1 = \u003c&a\u003e; e: e { prop = \u003c0x0a\u003e; phandle = \u003c0x04\u003e; }; }; ``` | ``` [overlay_2.dts] /dts-v1/; /plugin/; /* invalid! */ &e { prop = \u003c0x0b\u003e; }; ``` |\n\n#### Example: Valid overlays\n\nIn this example, `overlay_2.dts` refers only to node\n**`b`** from the main DTS. When\n`overlay_1` is applied to the base DT, then followed by the\napp of `overlay_2`, the value of property\n**`prop`** in node **`e`**\n(set by `overlay_1.dts`) is overwritten by the value set by\n`overlay_2.dts`.\n\n| main.dts | overlay_1.dts | overlay_2.dts |\n|-----------------------------------------------------------------|-----------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------|\n| ``` [final.dts] /dts-v1/; / { a: a {}; b: b {}; c: c {}; }; ``` | ``` [overlay_1.dts] /dts-v1/; /plugin/; &b { ref1 = \u003c&a\u003e; e { prop = \u003c0x0c\u003e; }; }; ``` | ``` [overlay_2.dts] /dts-v1/; /plugin/; /* valid */ &b { ref1 = \u003c&c\u003e; e { prop = \u003c0x0d\u003e; }; }; ``` |\n\n### Implement the DTBO partition\n\nTo implement the required DTBO partition, ensure the bootloader can do the\nfollowing:\n\n1. Identify the board it is running on and select the corresponding overlays to be applied.\n2. Append the `androidboot.dtbo_idx` parameter to the kernel command line.\n - The parameter must indicate, the zero-based indices of the DTOs from the DTBO partition image it applied to the base DT (in the same order).\n - The indices must refer to the position of the overlay in the DTBO partition.\n\nFor details on the structure of the DTBO partition, refer to [Device tree overlays](/devices/architecture/dto).\n\n### Validate the DTBO partition\n\nYou can use VTS to verify the following:\n\n- Existence of the kernel command line parameter `androidboot.dtbo_idx` (by checking that `Init` has automatically set up the corresponding `ro.boot.dtbo_idx` system property).\n- Validity of the `ro.boot.dtbo_idx` system property (by checking that the property specifies at least one valid DTBO image index).\n- Validity of the DTBO partition (also verifies the overlays in the DTBO partition that are applied to the base DT).\n- Additional nodes or property changes in the resulting DT are presented to the Linux kernel.\n\nFor example, in the following overlays and final DT, adding\n`androidboot.dtbo_idx=5,3` to the kernel command line passes\nvalidation but adding `androidboot.dtbo_idx=3,5` to the kernel\ncommand line doesn't pass validation.\n\n| Overlay DT at index 3 | Overlay DT at index 5 |\n|--------------------------------------------------------------------|--------------------------------------------------------------------|\n| ``` [overlay_1.dts] /dts-v1/; /plugin/; &c { prop = \u003c0xfe\u003e; }; ``` | ``` [overlay_2.dts] /dts-v1/; /plugin/; &c { prop = \u003c0xff\u003e; }; ``` |\n\n| Final DT |\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` /dts-v1/; / { a { phandle = \u003c0x1\u003e; }; b { phandle = \u003c0x2\u003e; }; c { phandle = \u003c0x3\u003e; prop = \u003c0xfe\u003e; }; __symbols__ { a = \"/a\"; b = \"/b\"; c = \"/c\"; }; }; ``` |"]]