[U-Boot] [PATCH v2 3/4] tegra: Implement pre-console putc() for fdt warning

Simon Glass sjg at chromium.org
Sat Mar 10 20:22:36 CET 2012

Hi Wolfgang,

On Sat, Mar 10, 2012 at 12:16 AM, Wolfgang Denk <wd at denx.de> wrote:
> Dear Simon Glass,
> In message <1331325178-14634-3-git-send-email-sjg at chromium.org> you wrote:
>> When there is not device tree file available to U-Boot, we panic.
>> Implement board_pre_console_putc() so that this panic will be displayed
>> on the serial console.
> ...
>> +void board_pre_console_putc(int ch)
>> +{
> ...
>> +     for (uart_addr = uart_reg_addr; *uart_addr; uart_addr++) {
>> +             NS16550_t regs = (NS16550_t)*uart_addr;
>> +
>> +             NS16550_init(regs, divisor);
>> +             NS16550_putc(regs, ch);
>> +             if (ch == '\n')
>> +                     NS16550_putc(regs, '\r');
>> +             NS16550_drain(regs);
> Why is this needed for every output character?
> Actually, why is it needed at all?

Of course in this case the init could be done for each UART at the
start of the function rather than in the loop, by looping through the
UARTs twice.

More generally, I will explain both of these patches in this email.

The genesis of this was a requirement to print some sort of message
when things go horribly wrong in early init. This could be in SPL code
when we get an error loading U-Boot, or in board_init_f() when using
CONFIG_OF_CONTROL and we find there is no device tree.

At present in the case of a missing fdt the board is just dead, there
is no message and no indication of what the user should do to sort it
out. The normal console code will not get set up, since U-Boot does
not know which UART is the console. There is a panic() in
fdtdec_check_fdt() to make sure that we don't blindly continue and do
strange things in this case. But since there is no console, the
panic() displays nothing.

My original idea was board_panic_no_console() which boards or SOCs
could implement to print a message on all available UARTs or display,
flash lights, etc. to indicate that something went badly wrong.

The initial patch for board_panic_no_console() was here:


After requests on the list for general purpose pre-console output
function (the purpose of which I didn't necessary see) I changed this
to a putc() mechanism. This means that we need to set up the UARTs
each time it is called. We can't really add a flag to global data
since this might be called before that is even set up. There might be
a better way, but I'm not sure what it is.

For SPL I would like to be able use this same mechanism to call
panic() when something goes wrong, and use the same mechanism to get a
message to the user. Again, this avoids a bricked unit with no failure


> Best regards,
> Wolfgang Denk
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
> All a hacker needs is a tight PUSHJ, a loose pair of UUOs, and a warm
> place to shift.

More information about the U-Boot mailing list