[U-Boot] pritnf() in arch_cpu_init()

Simon Glass sjg at chromium.org
Mon May 18 22:46:21 CEST 2015


Hi Alexey,

On 18 May 2015 at 04:41, Alexey Brodkin <Alexey.Brodkin at synopsys.com> wrote:
> Hi Simon,
>
> I was looking at how to output error message from very early init and
> found IMHO senseless code in "arch/x86/cpu/coreboot/coreboot.c":
> ---------------->8------------------
> int arch_cpu_init(void)
> {
>         int ret = get_coreboot_info(&lib_sysinfo);
>         if (ret != 0) {
>                 printf("Failed to parse coreboot tables.\n");
>                 return ret;
>         }
> ---------------->8------------------
>
> The problem here is arch_cpu_init() executed much earlier compared to
> serial/console init, refer to "init_sequence_f":
> ---------------->8------------------
> line 764:       arch_cpu_init,
> ...
> line 807:       serial_init,    /* serial communications setup */
>                 console_init_f, /* stage 1 init of console */
> ---------------->8------------------
>
> So printf() output is only available in pre-console buffer if
> CONFIG_PRE_CONSOLE_BUFFER is configured. Otherwise CPU will end up in
> halt before anything gets printed to console.
>
> I would propose to create a special very-early flavour of printf() which
> is only built if pre-console buffer is configured. That way we:
>
>  [1] By default get rid of printf() in early CPU init code that might as
> well be used in SPL build (so there will be no extra dependency on
> pritnf/console)
>
>  [2] Save some space in memory footprint with removal of the string.
>
> I'm pretty sure there're more places when printf() is used before
> console gets initialized but let's first discuss it with this particular
> example.

I've been fiddling with some patches to enable the debug UART
(CONFIG_DEBUG_UART) with printf() so that it can be used from very
early on. That might help here.

But the case you identify should probably be a debug().

Regards,
Simon


More information about the U-Boot mailing list