Tool to visualize the device tree file (dtb) used by the Linux kernel? [closed]
Asked Answered
K

5

33

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.

Knitwear answered 22/12, 2012 at 6:52 Comment(3)
Are you asking simply for a way to display the contents of a .dtb-file? If so, fdtdump is your friend.Technicality
I want something which takes the dts or dtsi files and shows them graphically.Knitwear
fdtdump is exactly what I needed. dtc -I dtb -O dts <filename> might also serve the purpose. A GUI viewer is available here: github.com/dev-0x7C6/fdt-viewerPassive
D
8

You can try the Component inspector tool.

enter image description here

It is part of QorIQ Configuration Suite which is a plugin for Eclipse.

Download here. (Requires registration. Free to download.)


Personally as i am on the cmd-line most of the time, and quite addicted to vi, i find its built-in code folding capabilities are somewhat sufficient as long as the dts is properly indented.

Setup hot-keys commands to fold/expand blocks of code in vi
by adding the following lines to .vimrc :

nnoremap <silent> <F5> zfa}<CR>
nnoremap <silent> <F6> zo<CR>

With the above setup, to fold a block/node, simply move the cursor onto any of its lines(except the title) and hit F5. To expand a folded block/node, move to the line with the folded title and hit F6.

Here is what a partially folded dts looks like in vi. enter image description here

Degradable answered 23/7, 2013 at 8:30 Comment(3)
does the QorIQ work for any target cpu? Or is does no mater because it is only some sort of tree editor?Dun
unfortunately QorIQ Configuration Suite is not available anymore, any alternative?Lightfingered
@Lightfingered I use Visual Studio Code with the DeviceTree extensionHullo
F
37

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.dtb, 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

Fettle answered 8/10, 2016 at 11:31 Comment(0)
C
16

On linux we can directly open dtb file by using fdtdump

fdtdump dtb_file.dtb > /tmp/test.txt 
Chinn answered 10/4, 2018 at 6:22 Comment(1)
Best for a fast inspection of the contentGarris
D
8

You can try the Component inspector tool.

enter image description here

It is part of QorIQ Configuration Suite which is a plugin for Eclipse.

Download here. (Requires registration. Free to download.)


Personally as i am on the cmd-line most of the time, and quite addicted to vi, i find its built-in code folding capabilities are somewhat sufficient as long as the dts is properly indented.

Setup hot-keys commands to fold/expand blocks of code in vi
by adding the following lines to .vimrc :

nnoremap <silent> <F5> zfa}<CR>
nnoremap <silent> <F6> zo<CR>

With the above setup, to fold a block/node, simply move the cursor onto any of its lines(except the title) and hit F5. To expand a folded block/node, move to the line with the folded title and hit F6.

Here is what a partially folded dts looks like in vi. enter image description here

Degradable answered 23/7, 2013 at 8:30 Comment(3)
does the QorIQ work for any target cpu? Or is does no mater because it is only some sort of tree editor?Dun
unfortunately QorIQ Configuration Suite is not available anymore, any alternative?Lightfingered
@Lightfingered I use Visual Studio Code with the DeviceTree extensionHullo
M
3

There are few tools:

Micaelamicah answered 27/11, 2021 at 19:56 Comment(1)
This is the best answer.Apiculture
H
2

As many of you have figured out after reading this question, it appears that the Component Inspector Tool is no longer available.

Visual Studio Code (free) provides an extension through the marketplace called DeviceTree which helps in navigating device tree files (NOTE: - .dts-only files are supported for now). It does not appear to be as good as the Component Inspector Tool but it does perform basic functions like highlighting and collapsing.

Hullo answered 21/2, 2018 at 16:38 Comment(1)
It does not support reading dtb files, like the question asked. Only dts files...Payment

© 2022 - 2024 — McMap. All rights reserved.