Linux show device tree

Linux: Decompile/show a device tree binary file dtb

under linux device tree is a way to describe hardware which is not discoverable.

The kernel uses a compiled version of the device tree. This can be decompiled in an readable formet by the device tree compiler.

Install device tree compiler

apt-get install device-tree-compiler
michael@devdeb ~# dtc -I dtb -O dts sun8i-h3-orangepi-pc.dtb -o /tmp/tmp.dts michael@devdeb ~# less /tmp/tmp.dts

Leave a Reply Cancel reply

My Knowledgebase for things about Linux, Windows, VMware, Electronic and so on…

Categories

Recent Comments

Consider to make a small donation if the information on this site are useful 🙂

Follow michlstechblog

This website uses cookies to improve your experience and to serv personalized advertising by google adsense. By using this website, you consent to the use of cookies for personalized content and advertising. For more information about cookies, please see our Privacy Policy, but you can opt-out if you wish. Accept Reject Read More

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.

Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.

Читайте также:  Проверить открытый порт линукс

Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.

Источник

4.1.12. How to check some device tree information from user-space of Linux?¶

You might need to check value of some dtb entry, for debugging, checking that your dtb really got updated after you modfified, etc. Though you can’t have a .dts-file-like view of the device tree which was loaded, you can check values using the entries in /proc/device-tree.

In the command prompt of Linux, you should see something similar to the following in the /proc/device-tree directory:

root@j7-evm:~# ls /proc/device-tree/ #address-cells firmware l3-cache0 #size-cells fixedregulator-evm12v0 main_r5fss_cpsw9g_virt_mac0 __symbols__ fixedregulator-sd memory@80000000 aliases fixedregulator-vsys3v3 model chosen fixedregulator-vsys5v0 name compatible gpio-keys pmu connector interconnect@100000 reserved-memory cpus interrupt-parent serial-number dma_buf_phys ion sound@0 dummy-panel l2-cache0 timer-cl0-cpu0

Following are some typical usages you might need:

    Let’s say you don’t know the exact path of the device tree entry you are trying to check. There is a __symbol__ directory in /proc/device-tree, which is very helpful in such cases. It has an entry for each symbol label in the device tree. You can find the exact path for that symbol by running cat command on that entry. Following is an example demonstrating the use:

root@j7-evm:~# cat /proc/device-tree/__symbols__/main_i2c0 /interconnect@100000/i2c@2000000 root@j7-evm:~# ls /proc/device-tree/interconnect@100000/i2c@2000000/ #address-cells clock-names gpio@20 name pinctrl-names #size-cells clocks gpio@22 phandle power-domains clock-frequency compatible interrupts pinctrl-0 reg
# Example for a string value root@j7-evm:~# cat /proc/device-tree/interconnect@100000/i2c@2000000/compatible ti,j721e-i2cti,omap4-i2c # Example for an integer value root@j7-evm:~# xxd -g4 /proc/device-tree/interconnect@100000/i2c@2000000/clock-frequency 00000000: 00061a80 . # The above value is in hexadecimal. You can calculate it's value in decimal by using following command root@j7-evm:~# echo $((0x00061a80)) 400000
# Finding symbols for R5Fs root@j7-evm:~# ls /proc/device-tree/__symbols__/main_r5fss* /proc/device-tree/__symbols__/main_r5fss0 /proc/device-tree/__symbols__/main_r5fss0_core1_dma_memory_region /proc/device-tree/__symbols__/main_r5fss1_core0_memory_region /proc/device-tree/__symbols__/main_r5fss0_core0 /proc/device-tree/__symbols__/main_r5fss0_core1_memory_region /proc/device-tree/__symbols__/main_r5fss1_core1 /proc/device-tree/__symbols__/main_r5fss0_core0_dma_memory_region /proc/device-tree/__symbols__/main_r5fss1 /proc/device-tree/__symbols__/main_r5fss1_core1_dma_memory_region /proc/device-tree/__symbols__/main_r5fss0_core0_memory_region /proc/device-tree/__symbols__/main_r5fss1_core0 /proc/device-tree/__symbols__/main_r5fss1_core1_memory_region /proc/device-tree/__symbols__/main_r5fss0_core1 /proc/device-tree/__symbols__/main_r5fss1_core0_dma_memory_region # Finding location from the symbols root@j7-evm:~# cat /proc/device-tree/__symbols__/main_r5fss0_core0_memory_region /reserved-memory/r5f-memory@a2100000 root@j7-evm:~# cat /proc/device-tree/__symbols__/main_r5fss0_core0_dma_memory_region /reserved-memory/r5f-dma-memory@a2000000 # Checking the values root@j7-evm:~# xxd -g4 /proc/device-tree/reserved-memory/r5f-memory@a2100000/reg 00000000: 00000000 a2100000 00000000 01f00000 . root@j7-evm:~# xxd -g4 /proc/device-tree/reserved-memory/r5f-dma-memory@a2000000/reg 00000000: 00000000 a2000000 00000000 00100000 .

Источник

Читайте также:  Manjaro linux microsoft office

Where to find device-tree?

Coming form this question yesterday, I decided to port this library to my board. I was aware that I needed to change something, so I compiled the library, call it on a small program and see what happens. The 1st problem is here:

 // Check for GPIO and peripheral addresses from device tree. // Adapted from code in the RPi.GPIO library at: // http://sourceforge.net/p/raspberry-gpio-python/ FILE *fp = fopen("/proc/device-tree/soc/ranges", "rb"); if (fp == NULL)

This lib is aimed for Rpi, os the structure of the system on my board is not the same. So I was wondering if somebody could tell me where I could find this file or how it looks like so I can find it by my self in order to proceed the job. Thanks.

«where I could find this file. « — That «file» exists only in the special procfs filesystem, and that /proc/device-tree/ subdirectory is derived from the board’s Device Tree blob. In DT source code that ranges «file» exists as only one line within a file (e.g. arch/arm/boot/dts/bcm2835.dtsi). Your board (which you neglect to provide any details) would only use DT if it had a PPC or ARM SoC, and even then the structure of the DT could be different from this Broadcom example.

1 Answer 1

You don’t necessarily want that «file» (or more precisely /proc node).

The code this is found in is setting up to do direct memory mapped I/O using what appears to be a pi-specific gpio-flavored version of the /dev/mem type of device driver for exposing hardware special function registers to userspace.

To port this to your board, you would need to first determine if there is a /dev/mem or similar capability in your kernel which you can activate. Then you would need to determine the appropriate I/O registers for GPIO pins. The pi-specific code is reading the Device Tree to figure this out, but there are other ways, for example you can manually read the programmer’s manual of the SoC on which you are running.

Another approach you can consider is adding some small microcontroller (or yes, barebones ***duino) to the system, and using that to collect information from various sensors and peripherals. This can then be forwarded to the SoC over a UART link, or queried out via I2C or similar — add a small amount of cost and some degree of bottleneck, but also means that the software on the SoC then becomes very portable — to a different comparable chip, or perhaps even to run on a desktop PC during development.

Читайте также:  XML Developer's Guide

Источник

Where is the device tree on the Linux machine, for e.g., Debian or Ubuntu?

These days we have device tree. I am wondering where can I see the device tree in my PC — i.e. Debian — Release: 9.11. When I look at the kernel config, I don’t see the device tree. How come device tree isn’t there in my PC.

1 Answer 1

x86 PCs don’t use static device trees, they use other mechanisms to enumerate installed hardware (ACPI tables, PCI enumeration, USB. ). So you won’t find a corresponding .dtb file in /boot .

what do they use? I know that chrome books uses the device tree. For example, here is there recent bug — bugs.chromium.org/p/chromium/issues/detail?id=1135157

I think you’re reading too much into that bug as far as DT is concerned. On x86, the kernel knows about some hard-coded hardware and probes for it (e.g. the 8042), everything else is discovered using ACPI and bus enumeration (PCI, USB. ).

Yup, as user431397 says, some x86 systems use DT. I’m answering for PCs only since that’s what you asked about.

You must log in to answer this question.

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.14.43533

Linux is a registered trademark of Linus Torvalds. UNIX is a registered trademark of The Open Group.
This site is not affiliated with Linus Torvalds or The Open Group in any way.

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

Оцените статью
Adblock
detector