Difference between revisions of "Device Tree Reference"

From eLinux.org
Jump to: navigation, search
(move "Tools" section from top device tree page)
(move debugging section from Device_Tree)
Line 75: Line 75:
  
 
* tutorials
 
* tutorials
** "Solving Device Tree Issues" (updated), LinuxCon North America August 2015 by Frank Rowand
+
** "Solving Device Tree Issues" (updated), ELCE October 2015 by Frank Rowand
*** [[Media:Dt_debugging_lcna_2015.pdf | PDF slides ]]
+
*** [[Media:Dt_debugging_elce_2015_151006_0421.pdf | PDF slides]]
 
*** [[Device_Tree_frowand | Supporting Resources (patches, etc)]]
 
*** [[Device_Tree_frowand | Supporting Resources (patches, etc)]]
  
Line 88: Line 88:
 
** binding driver to device
 
** binding driver to device
 
** deferred binding
 
** deferred binding
 +
 +
=== debugging - random hints ===
 +
 +
You can set CONFIG_PROC_DEVICETREE to be able to see the device tree information in /proc after booting.
 +
Build the kernel with this option set to 'Y', boot the kernel, then 'cd /proc/device-tree'
 +
 +
/proc/device-tree still does not exist.  Now what???
 +
 +
Is CONFIG_PROC_FS enabled?
 +
Is CONFIG_OF enabled?
 +
Does /sys/firmware/devicetree/base exist?  (Note that this path is '''not''' an ABI, but currently
 +
  /proc/devicetree is a soft link to this location.)
 +
Did the bootloader load a devicetree?  (Check the boot console or use dmesg to print the boot messages.)
 +
 +
For newer kernels where the CONFIG_PROC_DEVICETREE option does not exist, /proc/device-tree will be
 +
created if CONFIG_PROC_FS is set to 'Y'.
 +
 +
You might also try CONFIG_DEBUG_DRIVER=Y.
 +
 +
Also, often, you can set the line: "#define DEBUG 1" to an individual C file, to produce add debug statements
 +
to the routines in that file. This will activate any pr_debug() lines in the source for that file.
 +
 +
Alternatively, you can add the following to drivers/of/Makefile:
 +
 +
CFLAGS_base.o := -DDEBUG
 +
CFLAGS_device.o := -DDEBUG
 +
CFLAGS_platform.o := -DDEBUG
 +
CFLAGS_fdt.o := -DDEBUG
  
 
=== Tools ===
 
=== Tools ===
 +
 
* Device Tree Compiler (dtc) - converts between the human editable device tree source "dts" format and the compact device tree blob "dtb" representation usable by the kernel or assembler source.  dtc is also a dtb decompiler.
 
* Device Tree Compiler (dtc) - converts between the human editable device tree source "dts" format and the compact device tree blob "dtb" representation usable by the kernel or assembler source.  dtc is also a dtb decompiler.
 
** The linux version of dtc is maintained in <tt>scripts/dtc/</tt> in the kernel source directory.
 
** The linux version of dtc is maintained in <tt>scripts/dtc/</tt> in the kernel source directory.

Revision as of 11:55, 9 June 2016


Top Device Tree page

Reference Manual

Introduction

Device Tree Usage

The Device Tree Usage page was previously located at devicetree.org

It walks through how to write a device tree for a new machine.

It is intended to provide an overview of device tree concepts and how they are used to describe a machine.

Miscellaneous Tips

Linux Drivers Device Tree Guide

Device Tree Source

  • presentations

Bindings

Subsystem specific

  • gpio / pinctrl
  • interrupts
  • timers
  • etc

Overlays

Device Tree Source Validation

Compiling .dtb (FDT binary blob)

  • via kernel make system
    • all configured .dtb
      • make dtbs
    • specific .dtb
      • make arch/arm/boot/dts/qcom-apq8074-dragonboard.dtb
  • via generated script in build directory
    • arch/arm/boot/dts/.*.dtb.cmd
    • arch/${ARCH}/boot/dts/.*.dtb.cmd

install

  • make dtbs_install
    • installs in /boot/dtbs/<kernel version> ???? -- is this useful ???
  • many other ways to install ....

boot loaders

booting

debugging

  • diffing .dts, .dtb, /proc/devicetree/
  • locating source location for properties
  • boot time messages
    • device creation
    • driver registration
    • binding driver to device
    • deferred binding

debugging - random hints

You can set CONFIG_PROC_DEVICETREE to be able to see the device tree information in /proc after booting. Build the kernel with this option set to 'Y', boot the kernel, then 'cd /proc/device-tree'

/proc/device-tree still does not exist.  Now what???

Is CONFIG_PROC_FS enabled?
Is CONFIG_OF enabled?
Does /sys/firmware/devicetree/base exist?  (Note that this path is not an ABI, but currently
  /proc/devicetree is a soft link to this location.)
Did the bootloader load a devicetree?  (Check the boot console or use dmesg to print the boot messages.)

For newer kernels where the CONFIG_PROC_DEVICETREE option does not exist, /proc/device-tree will be created if CONFIG_PROC_FS is set to 'Y'.

You might also try CONFIG_DEBUG_DRIVER=Y.

Also, often, you can set the line: "#define DEBUG 1" to an individual C file, to produce add debug statements to the routines in that file. This will activate any pr_debug() lines in the source for that file.

Alternatively, you can add the following to drivers/of/Makefile:

CFLAGS_base.o := -DDEBUG
CFLAGS_device.o := -DDEBUG
CFLAGS_platform.o := -DDEBUG
CFLAGS_fdt.o := -DDEBUG

Tools

"The device tree generator is a Xilinx EDK tool that plugs into the
Automatic BSP Generation features of the tool, XPS"

man pages

Glossary

  • .dtb - File name suffix, by convention, for compiled devicetree.
  • .dts - File name suffix, by convention, for devicetree source.
  • .dtsi - File name suffix, by convention, for devicetree source to be included by a .dts or .dtsi file.
  • Binary Blob - File containing a compiled devicetree.
  • dtc - Devicetree compiler.
  • EDT Expanded Device Tree - A copy of an FDT, but converted to kernel data structures, in the kernel memory space.
  • FDT Flattened Device Tree - A copy of a binary blob in the kernel memory space.

Definitions