public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] console: Support board-specific early console
@ 2015-03-20 11:30 Thierry Reding
  2015-03-20 11:30 ` [U-Boot] [PATCH 2/2] ARM: tegra: Implement early console support Thierry Reding
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Thierry Reding @ 2015-03-20 11:30 UTC (permalink / raw)
  To: u-boot

From: Thierry Reding <treding@nvidia.com>

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.

Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 README           | 17 +++++++++++++++++
 common/console.c | 21 +++++++++++++++++++--
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/README b/README
index b0124d6022e1..a7cb3d86d2d2 100644
--- a/README
+++ b/README
@@ -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:
 -----------------------------------
 
diff --git a/common/console.c b/common/console.c
index 3f25e76fe79e..d552dff4ee0f 100644
--- a/common/console.c
+++ b/common/console.c
@@ -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
-- 
2.3.2

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

end of thread, other threads:[~2015-03-23 23:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-20 11:30 [U-Boot] [PATCH 1/2] console: Support board-specific early console Thierry Reding
2015-03-20 11:30 ` [U-Boot] [PATCH 2/2] ARM: tegra: Implement early console support Thierry Reding
2015-03-20 15:24 ` [U-Boot] [PATCH 1/2] console: Support board-specific early console Tom Rini
2015-03-20 16:55 ` Wolfgang Denk
2015-03-23 23:38   ` Simon Glass

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