If puts() or printf() is called before the console is ready, U-Boot will
either hang or die. This adds a check for this so that debug() can be used
in early code without concern that it will hang.

U-Boot boots properly

Tested-by: Simon Glass <s...@chromium.org>
Signed-off-by: Simon Glass <s...@chromium.org>
---
 common/console.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/console.c b/common/console.c
index 8c650e0..28ddb95 100644
--- a/common/console.c
+++ b/common/console.c
@@ -338,7 +338,7 @@ void putc(const char c)
        if (gd->flags & GD_FLG_DEVINIT) {
                /* Send to the standard output */
                fputc(stdout, c);
-       } else {
+       } else if (gd->have_console) {
                /* Send directly to the handler */
                serial_putc(c);
        }
@@ -359,7 +359,7 @@ void puts(const char *s)
        if (gd->flags & GD_FLG_DEVINIT) {
                /* Send to the standard output */
                fputs(stdout, s);
-       } else {
+       } else if (gd->have_console) {
                /* Send directly to the handler */
                serial_puts(s);
        }
-- 
1.7.3.1

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to