[U-Boot] [RFC PATCH 0/4] Run-time configuration of U-Boot via a flat device tree (fdt)

Simon Glass sjg at chromium.org
Fri Sep 2 19:06:41 CEST 2011


HI Mike,

On Fri, Sep 2, 2011 at 9:33 AM, Mike Frysinger <vapier at gentoo.org> wrote:
> On Thursday, September 01, 2011 16:49:05 Simon Glass wrote:
>> At present in U-Boot configuration is mostly done using CONFIG options in
>> the board file. This patch set aims to make it possible for a single
>> U-Boot binary to support multiple boards, with the exact configuration of
>> each board controlled by a flat device tree (fdt). This is the approach
>> recently taken by the ARM Linux kernel and has been used by PowerPC for
>> some time.
>>
>> The fdt is a convenient vehicle for implementing run-time configuration for
>> three reasons. Firstly it is easy to use, being a simple text file. It is
>> extensible since it consists of nodes and properties in a nice hierarchical
>> format.
>>
>> Finally, there is already excellent infrastructure for the fdt: a compiler
>> checks the text file and converts it to a compact binary format, and a
>> library is already available in U-Boot (libfdt) for handling this format.
>
> i guess the important questions for u-boot: size and speed.  have you done any
> comparisons in this area ?

In general the main difference between compile-time and run-time
config is the device init. Rather than spreading CONFIG_ items through
the driiver, we can define a structure which holds the config. Then it
can be set up at driver init, either by assigning from CONFIG items,
or decoding values from the fdt. Using this structure could in some
cases have some small affect on code size and performance within the
driver. For example, if the driver has something like:

   for (very tight loop executed 1000 times) {
      writel(CONFIG_SOME_VALUE / 9, &periph->reg);
   }

then the compiler can work out the value at run time, whereas when the
driver is modified to use a structure:

      writel(config.some_value / 9, &periph->reg);

the compiler must actually do the calculation. I don't see much of
this in the code base though. So overall the performance difference is
small, and with a little effort can be close to zero.

In terms of code size, apart from adding the init code to decode from
the fdt, I don't see a difference. I think an fdt_decode library is a
good idea so that drivers have helper functions for doing common tasks
(higher level than the existing fdt_support library, with specific
driver decode support). That means that the fdt decode code size hit
might happen once per driver class, maybe.

Regards,
Simon

> -mike
>


More information about the U-Boot mailing list