This post discusses dts, dtb, dtc, and make.
reference code base
Qualcomm msm8994 LA.BF64.1.1-06510-8×94.0 with Android 5.0.2(LRX22G), bootloader (L)ittle (K)ernel and Linux kernel 3.10.49.
what are dts, dtb, and dtc
make dtc in kernel
If CONFIG_DTC is set, then it could make dtc with target scripts in kernel source code. The target scripts is built by default.
$ make -C kernel O=$(PWD)/$(kernel_out) scripts
subdir-$(CONFIG_MODVERSIONS) += genksyms subdir-y += mod subdir-$(CONFIG_SECURITY_SELINUX) += selinux subdir-$(CONFIG_DTC) += dtc
make dtb
DTB files are built while building kernel. A dtb file is compiled if it is added into dtb-y. In this case, CONFIG_ARCH_MSM8994=y, so dtb-y will include below dtb files. For example, dtc will compile msm8994-v1-fluid.dts into msm8994-v1-fluid.dtb.
dtb-$(CONFIG_ARCH_MSM8994) += msm8994-v1-sim.dtb \ msm8994-rumi.dtb \ msm8994-v1-cdp.dtb \ msm8994-pmi8994-pm8004-v1-cdp.dtb \ msm8994-v1-mtp.dtb \ msm8994-pmi8994-pm8004-v1-mtp.dtb \ msm8994-v1-liquid.dtb \ msm8994-v1-fluid.dtb \ apq8094-v1-cdp.dtb \ apq8094-v1-mtp.dtb \ apq8094-v1-liquid.dtb \ apq8094-v1-fluid.dtb \ apq8094-v1-dragonboard.dtb \ msm8994-v2-sim.dtb \ msm8994-v2-cdp.dtb \ msm8994-pmi8994-pm8004-v2-cdp.dtb \ msm8994-v2-mtp.dtb \ msm8994-pmi8994-pm8004-v2-mtp.dtb \ msm8994-v2-liquid.dtb \ msm8994-v2-fluid.dtb \ apq8094-v2-cdp.dtb \ apq8094-v2-mtp.dtb \ apq8094-v2-liquid.dtb \ apq8094-v2-fluid.dtb \ apq8094-v2-dragonboard.dtb
After building boot.img which depends on kernel and dt.img. We could see below dtb files are compiled by dtc.
$ make bootimage $ ls out/target/product/msm8994/obj/KERNEL_OBJ/arch/arm64/boot/dts apq8094-v1-cdp.dtb apq8094-v1-dragonboard.dtb apq8094-v1-fluid.dtb apq8094-v1-liquid.dtb apq8094-v1-mtp.dtb apq8094-v2.0-cdp.dtb apq8094-v2.0-dragonboard.dtb apq8094-v2.0-fluid.dtb apq8094-v2.0-liquid.dtb apq8094-v2.0-mtp.dtb apq8094-v2.1-cdp.dtb apq8094-v2.1-dragonboard.dtb apq8094-v2.1-fluid.dtb apq8094-v2.1-liquid.dtb apq8094-v2.1-mtp.dtb msm8992-cdp.dtb msm8992-mtp.dtb msm8992-rumi.dtb msm8992-sim.dtb msm8994-pmi8994-pm8004-v1-cdp.dtb msm8994-pmi8994-pm8004-v1-mtp.dtb msm8994-pmi8994-pm8004-v2.0-cdp.dtb msm8994-pmi8994-pm8004-v2.0-mtp.dtb msm8994-pmi8994-pm8004-v2.1-cdp.dtb msm8994-pmi8994-pm8004-v2.1-mtp.dtb msm8994-rumi.dtb msm8994-v1-cdp.dtb msm8994-v1-fluid.dtb msm8994-v1-liquid.dtb msm8994-v1-mtp.dtb msm8994-v1-sim.dtb msm8994-v2.0-cdp.dtb msm8994-v2.0-fluid.dtb msm8994-v2.0-liquid.dtb msm8994-v2.0-mtp.dtb msm8994-v2.1-cdp.dtb msm8994-v2.1-fluid.dtb msm8994-v2.1-liquid.dtb msm8994-v2.1-mtp.dtb msm8994-v2-sim.dtb
how use dtc transform dtb and dts
We could use dtc to decompile a dtb file into a dts file. And then use dtc to compile this dts file into a dtb file again. The two dtb files are the same.
$ cd msm8994/out/target/product/msm8994/obj/KERNEL_OBJ $ scripts/dtc/dtc -I dtb -O dts arch/arm64/boot/dts/mm8994-v1-liquid.dtb > test.dts $ scripts/dtc/dtc -I dts -O dtb test.dts > test.dtb $ diff arch/arm64/boot/dts/mm8994-v1-liquid.dtb test.dtb
conclusion
This post discusses dts, dtb, dtc, and make. It shows how to make dtb files and how to use dtc to transform between a dtb file and a dts file.