Tool to visualize the device tree file (dtb) used by the Linux kernel?

Punit Soni picture Punit Soni · Dec 22, 2012 · Viewed 42.2k times · Source

I am looking for a tool which can graphically represent the hardware device tree used in linux kernel. I am trying to understand linux kernel for particular arm chipset. It would be a really useful tool to have.

Answer

dtc -O dts

sudo apt-get install device-tree-compiler
dtc -I dtb -O dts -o a.dts a.dtb

gives a well indented textual representation of the device tree a.dts, which is easy to understand with a text editor. Or dump it to stdout with:

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

The source code for dtc is present in the kernel tree itself at scripts/dtc/dtc.c

Tested on Ubuntu 16.04, with the device tree of Raspberry Pi 2, found in the first partition of 2016-05-27-raspbian-jessie-qemu.img.

For convenience I have in my .bashrc:

dtbs() ( dtc -I dtb -O dts -o - "$1" )
dtsb() ( dtc -I dts -O dtb -o - "$1" )

dtc can also extract the DTS from /proc of a live kernel as shown at: https://unix.stackexchange.com/questions/265890/is-it-possible-to-get-the-information-for-a-device-tree-using-sys-of-a-running