[U-Boot] [PATCH v5 01/11] Add configuration option to select printf() inclusion on SPL

José Miguel Gonçalves jose.goncalves at inov.pt
Fri Sep 21 20:47:38 CEST 2012


The printf() implementation needs 4~5KB of storage space which may not be
available when building an SPL for SoCs with scarce internal RAM
(8KB or less). This patch adds a new option, CONFIG_SPL_PRINTF_SUPPORT,
to deal with this.

Signed-off-by: José Miguel Gonçalves <jose.goncalves at inov.pt>
---
Changes for v3:
   - New patch

Changes for v4:
   - None

Changes for v5:
   - None
---
 README           |    3 +++
 include/common.h |   11 +++++++++++
 2 files changed, 14 insertions(+)

diff --git a/README b/README
index 016d8bc..988812c 100644
--- a/README
+++ b/README
@@ -2576,6 +2576,9 @@ FIT uImage format:
 		CONFIG_SPL_LIBCOMMON_SUPPORT
 		Support for common/libcommon.o in SPL binary
 
+		CONFIG_SPL_PRINTF_SUPPORT
+		Enable printf() support in common/libcommon.o
+
 		CONFIG_SPL_LIBDISK_SUPPORT
 		Support for disk/libdisk.o in SPL binary
 
diff --git a/include/common.h b/include/common.h
index 55025c0..c10d745 100644
--- a/include/common.h
+++ b/include/common.h
@@ -805,9 +805,20 @@ int	tstc(void);
 /* stdout */
 void	putc(const char c);
 void	puts(const char *s);
+/*
+ * The printf() implementation needs 4~5KB of storage space which may not be
+ * available when building an SPL for SoCs with scarce internal RAM
+ * (8KB or less). To force printf() inclusion on an SPL we must define
+ * CONFIG_SPL_LIBCOMMON_SUPPORT and CONFIG_SPL_PRINTF_SUPPORT.
+ */
+#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_PRINTF_SUPPORT)
 int	printf(const char *fmt, ...)
 		__attribute__ ((format (__printf__, 1, 2)));
 int	vprintf(const char *fmt, va_list args);
+#else
+#define printf(fmt...) do {} while (0)
+#define vprintf(fmt, args) do {} while (0)
+#endif
 
 /* stderr */
 #define eputc(c)		fputc(stderr, c)
-- 
1.7.9.5



More information about the U-Boot mailing list