[U-Boot] [PATCH v3 16/21] sandbox: Allow puts() output before global_data is set up

Simon Glass sjg at chromium.org
Fri Nov 16 01:44:04 UTC 2018


We support putc() in this case but not puts(), but this is more useful
since it is what printf() uses.

This particularly affects debugging early in SPL, where currently printf()
statements result in no output. Fix this by adding a special case into
puts() for sandbox, just like putc().

Signed-off-by: Simon Glass <sjg at chromium.org>
Reviewed-by: Joe Hershberger <joe.hershberger at ni.com>
---

Changes in v3: None
Changes in v2: None

 common/console.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/common/console.c b/common/console.c
index 9a94f321922..0b0dd76256c 100644
--- a/common/console.c
+++ b/common/console.c
@@ -535,6 +535,13 @@ void putc(const char c)
 
 void puts(const char *s)
 {
+#ifdef CONFIG_SANDBOX
+	/* sandbox can send characters to stdout before it has a console */
+	if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
+		os_puts(s);
+		return;
+	}
+#endif
 #ifdef CONFIG_DEBUG_UART
 	if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
 		while (*s) {
-- 
2.19.1.1215.g8438c0b245-goog



More information about the U-Boot mailing list