[U-Boot] [PATCH v4] Add board_pre_console_putc to deal with early console output

Simon Glass sjg at chromium.org
Fri Dec 2 19:16:44 CET 2011


Hi Stefan,

On Fri, Dec 2, 2011 at 9:09 AM, Stefano Babic <sbabic at denx.de> wrote:
> On 19/10/2011 01:43, Simon Glass wrote:
>> This patch adds support for console output before the console is inited.
>> The main purpose of this is to deal with a very early panic() which would
>> otherwise cause a silent hang.
>>
>> A new board_pre_console_putc() function is added to the board API. If
>> provided by the board it will be called in the event of console output
>> before the console is ready. This function should turn on all UARTs and
>> spray the character out if it possibly can.
>>
>> The feature is controlled by a new CONFIG_PRE_CONSOLE_PUTC option.
>>
>> Signed-off-by: Simon Glass <sjg at chromium.org>
>> ---
>
> Hi Simon,
>
>
>> Changes in v2:
>> - Made this feature conditional on CONFIG_PRE_CONSOLE_PANIC
>>
>> Changes in v3:
>> - Rewrite this to be independent of panic()
>> - Rename feature to CONFIG_PRE_CONSOLE_PUTC
>>
>> Changes in v4:
>> - Remove weak function, so we get a link error if it is undefined by the board
>
> maybe I have not understood the real goal of this patch. We have already
> a CONFIG_PRE_CONSOLE_BUFFER, that tries to store the output when the
> console is not avalable - and can be retrieved with a JTAG debugger.
>
> Your patch adds a way to call some serial setup in board code, but it is
> not said that works or can work for all / most boards. Compared to the
> usage of the circular buffer, it is not so general - am I missing
> something ?

It actually started as a last-ditch panic message printer. It morphed
into the general pre-console putc after discussions on the list (with
Graeme).

It can happen that your early board code does not know what clocks to
use, or can't find a console, or some other critical error. It then
calls panic() which silently dies or maybe reboots if you are lucky.
This problem mostly comes about with device trees, where we must have
certain info in the device tree before we can even get to relocation.

The idea is that boards provide a way of outputting characters which
tries to work on all types of boards with that SOC. For example, they
output the characters on all UARTs with various clock options, etc.

We use it on Tegra to print a friendly panic message when something is
horribly wrong. In this case we will never make it to relocation so
the pre-console buffer will not be displayed. So we can't rely on
that.

Regards,
Simon

>
> Best regards,
> Stefano Babic
>
> --
> =====================================================================
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
> =====================================================================
>


More information about the U-Boot mailing list