public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] pritnf() in arch_cpu_init()
@ 2015-05-18 10:41 Alexey Brodkin
  2015-05-18 20:46 ` Simon Glass
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Brodkin @ 2015-05-18 10:41 UTC (permalink / raw)
  To: u-boot

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.

-Alexey

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [U-Boot] pritnf() in arch_cpu_init()
  2015-05-18 10:41 [U-Boot] pritnf() in arch_cpu_init() Alexey Brodkin
@ 2015-05-18 20:46 ` Simon Glass
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Glass @ 2015-05-18 20:46 UTC (permalink / raw)
  To: u-boot

Hi Alexey,

On 18 May 2015 at 04:41, Alexey Brodkin <Alexey.Brodkin@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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-05-18 20:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-18 10:41 [U-Boot] pritnf() in arch_cpu_init() Alexey Brodkin
2015-05-18 20:46 ` Simon Glass

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox