Commonly for arm systems, device trees supply hardware information to the kernel (Linux). These device trees exist as dts (device tree source) files that are compiled and loaded to the kernel. Problem is that I do not have access to such a dts
file, not even to a dtb
file.
I have access to /sys
and /proc
on the machine and I wanted to ask if that would allow me to "guess the correct values" to be used in a dts?
Also potential answer could highlight additionally the aspect if the answer to this question also depends on whether the device tree interface was used in the first place (i.e. a dtb
was created and provided to the kernel) instead of some more hacking "we simply divert from vanilla and patch the kernel so as to solve the device information problem for our kernel only"-solution?
Best Answer
/proc/device-tree
or/sys/firmware/devicetree/base
/proc/device-tree
is a symlink to/sys/firmware/devicetree/base
and the kernel documentation says userland should stick to/proc/device-tree
:You can then access dts properties from files:
The output format for integers is binary, so
hexdump
is needed.dtc -I fs
Get a full device tree from the filesystem:
outputs the dts to stdout.
See also: How to list the kernel Device Tree | Unix & Linux Stack Exchange
dtc
in BuildrootBuildroot has a
BR2_PACKAGE_DTC=y
config to putdtc
inside the root filesystem.QEMU
-machine dumpdtb
If you are running Linux inside QEMU, QEMU automatically generates the DTBs if you don't give it explicitly with
-dtb
, and so it is also able to dump it directly with:as mentioned at: https://lists.gnu.org/archive/html/qemu-discuss/2017-02/msg00051.html
Tested with this QEMU + Buildroot setup on the Linux kernel v4.19 arm64.
Thanks to Harry Tsai for pointing out the kernel documentation that says that
/proc/device-tree
is preferred for userland.