How to compile dts Linux device tree source files to dtb?

自闭症网瘾萝莉.ら 提交于 2019-11-28 18:35:31

问题


I have a device tree file (.dts) and I want to compile the file for my powerpc based board.

How can I do it on my machine, which is not powerpc based?? Can I do it with the DTC installed on my Ubuntu system? Or will it be more like using a separate compiler and passing ARCH information (like using a toolchain)?


回答1:


Device trees do not need to be compiled with "architecture-aware" tools. The dtc compiler on your ubuntu machine is probably current enough to compile your device tree. Or you can download the latest source and compile it yourself. The dtc compiler can be found here:

https://git.kernel.org/pub/scm/utils/dtc/dtc.git

There are some good documents in that package that will help you better understand device trees in general.

It's pretty easy to compile (and disassemble) device trees. For example

$ dtc -O dtb -o p4080ds.dtb p4080ds.dts

To get the device tree in text from from the device tree blob, do this:

$ dtc -I dtb -O dts p4080ds.dtb

Hope this helps!




回答2:


  • dtc can be installed by this command on linux:

    sudo apt-get install device-tree-compiler

  • you can compile dts or dtsi files by this command:

    dtc -I dts -O dtb -o devicetree_file_name.dtb devicetree_file_name.dts

  • you can convert dts to dtb by this command:

    dtc -I dts -O dtb -f devicetree_file_name.dts -o devicetree_file_name.dtb

  • you can convert dtb to dts by this command:

    dtc -I dtb -O dts -f devicetree_file_name.dtb -o devicetree_file_name.dts




回答3:


make dtbs

Doing this from the kernel tree is another common way to compile them, since the standard place to put dts is under the kernel tree in directories of the form ./arch/<arch>/boot/dts/.

This ends up calling dtc, but might work better because potential includes will be in the right place.

dtb files are placed in the same directory as the dts.



来源:https://stackoverflow.com/questions/21670967/how-to-compile-dts-linux-device-tree-source-files-to-dtb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!