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

login
register
mail settings
Submitter José Miguel Gonçalves
Date Sept. 21, 2012, 6:47 p.m.
Message ID <1348253268-21812-2-git-send-email-jose.goncalves@inov.pt>
Download mbox | patch
Permalink /patch/185877/
State Changes Requested
Delegated to: Minkyu Kang
Headers show

Comments

José Miguel Gonçalves - Sept. 21, 2012, 6:47 p.m.
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@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(+)

Patch

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)