$ ./out/target/product/project_name/obj/KERNEL_OBJ/scripts/dtc/dtc -I dtb -O dts -o decompiled.dts ~/project/linux_repo/out/target/product/project_name/obj/KERNEL_OBJ/arch/arm64/boot/dts/your.dtb
也就是
scripts/dtc/dtc -I dtb -O dts -o you_want.dts your.dtb
Usage: dtc [options] <input file>
-I, --in-format <arg>
Input formats are:
dts - device tree source text
dtb - device tree blob
fs - /proc/device-tree style directory-O, --out-format <arg>
Output formats are:
dts - device tree source text
dtb - device tree blob
asm - assembler source-o, --out <arg>
Output file
注意
一個是大寫 O
一個是小寫 o
以 Qualcomm MSM8917 為例
Qualcomm code base 會 build 出許多 .dtb,
因此需先找出 project 所使用到的 .dtb
在 uart log 中會有類似以下的 log
146 [ 0.000000] Machine: Qualcomm Technologies, Inc. MSM8917-PMI8940 MTP
Machine: 後面的字串就是您所使用的 device tree file 的 model,
在 android/kernel/msm-3.18/arch/arm/boot/dts/qcom/ 目錄下 grep 此字串,
$ grep -rns "Qualcomm Technologies, Inc. MSM8917-PMI8940 MTP"
arm/boot/dts/qcom/msm8917-pmi8940-mtp.dts:20: model = "Qualcomm Technologies, Inc. MSM8917-PMI8940 MTP";
msm8917-pmi8940-mtp 就是此 project 所使用的 dtb,
到 android/out/ 搜尋 msm8917-pmi8940-mtp.dtb,
android/out$ find -name "msm8917-pmi8940-mtp.dtb"
./target/product/msm8937_64/obj/kernel/msm-3.18/arch/arm64/boot/dts/qcom/msm8917-pmi8940-mtp.dtb
到 android/out/ 搜尋 dtc 執行檔,
$ find -name dtc
./target/product/msm8937_64/obj/kernel/msm-3.18/scripts/dtc/dtc
最後再反譯 dtb 為 dts,
android/out$ ./target/product/msm8937_64/obj/kernel/msm-3.18/scripts/dtc/dtc -I dtb -O dts -o decompiled.dts ./target/product/msm8937_64/obj/kernel/msm-3.18/arch/arm64/boot/dts/qcom/msm8917-pmi8940-mtp.dtb
decompiled.dts 就是此 project 所有被使用到的 dts 的集合。
以 MTK mt6755 為例
mtk code base 只會 build 出一個 .dtb,
所以直接到 linux_repo/out 下搜尋 *.dtb
linux_repo/out$ find -name "*.dtb"
./target/product/XXXXXXXXXX/obj/KERNEL_OBJ/arch/arm64/boot/dts/XXXXXXXXXX.dtb
到 linux_repo/out 下搜尋 dtc 執行檔
linux_repo/out$ find -name "dtc"
./target/product/XXXXXXXXXX/obj/KERNEL_OBJ/scripts/dtc/dtc
最後再反譯 dtb 為 dts,
linux_repo/out$ ./target/product/XXXXXXXXXX/obj/KERNEL_OBJ/scripts/dtc/dtc -I dtb -O dts -o decompiled.dts ./target/product/XXXXXXXXXX/obj/KERNEL_OBJ/arch/arm64/boot/dts/XXXXXXX.dtb
decompiled.dts 就是此 project 所有被使用到的 dts 的集合。