devtree gotchas

Back to work.

I'm still in the process of introducing new entries to the device
tree for my target board.  I already have the constants I should
add. I could obviously add them by copying and pasting them right
into the file, and see if they work.  I'd rather understand what
I'm doing, so I decided to invest some time on it.

The difficult part is that the devtree specification does not say
much on the textual format, focusing instead on the semantics.  The
kernel documentation, on the other hand, focuses on how the devtree
is handled, also glossing over details of the text specification.
For example, I know that there can be only one root, in the device
tree.  But why am I dealing with a few files, and each defines /
again?

Intuitively, they end up being merged, right?  And that's exactly
what happens, in fact.

The answer comes from compiling them and dumping the result, which
would be very easy in normal situations.  Yocto is however on the
way, with lots of hidden complexity, and a hellish tree of build
directories.

I've starting using ranger(1) in order to find things in such
hierarchy.  I'm not sure I want to continue: it is hany in some
ways, but an obstacle in others.  Maybe I can use the trick of
defining shell variables as bookmarks.

Gotchas:


1) The dtc(1) utility can be used to dump it, so the result can be
compared with the source, to overcome the lack of information from
the documentation.

       dtc -I dtb -O dts $dtsc_file > dump


2) device tree specifications are merged, so basically:

Let system-top.dts.pp be
       / {
        chosen {
         bootargs = "earlycon clk_ignore_unused";
        };
       };
       /include/ "hello.dtsi"

And let hello.dtsi be
       /* system-user.dtsi */
       /{
        chosen {
          stdout-path = "serial0:115200n8";
        };
       };

The result is
       / {
        chosen {
         bootargs = "earlycon clk_ignore_unused";
         stdout-path = "serial0:115200n8";
        };
       };