Starting March 27, 2025, we recommend using android-latest-release instead of aosp-main to build and contribute to AOSP. For more information, see Changes to AOSP.
Stay organized with collections
Save and categorize content based on your preferences.
You can use device tree compiler (DTC) to compile the device tree source (DTS)
files. However, before applying the overlay device tree (DT) on the target main DT, you
should also verify the result by simulating the behavior of the device tree overlay (DTO).
Compile with DTC
When using dtc to compile .dts, you must add
option -@ to add a __symbols__ node in the
resulting .dtbo. The __symbols__ node contains a
list of all nodes that are marked with a label, which the DTO library can use
for references.
Verification can help you identify errors that might occur when placing
the overlay DT on the main DT. Before updating the target, you can verify the
result of overlaying DT on the host by simulating the behavior of DTO using
/include/ in .dts.
Figure 1. Use syntax /include/ to simulate DTO on the host.
Create a copy of the overlay .dts. In the copy, remove the
first line header. Example:
/dts-v1/;
/plugin/;
Save the file as my_overlay_dt_wo_header.dts (or any
filename you want).
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:
/include/ "my_overlay_dt_wo_header.dts"
Save the file as my_main_dt_with_include.dts (or any
filename you want).
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:
Android 9 requires a device tree blob overlay
(DTBO) partition. To add nodes or make changes to the properties in the SoC
DT, the bootloader must dynamically overlay a device specific DT over
the SoC DT.
Indicate applied overlays
To enable the
Vendor Test Suite (VTS) to assess the correctness of overlay
app, vendors must add a new kernel command line parameter
androidboot.dtbo_idx that indicates the overlays selected from
the DTBO partition. In Android 12 using kernel version
5.10 or greater, this parameter passes through bootconfig.
For example, the parameter androidboot.dtbo_idx=x,y,z reports
x, y and z as the zero-based indices of
the DTOs from the DTBO partition applied (in that order)
by the bootloader to the base DT.
Overlays can apply to nodes from the main DT or add new nodes,
but can't refer to a node added in a previous overlay. This
restriction is necessary because the overlay app doesn't merge the
overlay symbol table with the main DT symbol table (not merging avoids
conflicts in symbol names and complication of dependencies between
overlays).
Example: Invalid overlays
In this example, overlay_2.dts refers to node
e , which was added by
overlay_1.dts. After overlay_1 is applied to the
main DT, if an attempt is made to apply overlay_2 to the
resultant DT, the overlay app fails with an error that the symbol
e isn't present in the symbol table for the
base DT.
main.dts
overlay_1.dts
overlay_2.dts
[main.dts]
/dts-v1/;
/ {
a: a {};
b: b {};
c: c {};
};
In this example, overlay_2.dts refers only to node
b from the main DTS. When
overlay_1 is applied to the base DT, then followed by the
app of overlay_2, the value of property
prop in node e
(set by overlay_1.dts) is overwritten by the value set by
overlay_2.dts.
main.dts
overlay_1.dts
overlay_2.dts
[final.dts]
/dts-v1/;
/ {
a: a {};
b: b {};
c: c {};
};
To implement the required DTBO partition, ensure the bootloader can do the
following:
Identify the board it is running on and select the corresponding
overlays to be applied.
Append the androidboot.dtbo_idx parameter to the kernel
command line.
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).
The indices must refer to the position of the overlay in the DTBO
partition.
For details on the structure of the DTBO partition, refer to Device tree overlays.
Validate the DTBO partition
You can use VTS to verify the following:
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).
Validity of the ro.boot.dtbo_idx system property (by
checking that the property specifies at least one valid DTBO image
index).
Validity of the DTBO partition (also verifies the overlays in the DTBO
partition that are applied to the base DT).
Additional nodes or property changes in the resulting DT are presented
to the Linux kernel.
For example, in the following overlays and final DT, adding
androidboot.dtbo_idx=5,3 to the kernel command line passes
validation but adding androidboot.dtbo_idx=3,5 to the kernel
command line doesn't pass validation.
/dts-v1/;
/ {
a {
phandle = <0x1>;
};
b {
phandle = <0x2>;
};
c {
phandle = <0x3>;
prop = <0xfe>;
};
__symbols__ {
a = "/a";
b = "/b";
c = "/c";
};
};
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-06-12 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-12 UTC."],[],[],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\"; }; }; ``` |"]]