User Tools

Site Tools


linux_device_trees

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux_device_trees [2018/11/17 16:11]
rpjday [Comparing two .dts files already in the kernel source tree (Part one)]
linux_device_trees [2018/12/11 13:03] (current)
rpjday [Internal wiki pages]
Line 3: Line 3:
 Stuff related to device trees and the Linux kernel, using examples from the current Linux kernel. Stuff related to device trees and the Linux kernel, using examples from the current Linux kernel.
  
-To do:+===== TO DO =====
  
   * overlays   * overlays
 +  * keywords (/plugin/, /​memreserve/,​ /​omit-if-no-ref/,​ /bits/)
 +
 +===== MISC (for now) =====
 +
 +  * "The unit-address must match the first address specified in the reg property of the node. If the node has no reg property, the @unit-address must be omitted and the node-name alone differentiates the node from other nodes at the same level in the tree. The binding for a particular bus may specify additional, more specific requirements for the format of reg and the unit-address."​
  
 ===== Some links ===== ===== Some links =====
Line 46: Line 51:
   * [[Device tree naming conventions]]   * [[Device tree naming conventions]]
   * [[Proper device tree design]]   * [[Proper device tree design]]
 +  * [[Device tree standard properties]]
 +  * [[Device tree node requirements]]
   * [[Comparing device trees with dtx_diff]]   * [[Comparing device trees with dtx_diff]]
- +  * [[Hierarchical device files]]
-===== Proper device tree design ===== +
- +
-==== One board, one .dts file ==== +
- +
-Every distinct board merits its own ''​.dts''​ file, as in: +
- +
-  * ''​am335x-boneblack.dts''​ +
-  * ''​am335x-boneblack-wireless.dts''​ +
-  * ''​am335x-boneblue.dts''​ +
-  * ''​am335x-bone.dts''​ +
-  * ''​am335x-bonegreen.dts''​ +
-  * ''​am335x-bonegreen-wireless.dts''​ +
- +
-==== Proper use of .dtsi files ==== +
- +
-There is **//no reason//** to make local copies of kernel-supplied ''​.dtsi''​ files and alter them; such files should be included as is, and //all// alterations should be made in the ''​.dts''​ file or a more general board-related ''​.dtsi''​ file supplied by that developer. Any alterations that involve actual //removal// of included content should be done via one of the two directives:​ +
- +
-  * ''/​delete-property/''​ +
-  * ''/​delete-node/''​ +
- +
-This functionality was introduced into the Linux kernel file ''​scripts/​dtc/​dtc-lexer.l''​ file in Sept of 2012: +
- +
-<​file>​ +
-commit cd296721a9645f9f28800a072490fa15458d1fb7 +
-Author: Stephen Warren <​swarren@nvidia.com>​ +
-Date:   ​Fri Sep 28 21:25:59 2012 +0000 +
- +
-    dtc: import latest upstream dtc +
-     +
-    This updates scripts/dtc to commit 317a5d9 "dtc: zero out new label +
-    objects"​ from git://​git.jdl.com/​software/​dtc.git. +
-     +
-    This adds features such as: +
-    ​/bits/ syntax for cell data. +
-    * Math expressions within cell data. +
-    * The ability to delete properties or nodes. +
-    * Support for #line directives in the input file, which allows the use of +
-      cpp on *.dts. +
-    * -i command-line option (/include/ path) +
-    * -W/-E command-line options for error/​warning control. +
-    * Removal of spew to STDOUT containing the filename being compiled. +
-    * Many additions to the libfdt API. +
-     +
-    Signed-off-by:​ Stephen Warren <​swarren@nvidia.com>​ +
-    Acked-by: Jon Loeliger <​jdl@jdl.com>​ +
-    Signed-off-by:​ Rob Herring <​rob.herring@calxeda.com>​ +
-</​file>​ +
- +
-Examples can be seen [[https://​elinux.org/​Device_Tree_Source_Undocumented|here]]+
- +
-==== Examples of /​delete-node/​ ==== +
- +
-=== imx6dl-tx6s-8034.dts === +
- +
-<​file>​ +
-#include "​imx6dl.dtsi"​ +
-#include "​imx6qdl-tx6.dtsi"​ +
- +
-/ { +
-        model = "Ka-Ro electronics TX6S-8034 Module";​ +
-        compatible = "​karo,​imx6dl-tx6dl",​ "​fsl,​imx6dl";​ +
- +
-        aliases { +
-                display = &​display;​ +
-                ipu1 = &​ipu1;​ +
-        }; +
- +
-        cpus { +
-                /​delete-node/​ cpu@1; +
-        }; +
-</​file>​ +
- +
-=== imx6q-utilite-pro.dts === +
- +
-<​file>​ +
-#include <​dt-bindings/​input/​input.h>​ +
-#include "​imx6q-cm-fx6.dts"​ +
- +
-/ { +
-        model = "​CompuLab Utilite Pro";​ +
-        compatible = "​compulab,​utilite-pro",​ "​compulab,​cm-fx6",​ "​fsl,​imx6q";​ +
-         +
- ... +
- +
-}; +
- +
-/* +
- * A single IPU is not able to drive both display interfaces available on the +
- * Utilite Pro at high resolution due to its bandwidth limitation. Since the +
- * tfp410 encoder is wired up to IPU1, sever the link between IPU1 and the +
- * SoC-internal Designware HDMI encoder forcing the latter to be connected to +
- * IPU2 instead of IPU1. +
- */ +
-/​delete-node/&​ipu1_di0_hdmi;​ +
-/​delete-node/&​hdmi_mux_0;​ +
-/​delete-node/&​ipu1_di1_hdmi;​ +
-/​delete-node/&​hdmi_mux_1;​ +
-</​file>​ +
- +
- +
-==== Examples of /​delete-property/​ ==== +
- +
-=== imx6qp.dtsi === +
- +
-<​file>​ +
-#include "​imx6q.dtsi"​ +
- +
-/ { +
-        soc { +
-         +
-        ... +
-         +
-}; +
- +
-&fec { +
-        /​delete-property/​interrupts-extended;​ +
-        interrupts = <0 118 IRQ_TYPE_LEVEL_HIGH>,​ +
-                     <0 119 IRQ_TYPE_LEVEL_HIGH>;​ +
-}; +
-</​file>​ +
- +
-=== imx6ul-tx6ul-mainboard.dts === +
- +
-<​file>​ +
-#include "​imx6ul.dtsi"​ +
-#include "​imx6ul-tx6ul.dtsi"​ +
- +
-/ { +
-        model = "Ka-Ro electronics TXUL-0010 Module on TXUL Mainboard";​ +
-        compatible = "​karo,​imx6ul-tx6ul",​ "​fsl,​imx6ul";​ +
- +
-        aliases { +
-                lcdif_24bit_pins_a = &​pinctrl_disp0_3;​ +
-                mmc0 = &​usdhc1;​ +
-                /​delete-property/​ mmc1; +
-                serial2 = &​uart3;​ +
-                serial4 = &​uart5;​ +
-        }; +
-        /​delete-node/​ sound; +
-}; +
- +
-... +
- +
-&usdhc1 { +
-        pinctrl-0 = <&​pinctrl_usdhc1>;​ +
-        non-removable;​ +
-        /​delete-property/​ cd-gpios; +
-        cap-sdio-irq;​ +
-}; +
- +
-&uart1 { +
-        pinctrl-0 = <&​pinctrl_uart1>;​ +
-        /​delete-property/​ uart-has-rtscts;​ +
-}; +
- +
-&uart2 { +
-        pinctrl-0 = <&​pinctrl_uart2>;​ +
-        /​delete-property/​ uart-has-rtscts;​ +
-        status = "​okay";​ +
-}; +
-</​file>​ +
- +
-===== Comparing .dts files with dtx_diff ===== +
- +
-Here's how to properly compare two device tree source files with the ''​dtx_diff''​ script that comes with the Linux kernel source, given an apparent bug that I've already reported and explain below. This script handles all include files when doing the comparison. +
- +
-==== Preparing for comparison ==== +
- +
-First, given a kernel source tree at ''​~/​k/​git'',​ prepare for comparison with: +
- +
-<​code>​ +
-$ cd ~/k/git +
-$ PATH=~/​k/​git/​scripts/​dtc:​$PATH +
-$ export ARCH=arm +
-</​code>​ +
- +
-Note that setting the PATH as above will add access to all of the executables (scripts and possible binary executables) under the kernel'​s ''​scripts/​dtc/''​ directory, which includes not only the ''​dtx_diff''​ script but, if you've compiled the kernel scripts, the ''​dtc''​ device tree compiler program that will exist under there as well. +
- +
-I mention this so you know that if you already had a ''/​usr/​bin/​dtc''​ executable installed via some sort of ''​dtc''​ package, the one in that scripts directory will take precedence, unless you add that directory at the end of ''​PATH''​ instead of at the beginning. In any event, you //must// have a ''​dtc''​ command somewhere for the ''​dtx_diff''​ script. +
- +
- +
-==== Comparing two .dts files already in the kernel source tree (Part deux) ==== +
- +
-In the above example, you were located in the root directory of the relevant kernel source tree, which is the default for the ''​dtx_diff''​ script, where it knows how to process device tree source file includes. If, however, you're in the actual underlying ''​dts''​ directory (or somewhere else in the kernel source tree), you can't just run the script as is since it won't know the kernel source tree to use to process ''​include''​ directives:​ +
- +
-<​code>​ +
-$ cd arch/​arm/​boot/​dts +
-$ dtx_diff imx6q{,​p}-sabresd.dts +
- +
-... snip ... +
- +
-In file included from imx6qp.dtsi:​43:​0,​ +
-                 from imx6qp-sabresd.dts:​45:​ +
-imx6q.dtsi:​11:​50:​ error: no include path in which to search for dt-bindings/​interrupt-controller/​irq.h +
- #​include <​dt-bindings/​interrupt-controller/​irq.h>​ +
- +
-... snip ... +
- +
-  ./arch/arm/ does not exist +
-  Is $ARCH='​arm'​ correct? +
-  Possible fix: use '​-s'​ option +
- +
-  ./arch/arm/ does not exist +
-  Is $ARCH='​arm'​ correct? +
-  Possible fix: use '​-s'​ option +
-  Possible fix: use '​-S'​ option +
- +
-  Possible fix: use '​-S'​ option +
-+
-</​code>​ +
- +
-Instead, you need to use one of these two variations, depending on whether you're in a Git repository, or just a regular source tree: +
- +
-<​code>​ +
-$ dtx_diff -s ~/k/git imx6q{,​p}-sabresd.dts ​   (specify source tree with ''​-s''​) +
-$ dtx_diff -S imx6q{,​p}-sabresd.dts ​           (''​-S''​ means this is a Git repo) +
-</​code>​ +
- +
-In short, as long as you're still inside the relevant kernel source tree, comparisons will work -- you just need to make sure the ''​dtx_diff''​ script is told where the top of the kernel source tree is. +
- +
- +
- +
-==== Comparing two device tree files out of tree -- apparent bug ==== +
- +
-What doesn'​t seem to work is comparing two device tree files that are outside the confines of a kernel source tree, even if you identify the kernel source tree. Below, I copy the same two files to ''/​tmp''​ and try to do the comparison there, referring back to the same kernel source tree: +
- +
-<​code>​ +
-$ cp imx6q{,​p}-sabresd.dts /tmp +
-$ cd /tmp +
-$ dtx_diff -s ~/k/git imx6q{,​p}-sabresd.dts +
-imx6qp-sabresd.dts:​45:​10:​ fatal error: imx6qp.dtsi:​ No such file or directory +
- #​include "​imx6qp.dtsi"​ +
-          ^~~~~~~~~~~~~ +
-imx6q-sabresd.dts:​15:​10:​ fatal error: imx6q.dtsi: No such file or directory +
- #​include "​imx6q.dtsi"​ +
-          ^~~~~~~~~~~~ +
-compilation terminated. +
-compilation terminated. +
-Error: imx6qp-sabresd.dts:​43.9-10 Error: imx6q-sabresd.dts:​13.9-10 syntax errorsyntax error +
- +
-FATAL ERROR: FATAL ERROR: Unable to parse input tree +
-Unable to parse input tree +
- +
-Possible hints to resolve the above error: +
- +
-  (hints might not fix the problem) +
-Possible hints to resolve the above error: +
-  (hints might not fix the problem) +
- +
- +
-  No hints available. +
-  No hints available. +
-+
-</​code>​ +
- +
-I have no idea why this fails -- obviously, even when telling ''​dtx_diff''​ where the kernel source tree is, the include search path is not being set correctly. I've already reported this as an apparent bug to the device tree mailing list.+
  
linux_device_trees.1542471086.txt.gz · Last modified: 2018/11/17 16:11 by rpjday