[U-Boot] SPL DM

Simon Glass sjg at chromium.org
Tue Feb 3 15:11:08 CET 2015


Hi Michal,

On 3 February 2015 at 06:16, Michal Simek <monstr at monstr.eu> wrote:
> Hi Simon,
>
> I am playing with driver model and I have moved uartlite to it and
> it is working fine for normal u-boot +10k but SPL size is dramatically
> bigger. Without DM I can fit to 3k but now it has ~16k.
>
> microblaze-generic:  all +10759  bss +4  data +560  rodata +1379
> spl/u-boot-spl:all +9100  spl/u-boot-spl:bss -4  spl/u-boot-spl:data -48
>  spl/u-boot-spl:rodata +5660  spl/u-boot-spl:text +3492  text +8816
>
> This 9k is after removing all printf calling which is adding 6kB.
>
>
> diff --git a/common/malloc_simple.c b/common/malloc_simple.c
> index afdacff80d8e..a9e4d96738a0 100644
> --- a/common/malloc_simple.c
> +++ b/common/malloc_simple.c
> @@ -19,7 +19,7 @@ void *malloc_simple(size_t bytes)
>
>         new_ptr = gd->malloc_ptr + bytes;
>         if (new_ptr > gd->malloc_limit)
> -               panic("Out of pre-reloc memory");
> +               puts("Out of pre-reloc memory");
>         ptr = map_sysmem(gd->malloc_base + gd->malloc_ptr, bytes);
>         gd->malloc_ptr = ALIGN(new_ptr, sizeof(new_ptr));
>         return ptr;
> diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
> index 3fc7104359d3..d56fafcb8ee2 100644
> --- a/drivers/serial/serial-uclass.c
> +++ b/drivers/serial/serial-uclass.c
> @@ -72,7 +72,7 @@ static void serial_find_console_or_panic(void)
>         if (uclass_get_device_by_seq(UCLASS_SERIAL, INDEX, &dev) &&
>             uclass_get_device(UCLASS_SERIAL, INDEX, &dev) &&
>             (uclass_first_device(UCLASS_SERIAL, &dev) || !dev))
> -               panic("No serial driver found");
> +               puts("No serial driver found");
>  #undef INDEX
>         gd->cur_serial_dev = dev;
>  }
>
>
> Here is diff between versions. I have setup CONFIG_SYS_MALLOC_SIMPLE
> Simon: Have you tried to to reduce size in this too?
> Interesting part is that new uartlite functions are not called that's why I am expecting
> any other problem.
>
>                  spl-u-boot-spl: add: 27/-13, grow: 2/-1 bytes: 4024/-576 (3448)
>                  function                                   old     new   delta
>                  device_bind                                  -     596    +596
>                  device_probe_child                           -     508    +508
>                  uclass_get                                   -     296    +296
>                  lists_bind_drivers                           -     212    +212
>                  uclass_resolve_seq                           -     188    +188
>                  uclass_bind_device                           -     180    +180
>                  uclass_find_device_by_seq                    -     172    +172
>                  device_bind_by_name                          -     152    +152
>                  uclass_get_device_by_seq                     -     140    +140
>                  serial_find_console_or_panic                 -     136    +136
>                  uclass_find_device                           -     132    +132
>                  lists_driver_lookup_name                     -     128    +128
>                  uclass_first_device                          -     108    +108
>                  dm_init                                      -      96     +96
>                  _serial_putc                                 -      96     +96
>                  uclass_unbind_device                         -      92     +92
>                  malloc_simple                                -      92     +92
>                  uclass_get_device                            -      88     +88
>                  lists_uclass_lookup                          -      80     +80
>                  dm_init_and_scan                             -      80     +80
>                  calloc                                       -      80     +80
>                  uclass_find                                  -      72     +72
>                  uclass_pre_probe_child                       -      60     +60
>                  uclass_post_probe_device                     -      52     +52
>                  strcmp                                       -      52     +52
>                  dm_scan_platdata                             -      52     +52
>                  serial_puts                                 44      80     +36
>                  device_probe                                 -      32     +32
>                  board_init_r                               232     248     +16
>                  serial_current                               4       -      -4
>                  userial0_setbrg                              8       -      -8
>                  serial_init                                 56      48      -8
>                  userial0_tstc                               20       -     -20
>                  userial0_puts                               32       -     -32
>                  userial0_putc                               32       -     -32
>                  userial0_init                               32       -     -32
>                  userial0_getc                               32       -     -32
>                  uartlite_serial_getc                        40       -     -40
>                  uartlite_serial0_device                     48       -     -48
>                  uartlite_serial_init                        52       -     -52
>                  uartlite_serial_puts                        80       -     -80
>                  uartlite_serial_putc                        92       -     -92
>                  get_current                                 96       -     -96

I took a look at this quite recently and your numbers (4KB) are
similar to mine - for ARM. I suppose. Actually on Tegra I see 5KB but
I think that is due to GPIOs being used too. I expect Thumb will cut
this by 20% or so.

There is also a bug in gcc which causes the rodata to blow up. You
might be seeing that also.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54303

I just got a response with a possible patch on the gcc mailing list.

So this is very much work-in-progress. I see a few options:

1. Reduce functionality further, like the existing
CONFIG_DM_WARN/DEVICE_REMOVE/STDIO but operating on things like
device_bind/probe(). I have not seriously looked at this but I suspect
it would be painful.

2. Support for static binding, i.e. declare a struct udevice directly,
using const static init and perhaps some sort of macro to help thread
tings together. Then we could add CONFIG_DM_BIND (to support binding
new devices) and disable it for SPL. A bit ick but it might get us
closer to running in a 4KB SRAM.

If you have ideas/patches please send them through. Right now I need
to get Kconfig support v2 landed, and we still need a few more gdata
patches before we can enable DM in SPL anyway (Tom is looking at
that).

Regards,
Simon


More information about the U-Boot mailing list