console: Avoid serial output before the console is running
authorSimon Glass <sjg@chromium.org>
Fri, 19 Nov 2021 20:23:47 +0000 (13:23 -0700)
committerAnatolij Gustschin <agust@denx.de>
Sun, 26 Dec 2021 22:02:19 +0000 (23:02 +0100)
The video driver uses this for debugging, but if used before relocation it
crashes at present. Avoid trying to output debugging before the console is
ready.

Signed-off-by: Simon Glass <sjg@chromium.org>
common/console.c

index 0c9099c..2bccc8a 100644 (file)
@@ -348,7 +348,8 @@ static void console_puts_select(int file, bool serial_only, const char *s)
 
 void console_puts_select_stderr(bool serial_only, const char *s)
 {
-       console_puts_select(stderr, serial_only, s);
+       if (gd->flags & GD_FLG_DEVINIT)
+               console_puts_select(stderr, serial_only, s);
 }
 
 static void console_puts(int file, const char *s)
@@ -401,7 +402,8 @@ static inline void console_putc(int file, const char c)
 
 void console_puts_select(int file, bool serial_only, const char *s)
 {
-       if (serial_only == console_dev_is_serial(stdio_devices[file]))
+       if ((gd->flags & GD_FLG_DEVINIT) &&
+           serial_only == console_dev_is_serial(stdio_devices[file]))
                stdio_devices[file]->puts(stdio_devices[file], s);
 }