Mulai 27 Maret 2025, sebaiknya gunakan android-latest-release
, bukan aosp-main
, untuk mem-build dan berkontribusi pada AOSP. Untuk mengetahui informasi selengkapnya, lihat Perubahan pada AOSP.
Sintaksis DTO
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Format sumber hierarki perangkat (DTS) adalah representasi tekstual dari hierarki perangkat (DT).
Compiler hierarki perangkat (DTC) memproses format ini menjadi DT biner,
yang merupakan bentuk yang diharapkan oleh kernel Linux.
Menggunakan referensi
Project DTC
(compiler Hierarki perangkat + patch overlay) menjelaskan format DTS dalam
dtc-format.txt
dan
manual.txt.
Format dan aturan DTO dijelaskan dalam
dt-object-internal.txt.
Dokumen ini menjelaskan cara mengupdate DT utama menggunakan node
fragment@x
dan sintaksis __overlay__
di DT overlay. Contoh:
/ {
fragment@0 {
target = <&some_node>;
__overlay__ {
some_prop = "okay";
...
};
};
};
Namun, Google sangat menyarankan agar Anda tidak menggunakan
fragment@x
dan sintaksis __overlay__
, dan sebagai gantinya gunakan
sintaksis referensi. Contoh:
&some_node {
some_prop = "okay";
...
};
Sintaksis referensi dikompilasi oleh dtc
ke dalam objek yang sama seperti
di atas menggunakan sintaksis __overlay__
. Sintaksis ini tidak memaksa Anda
memberi nomor fragmen, sehingga Anda dapat membaca dan menulis DTS overlay dengan mudah. Jika
dtc
Anda tidak mendukung sintaksis ini, gunakan
dtc
di AOSP.
Menggunakan label
Untuk mengizinkan referensi yang tidak ditentukan ke node yang tidak ada pada waktu kompilasi, file DT .dts
overlay harus memiliki tag /plugin/
di header-nya. Contoh:
/dts-v1/;
/plugin/;
Dari sini, Anda dapat menargetkan node yang akan ditempatkan menggunakan referensi, yaitu
jalur node absolut yang diawali dengan ampersand (&). Misalnya, untuk
node@0
di DT utama:
Menentukan label di DT utama ... |
... lalu gunakan label. |
[my_main_dt.dts]
/dts-v1/;
/ {
my_node: node@0 {
status = "disabled";
my_child: child@0 {
value = <0xffffffff>;
};
};
};
|
[my_overlay_dt.dts]
/dts-v1/;
/plugin/;
&my_node {
status = "okay";
};
&my_child {
value = <0x1>;
};
|
Ganti
Jika properti target referensi ada di DT utama, properti tersebut akan diganti
setelah DTO; jika tidak, properti tersebut akan ditambahkan. Contoh:
main.dts |
overlay.dts |
Hasil Gabungan |
[my_main_dt.dts]
/dts-v1/;
/ {
compatible = "corp,foo";
my_node: node@0 {
status = "disabled";
};
};
|
[my_overlay_dt.dts]
/dts-v1/;
/plugin/;
&my_node {
status = "okay";
};
|
/dts-v1/;
/ {
compatible = "corp,foo";
...
node@0 {
linux,phandle = <0x1>;
phandle = <0x1>;
status = "okay";
};
};
|
Cantelkan
Jika properti target referensi tidak ada di DT utama, properti tersebut
akan ditambahkan setelah DTO. Contoh:
main.dts |
overlay.dts |
Hasil Gabungan |
[my_main_dt.dts]
/dts-v1/;
/ {
compatible = "corp,foo";
my_node: node@0 {
status = "okay";
};
};
|
[my_overlay_dt.dts]
/dts-v1/;
/plugin/;
&my_node {
new_prop = "bar";
};
|
/dts-v1/;
/ {
compatible = "corp,foo";
...
node@0 {
linux,phandle = <0x1>;
phandle = <0x1>;
status = "okay";
new_prop = "bar";
};
};
|
Node turunan
Contoh sintaksis node turunan:
main.dts |
overlay.dts |
Hasil Gabungan |
[my_main_dt.dts]
/dts-v1/;
/ {
compatible = "corp,foo";
my_nodes: nodes {
compatible = "corp,bar";
node@0 {
status = "disabled";
};
};
};
|
[my_overlay_dt.dts]
/dts-v1/;
/plugin/;
&my_nodes {
new_prop1 = "abc";
node@0 {
status = "okay";
new_prop2 = "xyz";
};
};
|
/dts-v1/;
/ {
compatible = "corp,foo";
...
nodes {
linux,phandle = <0x1>;
phandle = <0x1>;
compatible = "corp,bar";
new_prop1 = "abc";
node@0 {
linux,phandle = <0x2>;
phandle = <0x2>;
status = "okay";
new_prop2 = "xyz";
};
};
};
|
Konten dan contoh kode di halaman ini tunduk kepada lisensi yang dijelaskan dalam Lisensi Konten. Java dan OpenJDK adalah merek dagang atau merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-08-21 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-21 UTC."],[],[],null,["# DTO syntax\n\nDevice tree source (DTS) format is a textual representation of a device tree (DT).\nThe device tree compiler (DTC) processes this format into a binary DT,\nwhich is the form expected by the Linux kernel.\n\nUse references\n--------------\n\nThe [DTC](https://github.com/pantoniou/dtc)\n(device Tree compiler + overlay patches) project describes the DTS format in\n[dtc-format.txt](https://android.googlesource.com/platform/external/dtc/+/refs/heads/android16-release/Documentation/dts-format.txt)\nand\n[manual.txt](https://android.googlesource.com/platform/external/dtc/+/refs/heads/android16-release/Documentation/manual.txt).\nDTO format and rules are described in\n[dt-object-internal.txt](https://android.googlesource.com/platform/external/dtc/+/refs/heads/android16-release/Documentation/dt-object-internal.txt).\nThese documents describe how to update the main DT using node\n`fragment@x` and syntax `__overlay__` in overlay DT. For\nexample: \n\n```objective-c\n/ {\n fragment@0 {\n target = \u003c&some_node\u003e;\n __overlay__ {\n some_prop = \"okay\";\n ...\n };\n };\n};\n```\n\nHowever, Google strongly recommends you do **not** use\n`fragment@x` and syntax `__overlay__`, and instead use the\nreference syntax. For example: \n\n```scdoc\n&some_node {\n some_prop = \"okay\";\n ...\n};\n```\n\nReference syntax is compiled by `dtc` into the same object as the\nabove using syntax `__overlay__`. This syntax doesn't force you to\nnumber the fragments, enabling you to read and write overlay DTS easily. If your\n`dtc` doesn't support this syntactic sugar, use the\n[dtc\nin AOSP](https://android.googlesource.com/platform/external/dtc).\n\nUse labels\n----------\n\nTo allow undefined references to nodes not present at compilation time, the\noverlay DT `.dts` file must have a tag `/plugin/` in its\nheader. For example: \n\n```text\n/dts-v1/;\n/plugin/;\n```\n\nFrom here you can target the nodes to be overlaid using a reference, which is\nan absolute node path prefixed with an ampersand (\\&). For example, for\n`node@0` in the main DT:\n\n| Define labels in the main DT ... | ... then use the labels. |\n|-------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------|\n| ```ini [my_main_dt.dts] /dts-v1/; / { my_node: node@0 { status = \"disabled\"; my_child: child@0 { value = \u003c0xffffffff\u003e; }; }; }; ``` | ```ini [my_overlay_dt.dts] /dts-v1/; /plugin/; &my_node { status = \"okay\"; }; &my_child { value = \u003c0x1\u003e; }; ``` |\n\nOverride\n--------\n\nIf the reference target property exists in the main DT, it is overridden\nafter DTO; otherwise, it is appended. For example:\n\n| main.dts | overlay.dts | Merged Result |\n|-----------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|\n| ```ini [my_main_dt.dts] /dts-v1/; / { compatible = \"corp,foo\"; my_node: node@0 { status = \"disabled\"; }; }; ``` | ```ini [my_overlay_dt.dts] /dts-v1/; /plugin/; &my_node { status = \"okay\"; }; ``` | ```objective-c /dts-v1/; / { compatible = \"corp,foo\"; ... node@0 { linux,phandle = \u003c0x1\u003e; phandle = \u003c0x1\u003e; status = \"okay\"; }; }; ``` |\n\nAppend\n------\n\nIf the reference target property doesn't exist in the main DT, it is\nappended after DTO. For example:\n\n| main.dts | overlay.dts | Merged Result |\n|-------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ```ini [my_main_dt.dts] /dts-v1/; / { compatible = \"corp,foo\"; my_node: node@0 { status = \"okay\"; }; }; ``` | ```ini [my_overlay_dt.dts] /dts-v1/; /plugin/; &my_node { new_prop = \"bar\"; }; ``` | ```objective-c /dts-v1/; / { compatible = \"corp,foo\"; ... node@0 { linux,phandle = \u003c0x1\u003e; phandle = \u003c0x1\u003e; status = \"okay\"; new_prop = \"bar\"; }; }; ``` |\n\nChild nodes\n-----------\n\nExamples of child node syntax:\n\n| main.dts | overlay.dts | Merged Result |\n|------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ```ini [my_main_dt.dts] /dts-v1/; / { compatible = \"corp,foo\"; my_nodes: nodes { compatible = \"corp,bar\"; node@0 { status = \"disabled\"; }; }; }; ``` | ```ini [my_overlay_dt.dts] /dts-v1/; /plugin/; &my_nodes { new_prop1 = \"abc\"; node@0 { status = \"okay\"; new_prop2 = \"xyz\"; }; }; ``` | ```objective-c /dts-v1/; / { compatible = \"corp,foo\"; ... nodes { linux,phandle = \u003c0x1\u003e; phandle = \u003c0x1\u003e; compatible = \"corp,bar\"; new_prop1 = \"abc\"; node@0 { linux,phandle = \u003c0x2\u003e; phandle = \u003c0x2\u003e; status = \"okay\"; new_prop2 = \"xyz\"; }; }; }; ``` |"]]