mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* device trees, dtc and beaglebone black
@ 2014-07-05 14:45 Robert P. J. Day
  2014-07-07  7:36 ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Robert P. J. Day @ 2014-07-05 14:45 UTC (permalink / raw)
  To: U-Boot Version 2 (barebox)


  first in a series of questions as i try to puzzle out device trees
and the config options related to it -- first few questions will
undoubtedly be simple as i want to make absolutely sure i don't
misunderstand something basic that screws me up later. and i'll ask in
relation to a real-life example i'm interested in -- the beaglebone
black (BBB).

  first, i notice this page on device trees on the barebox wiki:

http://wiki.barebox.org/doku.php?id=user:devicetree

is it still reasonably up to date? seems like it has useful
information that isn't yet in the user manual.

  next, with the BBB, i realize there are two configs and builds that
must be done:

 $ make omap3530_beagle_xload_defconfig
 $ make omap3530_beagle_defconfig

the first is responsible for building the first-stage (MLO) loader for
the BBB, and it appears to have no device tree functionality whatever,
so it seems i can safely ignore that build, so i'll restrict myself to
the second configure and build for all future questions.

  in terms of building and linking a DTB directly into the barebox
executable, i can see the "System Type" selections:

  [*] link a DTB into the barebox image
    () DTB to build into the barebox image (NEW)

where i assume that if i want to link a DTB, i need to select the
appropriate .dts file, and i'd select "am335x-boneblack". so far, so
good, but here's the first puzzle.

  if i select to link a DTB, it seems obvious that i will need to
compile the .dts file with the "dtc" compiler, right? but that would
seem to be the *only* time i need access to the device tree compiler,
isn't it? and whether or not a device tree compiler is built is
controlled by CONFIG_DTC. you can see this in scripts/Makefile:

  subdir-$(CONFIG_DTC)            += dtc

but it seems that "dtc" is being compiled even when it's unneeded.

  if you look at drivers/of/Kconfig:

=====

config OFTREE
        select DTC
        bool

config OFTREE_MEM_GENERIC
        depends on OFTREE
        depends on PPC || ARM
        def_bool y

config DTC
        bool

config OFDEVICE
        select OFTREE
        select DTC
        bool "Enable probing of devices from the devicetree"

=====

it appears that DTC is explicitly selected by either of OFTREE or
OFDEVICE. but the simple selection of device tree support doesn't seem
to require building "dtc" unless you need to compile a device tree
yourself, does it? i tested this -- i selected not to have a builtin
DTB, but "dtc" was still compiled for me. any reason why? it doesn't
hurt, of course, but it seems unnecessary. or am i misreading
something?

  more questions shortly ...

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: device trees, dtc and beaglebone black
  2014-07-05 14:45 device trees, dtc and beaglebone black Robert P. J. Day
@ 2014-07-07  7:36 ` Sascha Hauer
  2014-07-07 10:16   ` Robert P. J. Day
  0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2014-07-07  7:36 UTC (permalink / raw)
  To: Robert P. J. Day; +Cc: U-Boot Version 2 (barebox)

On Sat, Jul 05, 2014 at 10:45:25AM -0400, Robert P. J. Day wrote:
> 
>   first in a series of questions as i try to puzzle out device trees
> and the config options related to it -- first few questions will
> undoubtedly be simple as i want to make absolutely sure i don't
> misunderstand something basic that screws me up later. and i'll ask in
> relation to a real-life example i'm interested in -- the beaglebone
> black (BBB).
> 
>   first, i notice this page on device trees on the barebox wiki:
> 
> http://wiki.barebox.org/doku.php?id=user:devicetree
> 
> is it still reasonably up to date? seems like it has useful
> information that isn't yet in the user manual.

dumping device trees is no longer done with the oftree command, we
have a dedicated of_dump command now. The device tree overlay or merge
support stuff was removed in:

commit d384b5639fc1a3cff60610e375a2096de413b71f
Author: Sascha Hauer <s.hauer@pengutronix.de>
Date:   Mon May 19 14:40:03 2014 +0200

    of: Drop devicetree merge support

    I assume I am the only person knowing that barebox is able to
    merge devicetrees. This feature seems broken for a while now since
    trying to merge devicetress results in:

    unflatten: too many end nodes

    Remove this feature to save the complexity.

    Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>


> 
>   next, with the BBB, i realize there are two configs and builds that
> must be done:
> 
>  $ make omap3530_beagle_xload_defconfig
>  $ make omap3530_beagle_defconfig

Nope. These configs are for the beaglebo*ard*, not the beaglebone. Maybe
we should rename the config files. At the time they were introduced
there was no beaglebone.

The configs you need for the beaglebone are:

am335x_mlo_defconfig
am335x_defconfig

Both come with device tree support.

> 
> the first is responsible for building the first-stage (MLO) loader for
> the BBB, and it appears to have no device tree functionality whatever,
> so it seems i can safely ignore that build, so i'll restrict myself to
> the second configure and build for all future questions.
> 
>   in terms of building and linking a DTB directly into the barebox
> executable, i can see the "System Type" selections:
> 
>   [*] link a DTB into the barebox image
>     () DTB to build into the barebox image (NEW)

There are generally two ways to get a device tree into barebox:

- enable the builtin DTB option. In this case we have a single DTB built
  into the binary. It is accessible as __dtb_start in the binary. The
  code in arch/arm/cpu/dtb.c will pass this to of_unflatten_dtb(),
  of_set_root_node() and of_probe() to instantiate the devices. Since
  there is a single config option and only one pointer in the binary
  this means there can be only one device tree in the binary.

- Disable the builtin DTB option and instead compile the device tree
  with pbl-y or obj-y in arch/arm/dts/Makefile. With this option the
  device tree will be accessible in the binary with a symbol name
  derived from the filename. This means there can be many device trees
  in the binary and makes it possible to build a binary for multiple
  boards.

Due to the two stage boot process the beaglebone startup and the device
tree handling is quite complicated. There are three different device
trees involed: am335x-bone-common.dts, am335x-bone.dts and
am335x-boneblack.dts.

The second way is the way used by the beaglebone. It goes like this:

There are two binaries involved, built by the two configs. The *mlo*
config runs from SRAM which means we have limited space. The entry point
for this image is:

ENTRY_FUNCTION(start_am33xx_beaglebone_sram, bootinfo, r1, r2)

This function does the SDRAM setup and then calls the barebox_arm_entry
function with this devicetree:

__dtb_am335x_bone_common_start

The symbol name can be derived from the filename
(am335x-bone-common.dts) by replacing dashes with underscores and adding
a __dtb_ to the beginning and a _start to the end.

For the real barebox image the entry point is:

ENTRY_FUNCTION(start_am33xx_beaglebone_sdram, r0, r1, r2)

And here we finally differentiate between both variants:

	if (is_beaglebone_black()) {
                sdram_size = SZ_512M;
                fdt = __dtb_am335x_boneblack_start;
        } else {
                sdram_size = SZ_256M;
                fdt = __dtb_am335x_bone_start;
        }


> =====
> 
> it appears that DTC is explicitly selected by either of OFTREE or
> OFDEVICE. but the simple selection of device tree support doesn't seem
> to require building "dtc" unless you need to compile a device tree
> yourself, does it? i tested this -- i selected not to have a builtin
> DTB, but "dtc" was still compiled for me. any reason why? it doesn't
> hurt, of course, but it seems unnecessary. or am i misreading
> something?

dtc is needed whenever a .dtb.o has to be built. Look for lines like:

pbl-$(CONFIG_MACH_GK802) += imx6q-gk802.dtb.o

This triggers a Make rule to build a dtb using the dtc. This could be
anywhere in the Makefiles, so maybe dtc should always be built.

In short you are right. dtc might be built when it's not actually
needed, but this doesn't hurt.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: device trees, dtc and beaglebone black
  2014-07-07  7:36 ` Sascha Hauer
@ 2014-07-07 10:16   ` Robert P. J. Day
  0 siblings, 0 replies; 3+ messages in thread
From: Robert P. J. Day @ 2014-07-07 10:16 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: U-Boot Version 2 (barebox)

On Mon, 7 Jul 2014, Sascha Hauer wrote:

> On Sat, Jul 05, 2014 at 10:45:25AM -0400, Robert P. J. Day wrote:
> >
> >   next, with the BBB, i realize there are two configs and builds that
> > must be done:
> >
> >  $ make omap3530_beagle_xload_defconfig
> >  $ make omap3530_beagle_defconfig
>
> Nope. These configs are for the beaglebo*ard*, not the beaglebone. Maybe
> we should rename the config files. At the time they were introduced
> there was no beaglebone.
>
> The configs you need for the beaglebone are:
>
> am335x_mlo_defconfig
> am335x_defconfig

  yes, i should have known that ... i'll dig into the rest of your
note later.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2014-07-07 10:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-05 14:45 device trees, dtc and beaglebone black Robert P. J. Day
2014-07-07  7:36 ` Sascha Hauer
2014-07-07 10:16   ` Robert P. J. Day

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox