A partire dal 27 marzo 2025, ti consigliamo di utilizzare android-latest-release
anziché aosp-main
per compilare e contribuire ad AOSP. Per ulteriori informazioni, vedi Modifiche ad AOSP.
Sintassi DTO
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Il formato DTS (Device Tree Source) è una rappresentazione testuale di un albero dei dispositivi (DT).
Il compilatore dell'albero dei dispositivi (DTC) elabora questo formato in un DT binario,
che è la forma prevista dal kernel Linux.
Utilizzare i riferimenti
Il DTC
(Compilatore Albero dei dispositivi + Patch di overlay) descrive il formato DTS in
dtc-format.txt
e
manual.txt.
Il formato e le regole dei DTO sono descritti in
dt-object-internal.txt.
Questi documenti descrivono come aggiornare il DT principale utilizzando
fragment@x
e sintassi __overlay__
nel DT overlay. Per
esempio:
/ {
fragment@0 {
target = <&some_node>;
__overlay__ {
some_prop = "okay";
...
};
};
};
Tuttavia, Google consiglia vivamente di non utilizzare fragment@x
e la sintassi __overlay__
, ma di utilizzare la sintassi di riferimento. Ad esempio:
&some_node {
some_prop = "okay";
...
};
La sintassi di riferimento viene compilata da dtc
nello stesso oggetto di sopra utilizzando la sintassi __overlay__
. Questa sintassi non ti obbliga a numerare i frammenti, il che ti consente di leggere e scrivere facilmente i file DTS overlay. Se il tuo
dtc
non supporta questa sintassi, utilizza il
dtc
in AOSP.
Utilizzare le etichette
Per consentire riferimenti non definiti a nodi non presenti al momento della compilazione, il
file DT .dts
dell'overlay deve avere un tag /plugin/
nell'header. Ad esempio:
/dts-v1/;
/plugin/;
Da qui puoi scegliere come target i nodi da sovrapporre utilizzando un riferimento, ovvero un percorso del nodo assoluto preceduto da una e commerciale (&). Ad esempio, per node@0
nel DT principale:
Definisci le etichette nel DT principale ... |
... quindi utilizza le etichette. |
[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>;
};
|
Ignora
Se la proprietà target di riferimento esiste nel DT principale, viene sostituita
dopo il DTO; in caso contrario, viene aggiunta. Ad esempio:
main.dts |
overlay.dts |
Risultato unito |
[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";
};
};
|
Aggiungi
Se la proprietà target di riferimento non esiste nel DT principale, viene aggiunta dopo il DTO. Ad esempio:
main.dts |
overlay.dts |
Risultato unito |
[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";
};
};
|
Nodi secondari
Esempi di sintassi del nodo secondario:
main.dts |
overlay.dts |
Risultato unito |
[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";
};
};
};
|
I campioni di contenuti e codice in questa pagina sono soggetti alle licenze descritte nella Licenza per i contenuti. Java e OpenJDK sono marchi o marchi registrati di Oracle e/o delle sue società consociate.
Ultimo aggiornamento 2025-08-21 UTC.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 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\"; }; }; }; ``` |"]]