[U-Boot] [PATCH v4 07/13] davinci: Use correct #ifdef around gdata/bdata

Christian Riesch christian.riesch at omicron.at
Mon Feb 27 11:39:42 CET 2012


Hi,

On Mon, Feb 27, 2012 at 11:16 AM, Sughosh Ganu <urwithsughosh at gmail.com> wrote:
> hi Simon,
>
> On Sun Feb 26, 2012 at 09:56:37AM -0800, Simon Glass wrote:
>> Hi Sughosh,
>>
>> On Thu, Feb 23, 2012 at 9:25 AM, Sughosh Ganu <urwithsughosh at gmail.com> wrote:
>> > hi Simon,
>> >
>> > On Mon Feb 20, 2012 at 05:32:49PM -0800, Simon Glass wrote:
>> >> This fixes the following warnings in an SPL build when libcommon is
>> >> in use:
>> >>
>> >> spl.c:37: warning: 'gdata' defined but not used
>> >> spl.c:38: warning: 'bdata' defined but not used
>> >>
>> >> Signed-off-by: Simon Glass <sjg at chromium.org>
>> >> ---
>> >> Changes in v4:
>> >> - Add new patch to fix davinci build warnings
>> >>
>> >>  arch/arm/cpu/arm926ejs/davinci/spl.c |    2 ++
>> >>  1 files changed, 2 insertions(+), 0 deletions(-)
>> >>
>> >> diff --git a/arch/arm/cpu/arm926ejs/davinci/spl.c b/arch/arm/cpu/arm926ejs/davinci/spl.c
>> >> index b1eff26..2861907 100644
>> >> --- a/arch/arm/cpu/arm926ejs/davinci/spl.c
>> >> +++ b/arch/arm/cpu/arm926ejs/davinci/spl.c
>> >> @@ -32,10 +32,12 @@
>> >>
>> >>  #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
>> >>
>> >> +#ifdef CONFIG_SPL_SPI_LOAD
>> >>  DECLARE_GLOBAL_DATA_PTR;
>> >>  /* Define global data structure pointer to it*/
>> >>  static gd_t gdata __attribute__ ((section(".data")));
>> >>  static bd_t bdata __attribute__ ((section(".data")));
>> >> +#endif

In arch/arm/cpu/arm926ejs/davinci/spl.c gdata and bdata are used for
serial_init() to allow output to the console from the SPL. However,
this is only the case when LIBCOMMON is used. LIBCOMMON is required
for booting from SPI, but not for booting from NAND. Up to now davinci
boards that boot from NAND with SPL did not use LIBCOMMON but used the
puts and putc functions defined in spl.c for console output.

>> >  Can you specify which boards you get this warning for. With your
>> >  patch to add libcommon to hawkboard's spl image, this is now also
>> >  needed for hawkboard which uses CONFIG_SPL_NAND_LOAD.

Simon's patch is for the hawkboard, since due to another patch in his
patchset LIBCOMMON is enabled in hawkboard's SPL. Now we have a board
that boots from NAND with SPL and has LIBCOMMON enabled (Simon, I did
not check the rest of your patchset, why do you need LIBCOMMON on the
hawkboard at all?)

However, the patch fixes the warning, but now we use putc and puts
from LIBCOMMON without initializing them. Thus it breaks the console
output of the hawkboard SPL.

So the correct solution would be to keep the ifdefs around the
definition of gdata and bdata as they are, but change board_init_f()
like this:

void board_init_r(gd_t *id, ulong dummy)
{
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
        mem_malloc_init(CONFIG_SYS_TEXT_BASE - CONFIG_SYS_MALLOC_LEN,
                        CONFIG_SYS_MALLOC_LEN);

        gd = &gdata;
        gd->bd = &bdata;
        gd->flags |= GD_FLG_RELOC;
        gd->baudrate = CONFIG_BAUDRATE;
        serial_init();          /* serial communications setup */
        gd->have_console = 1;
#endif
#ifdef CONFIG_SPL_NAND_LOAD
        nand_init();
        puts("Nand boot...\n");
        nand_boot();
#endif
#ifdef CONFIG_SPL_SPI_LOAD
        puts("SPI boot...\n");
        spi_boot();
#endif
}

Regards, Christian


More information about the U-Boot mailing list