Device tree basics
Typically, <.dtsi> file contain definitions of SoC-level information.
The <.dts> file contains board-level information.
Using device tree compiler
sudo apt install -y device-tree-compiler
Check nodes and properties
/proc/device-tree/
and /
node of a device tree source(DTS) are the same.
If a DTS is
/ {
model = "A";
}
The structure of /proc/device-tree/
is as follows.
/proc/device-tree
└── model
$ cat /proc/device-tree
A
So, you can check DTS with one of the following commands.
tree /proc/device-tree
fdtdump <.dtb file name> | vim -
DTS modification
fdtget/fdtput
fdtget <.dtb> <node> <property>
fdtput -t <type> <.dtb> <node> <property> <value>
- type
- s=string, i=int, u=unsigned, x=hex
- Optional modifier prefix: hh or b=byte, h=2 byte, l=4 byte (default)
Decompiled file modification
dtc -I dtb -O dts <.dtb> -o <.dts>
After decompiling with the above command, edit <.dts>
. Then, compile the edited file with the below command.
dtc -I dts -O dtb <.dts> -o <.dtb>
Using Linux kernel source
git clone --depth=1 --branch=<branch> <repository>
After editing DTS, check Makefile.
linux/arch/<arch>/boot/dts/<vendor>/Makefile
dtb-$(CONFIG_ARCH_<BOARD>) += <board>.dtb
Then, execute the below commands.
make xxx_defconfig \
&& make dtbs
Then, DTB will be created in linux/arch/<arch>/boot/
.
tip
If the above command fails, check arch/<arch>/configs. If not in arch/<arch>/configs, get a config file using zcat /proc/config.gz > <board>_defconfig
from the kernel installed on the desired board.