[U-Boot] [RFC PATCH v2 2/6] fdt: Add support for embedded device tree (CONFIG_OF_EMBED)

Simon Glass sjg at chromium.org
Wed Sep 14 20:03:44 CEST 2011


Hi Grant,

On Wed, Sep 14, 2011 at 9:45 AM, Grant Likely <grant.likely at secretlab.ca> wrote:
> On Mon, Sep 12, 2011 at 03:04:23PM -0700, Simon Glass wrote:
>> This new option allows U-Boot to embed a binary device tree into its image
>> to allow run-time control of peripherals. This device tree is for U-Boot's
>> own use and is not necessarily the same one as is passed to the kernel.
>>
>> The device tree compiler output should be placed in the $(obj)
>> rooted tree. Since $(OBJCOPY) insists on adding the path to the
>> generated symbol names, to ensure consistency it should be
>> invoked from the directory where the .dtb file is located and
>> given the input file name without the path.
>>
>> This commit contains my entry for the ugliest Makefile / shell interaction
>> competition.
>>
>> Signed-off-by: Simon Glass <sjg at chromium.org>
>
> May I suggest an alternate approach?  Rather than hard linking the dtb
> into the u-boot image, this would be so much more useful if the dtb
> can be concatenated to the u-boot binary so that it can be configured
> at install time.  Otherwise, switching to .dtb doesn't seem to
> actually buy much when it still requires a recompile of u-boot to
> change the dtb configuration data.

Thanks for your comments.

Yes I agree. This is CONFIG_OF_SEPARATE - see the other patch in the set.

>
> The linker script would need to be modified to make sure the end of
> the binary image is aligned, and that there is a label indicating the
> beginning of the .dtb section.  The init code will also need to read
> the .dtb header to get the dtb length so that it can be relocated into
> RAM with the rest of u-boot.

The label is _end, and you can just:

   cat u-boot.bin some-fdt.dtb >u-boot.dtb.bin

to make this work. The code in the patch is:

#elif defined CONFIG_OF_SEPARATE
	/* FDT is at end of image */
	gd->fdt_blob = (void *)(_end_ofs + _TEXT_BASE);
#endif

>
> Targets could even be added as u-boot.%.bin so that a single build
> could spit out several variants as needed, but still produce a bare
> u-boot.bin binary that can have the .dtb appended manually.

I did have this as part of the U-Boot Makefile in my testing. If
people don't consider it too intrusive then I can certainly add this
in. It is quite convenient, and just adds an extra target to the
U-Boot Makefile.

>
> Using CONFIG_OF_EMBED may actually be harmful if it starts encouraging
> developers to put .dts files into the u-boot tree.  Especially when
> right now the plan for the kernel is to actually move .dts file out of
> the Linux tree and into a separate & neutral repository.

It is a dev convenience, but very very useful in development. For
example, when using a debugger it is easy to just load the u-boot ELF
image and get everything there. We do need to make sure people don't
use it in production as it defeats the purpose of run-time config to a
large extent!

if the fdt is not in the U-Boot tree, where does it go? When will the
kernel fdt be set up? That sounds very promising.

Regards.
Simon

>
>> ---
>>  Makefile         |    4 ++
>>  README           |   11 +++++-
>>  config.mk        |    1 +
>>  dts/Makefile     |  100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>  include/common.h |    1 +
>>  5 files changed, 115 insertions(+), 2 deletions(-)
>>  create mode 100644 dts/Makefile
>>
[snip]


More information about the U-Boot mailing list