devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH v2 0/3] dtc: dts source location annotation
@ 2015-09-22  5:05 Frank Rowand
       [not found] ` <5600E191.9020903-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 12+ messages in thread
From: Frank Rowand @ 2015-09-22  5:05 UTC (permalink / raw)
  To: david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+, jdl-CYoMK+44s/E,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA

Annotate input source file and line number of nodes and properties
as comments in output .dts file when --annotate flag is supplied.

A common dts source file convention is for a system .dts file
to include default SOC and/or device .dtsi files and then add
additional system specific properties or over-ride property values
from the .dtsi files.  It can be a time consuming and error prone
exercise to determine exactly what nodes, properties, and property
values are in the final .dtb binary blob and where they originated.

Modify the dtc compiler to read a (possibly cpp pre-processed) .dts
file and for the output .dts annotate each node and property with
the corresponding source location.

As an example, one device tree node for the dragonboard in the
Linux kernel source tree is:

 sdhci@f9824900 { /* arch/arm/boot/dts/qcom-apq8074-dragonboard.dts:14 */
                        compatible = "qcom,sdhci-msm-v4"; /* arch/arm/boot/dts/qcom-msm8974.dtsi:240 */
                        reg = <0xf9824900 0x11c 0xf9824000 0x800>; /* arch/arm/boot/dts/qcom-msm8974.dtsi:241 */
                        reg-names = "hc_mem", "core_mem"; /* arch/arm/boot/dts/qcom-msm8974.dtsi:242 */
                        interrupts = <0x0 0x7b 0x0 0x0 0x8a 0x0>; /* arch/arm/boot/dts/qcom-msm8974.dtsi:243 */
                        interrupt-names = "hc_irq", "pwr_irq"; /* arch/arm/boot/dts/qcom-msm8974.dtsi:244 */
                        clocks = <0xd 0xd8 0xd 0xd7>; /* arch/arm/boot/dts/qcom-msm8974.dtsi:245 */
                        clock-names = "core", "iface"; /* arch/arm/boot/dts/qcom-msm8974.dtsi:246 */
                        status = "ok"; /* arch/arm/boot/dts/qcom-apq8074-dragonboard.dts:17 */
                        bus-width = <0x8>; /* arch/arm/boot/dts/qcom-apq8074-dragonboard.dts:15 */
                        non-removable; /* arch/arm/boot/dts/qcom-apq8074-dragonboard.dts:16 */
                }; /* arch/arm/boot/dts/qcom-apq8074-dragonboard.dts:18 */


qcom-apq8074-dragonboard.dts:
   - last referenced the sdhci node
   - changed the value of the "status" property from "disabled" to "ok"
   - added two properties, "bus-width" and "non-removable"

qcom-msm8974.dtsi:
   - initially set the value the "status" property to "disabled"
     (not visible in the annotated .dts)
   - provided all of the other property values


When the dtc compiler is run within the Linux kernel build system,
the path of the source files will be the full absolute path, just
as seen for gcc warnings and errors.  I always trim away the path
leading up to the Linux kernel source tree by passing the kernel
build output through a sed pipe.  I have done the same to the
above example to remove the excessive verbosity in the source paths.

Implementation notes:

  - The source location of each node and property is saved in the
    respective node or property during the parse phase because
    the source location information from current_srcfile is no longer
    available when the final values are written out from dt_to_source()
    and the functions that it calls.

  - A check is added to dtc.c to ensure that input and output format
    are both device tree source.  An alternate choice would be to
    turn off the --annotate flag if either the input file or the
    output file is not device tree source.  In the alternate case,
    the disabling of --annotate could be silent or a warning could
    be issued.

Changes from v1:

  - Removed the new global stack that was used to track the location
    of the beginning of each node.  To replace this, added new token
    openbrace to get the source location of the opening brace of a
    node.
  - Various cleanups.
  - Add "make check" tests to verify that an annotated .dts can be stripped,
    and the result will be the same as if compiled without --annotate.

Version v2 still creates a new structure "struct src" instead of using
the existing "struct srcpos".  This is because, as far as I know, the
"struct srcpos" information in current_srcfile is not available at the
point where the new annotation is output.  If I am wrong, please give me
some hints.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2015-09-23  0:18 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-22  5:05 [RFC PATCH v2 0/3] dtc: dts source location annotation Frank Rowand
     [not found] ` <5600E191.9020903-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-09-22  5:36   ` [RFC PATCH v2 1/3] " Frank Rowand
     [not found]     ` <5600E8EF.6020107-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-09-22 10:32       ` David Gibson
     [not found]         ` <20150922103251.GO20331-RXTfZT5YzpxwFLYp8hBm2A@public.gmane.org>
2015-09-22 17:10           ` Frank Rowand
     [not found]             ` <56018B92.90305-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-09-23  0:11               ` David Gibson
2015-09-22  5:38   ` [RFC PATCH v2 2/3] dtc: make check test for dtc --annotate Frank Rowand
     [not found]     ` <5600E953.40308-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-09-22 10:39       ` David Gibson
     [not found]         ` <20150922103907.GP20331-RXTfZT5YzpxwFLYp8hBm2A@public.gmane.org>
2015-09-22 17:21           ` Frank Rowand
     [not found]             ` <56018E33.5090708-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-09-23  0:18               ` David Gibson
2015-09-22  5:39   ` [RFC PATCH v2 3/3] dtc: linux kernel build process to create annotated .dts Frank Rowand
     [not found]     ` <5600E9A2.5050000-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-09-22 10:40       ` David Gibson
     [not found]         ` <20150922104013.GQ20331-RXTfZT5YzpxwFLYp8hBm2A@public.gmane.org>
2015-09-22 17:24           ` Frank Rowand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).