console: Support board-specific early console
PATCH 1/2 console: Support board-specific early console
From: Thierry Reding <[email protected]>
This is mostly useful for debugging the early boot process. Often boards can provide some low-level code that outputs a character on some debug port prior to passing the early setup code. Allow boards to implement an early_putc() function that will be used to redirect printf() and friends to this debug port until the proper console becomes ready.
--- README | 17 +++++++++++++++++ common/console.c | 21 +++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-)
README +17 -0
@@ -5014,6 +5014,23 @@ Low Level (hardware related) configuration options: driver that uses this: drivers/mtd/nand/davinci_nand.c +- CONFIG_EARLY_CONSOLE + Enables support for an early console. Output from puts() and + printf() will be redirected to this early console. A primary + use-case for this is early board bring up, where U-Boot does + not boot to the proper console yet, but it can also be quite + handy to help debug U-Boot's early boot phases. + + Boards that specify this option in their configuration must + provide an implementation of the early_putc() function: + + void early_putc(char ch); + + This function should output a single character on a device + that is available during early boot. Often this will be a + debug UART that has been preconfigured by a bootloader or + ROM before executing U-Boot. + Freescale QE/FMAN Firmware Support: -----------------------------------
common/console.c +19 -2
@@ -479,6 +479,16 @@ void putc(const char c) } } +#ifdef CONFIG_EARLY_CONSOLE +extern void early_putc (char ch); + +static void early_puts (const char *s) +{ +while (*s) +early_putc (*s++); +} +#endif +void puts (const char *s) {#ifdef CONFIG_SANDBOX
@@ -498,6 +508,11 @@ void puts(const char *s)return ;#endif +#ifdef CONFIG_EARLY_CONSOLE +if (!gd->have_console) +early_puts (s); +#endif +if (!gd->have_console)return pre_console_puts (s);
@@ -517,7 +532,8 @@ int printf(const char *fmt, ...)uint i;char printbuffer[CONFIG_SYS_PBSIZE ]; -#if !defined(CONFIG_SANDBOX ) && !defined(CONFIG_PRE_CONSOLE_BUFFER ) +#if !defined(CONFIG_SANDBOX ) && !defined(CONFIG_PRE_CONSOLE_BUFFER ) && \ + !defined(CONFIG_EARLY_CONSOLE )if (!gd->have_console)return 0 ;#endif
@@ -540,7 +556,8 @@ int vprintf(const char *fmt, va_list args)uint i;char printbuffer[CONFIG_SYS_PBSIZE ]; -#if defined(CONFIG_PRE_CONSOLE_BUFFER ) && !defined(CONFIG_SANDBOX ) +#if !defined(CONFIG_SANDBOX ) && !defined(CONFIG_PRE_CONSOLE_BUFFER ) && \ + !defined(CONFIG_EARLY_CONSOLE )if (!gd->have_console)return 0 ;#endif
Signature · 1 line
2.3.2
PATCH 2/2 ARM: tegra: Implement early console support
From: Thierry Reding <[email protected]>
Use the physical address of the debug serial port from the configuration to provide an early_putc() implementation that can be used with the new early console support.
--- board/nvidia/common/board.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
board/nvidia/common/board.c +22 -0
@@ -155,6 +155,28 @@ int board_init(void)return 0 ; } +#ifdef CONFIG_EARLY_CONSOLE +#define UART_THR 0x00 +#define UART_LSR 0x14 + +void early_putc (char ch) +{ +uint32_t mask =UART_LSR_TEMT |UART_LSR_THRE , value; +unsigned long base =CONFIG_SYS_NS16550_COM1 ; + +if (ch =='\n' ) +early_putc ('\r' ); + +writel (ch, base +UART_THR ); + +while (true) { + value =readl (base +UART_LSR ); +if ((value & mask) == mask) +break ; + } +} +#endif +#ifdef CONFIG_BOARD_EARLY_INIT_F static void __gpio_early_init (void ) {
Signature · 1 line
2.3.2
PATCH 1/2 console: Support board-specific early console
In reply to Thierry RedingQuoted 11 lines · Thierry Reding
From: Thierry Reding <[email protected]>
This is mostly useful for debugging the early boot process. Often boards can provide some low-level code that outputs a character on some debug port prior to passing the early setup code. Allow boards to implement an
early_putc()function that will be used to redirectprintf()and friends to this debug port until the proper console becomes ready.Cc Simon Glass <[email protected]>Cc Tom Rini <[email protected]>Signed-off-by Thierry Reding <[email protected]>
Dumb question, shouldn't this plug into the DEBUG_UART stuff Simon did that's already merged?
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150320/f60ba153/attachment.sig>
PATCH 1/2 console: Support board-specific early console
In reply to Thierry RedingDear Thierry,
Quoted 6 lines · In message <[email protected]> you…
This is mostly useful for debugging the early boot process. Often boards can provide some low-level code that outputs a character on some debug port prior to passing the early setup code. Allow boards to implement an
early_putc()function that will be used to redirectprintf()and friends to this debug port until the proper console becomes ready.
Hm... it is one of the basic design principles of U-Boot to provide debug output on the console as soon as possible. It should be the primary purpose of low level initialization to enable console output, before anything else.
Now you say, you have output even before that - this aears to be a contradiction to me. If you can output characters, then use this as your console. I feel we should not need any special configuration options to do what we should do anyway.
Or am I missing somthing?
Best regards,
Wolfgang Denk
Signature · 7 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk 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 Ein weiser Herrscher kann in einem gro?en Land mehr Gutes bewirken als in einem kleinen - ein dummer Herrscher aber auch viel mehr Un- fug. Da weise Herrscher seltener sind als dumme, war ich schon immer gegen gro?e Reiche skeptisch. - Herbert Rosendorfer
PATCH 1/2 console: Support board-specific early console
Hi,
Quoted 15 lines · Wolfgang Denk
Dear Thierry,
Quoted 6 lines · In message <[email protected]> you…
This is mostly useful for debugging the early boot process. Often boards can provide some low-level code that outputs a character on some debug port prior to passing the early setup code. Allow boards to implement an
early_putc()function that will be used to redirectprintf()and friends to this debug port until the proper console becomes ready.Hm... it is one of the basic design principles of U-Boot to provide debug output on the console as soon as possible. It should be the primary purpose of low level initialization to enable console output, before anything else.
Quoted 6 lines
Now you say, you have output even before that - this aears to be a contradiction to me. If you can output characters, then use this as your console. I feel we should not need any special configuration options to do what we should do anyway.
Or am I missing somthing?
I agree we need to set things up so that the console can work as early as possible. With boards that support driver model, until that is running we have no serial, so I think we are talking about the time between entering U-Boot and console_init_f(). This has always been a bit of an issue.
I wonder if we can use the debug UART stuff (as Tom mentioned) but enhance it to support printf()? We could plumb the console into that perhaps? This is a little like CONFIG_PRE_CONSOLE_BUFFER.
It would be nice if it were seamless.
Regards,
Simon