lib/tiny-printf.c: Add tiny printf function for space limited environments
This patch adds a small printf() version that supports all basic formats. Its intented to be used in U-Boot SPL versions on platforms with very limited internal RAM sizes. To enable it, just define CONFIG_USE_TINY_PRINTF in your defconfig. This will result in the SPL using this tiny function and the main U-Boot still using the full-blown printf() function. This code was copied from: http://www.sparetimelabs.com/printfrevisited With mostly only coding style related changes so that its checkpatch clean. The size reduction is about 2.5KiB. Here a comparison for the db-mv784mp-gp (Marvell AXP) SPL: Without this patch: 58963 18536 1928 79427 13643 ./spl/u-boot-spl With this patch: 56542 18536 1956 77034 12cea ./spl/u-boot-spl Note: To make it possible to compile tiny-printf.c instead of vsprintf.c when CONFIG_USE_TINY_PRINTF is defined, the functions printf() and vprintf() are moved from common/console.c into vsprintf.c in this patch. Signed-off-by: Stefan Roese <sr@denx.de> Cc: Simon Glass <sjg@chromium.org> Cc: Hans de Goede <hdegoede@redhat.com> Cc: Tom Rini <trini@konsulko.com> Cc: Albert Aribaud <albert.u.boot@aribaud.net>
This commit is contained in:
13
lib/Makefile
13
lib/Makefile
@@ -80,7 +80,18 @@ obj-y += string.o
|
||||
obj-y += time.o
|
||||
obj-$(CONFIG_TRACE) += trace.o
|
||||
obj-$(CONFIG_LIB_UUID) += uuid.o
|
||||
obj-y += vsprintf.o
|
||||
obj-$(CONFIG_LIB_RAND) += rand.o
|
||||
|
||||
ifdef CONFIG_SPL_BUILD
|
||||
# SPL U-Boot may use full-printf, tiny-printf or none at all
|
||||
ifdef CONFIG_USE_TINY_PRINTF
|
||||
obj-$(CONFIG_SPL_SERIAL_SUPPORT) += tiny-printf.o
|
||||
else
|
||||
obj-$(CONFIG_SPL_SERIAL_SUPPORT) += vsprintf.o
|
||||
endif
|
||||
else
|
||||
# Main U-Boot always uses the full printf support
|
||||
obj-y += vsprintf.o
|
||||
endif
|
||||
|
||||
subdir-ccflags-$(CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED) += -O2
|
||||
|
||||
Reference in New Issue
Block a user