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

Alexey Brodkin Alexey.Brodkin at synopsys.com
Mon May 18 12:41:17 CEST 2015


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


More information about the U-Boot mailing list