[U-Boot] [PATCH 1/2] tiny-printf: Support sprintf()

Add a simple version of this function for SPL. It does not check the buffer size as this would add to the code size.
Signed-off-by: Marek Vasut marex@denx.de Cc: Simon Glass sjg@chromium.org Cc: Stefan Roese sr@denx.de Cc: Tom Rini trini@konsulko.com Cc: lesne@alse-fr.com --- lib/tiny-printf.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c index 4b70263..5ea2555 100644 --- a/lib/tiny-printf.c +++ b/lib/tiny-printf.c @@ -147,8 +147,7 @@ static void putc_outstr(char ch) *outstr++ = ch; }
-/* Note that size is ignored */ -int snprintf(char *buf, size_t size, const char *fmt, ...) +int sprintf(char *buf, const char *fmt, ...) { va_list va; int ret; @@ -161,3 +160,16 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
return ret; } + +/* Note that size is ignored */ +int snprintf(char *buf, size_t size, const char *fmt, ...) +{ + va_list va; + int ret; + + va_start(va, fmt); + ret = sprintf(buf, fmt, va); + va_end(va); + + return ret; +}

Enable support for tiny printf on the omap3_logic board to trim down the SPL size. This makes the SPL actually build again and fit into the SRAM.
Signed-off-by: Marek Vasut marex@denx.de Cc: Simon Glass sjg@chromium.org Cc: Tom Rini trini@konsulko.com Cc: lesne@alse-fr.com --- configs/omap3_logic_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/omap3_logic_defconfig b/configs/omap3_logic_defconfig index 3226247..e7bf385 100644 --- a/configs/omap3_logic_defconfig +++ b/configs/omap3_logic_defconfig @@ -1,6 +1,7 @@ CONFIG_ARM=y CONFIG_OMAP34XX=y CONFIG_TARGET_OMAP3_LOGIC=y +CONFIG_USE_TINY_PRINTF=y CONFIG_SPL=y CONFIG_FIT=y CONFIG_SYS_EXTRA_OPTIONS="NAND"

On Tue, May 31, 2016 at 11:12:47PM +0200, Marek Vasut wrote:
Enable support for tiny printf on the omap3_logic board to trim down the SPL size. This makes the SPL actually build again and fit into the SRAM.
Signed-off-by: Marek Vasut marex@denx.de Cc: Simon Glass sjg@chromium.org Cc: Tom Rini trini@konsulko.com Cc: lesne@alse-fr.com
Reviewed-by: Tom Rini trini@konsulko.com

On Tue, May 31, 2016 at 11:12:47PM +0200, Marek Vasut wrote:
Enable support for tiny printf on the omap3_logic board to trim down the SPL size. This makes the SPL actually build again and fit into the SRAM.
Signed-off-by: Marek Vasut marex@denx.de Cc: Simon Glass sjg@chromium.org Cc: Tom Rini trini@konsulko.com Cc: lesne@alse-fr.com Reviewed-by: Tom Rini trini@konsulko.com
Applied to u-boot/master, thanks!

On Tue, May 31, 2016 at 11:12:46PM +0200, Marek Vasut wrote:
Add a simple version of this function for SPL. It does not check the buffer size as this would add to the code size.
Signed-off-by: Marek Vasut marex@denx.de Cc: Simon Glass sjg@chromium.org Cc: Stefan Roese sr@denx.de Cc: Tom Rini trini@konsulko.com Cc: lesne@alse-fr.com
Reviewed-by: Tom Rini trini@konsulko.com

Hi,
On 05/31/2016 11:12 PM, Marek Vasut wrote:
Add a simple version of this function for SPL. It does not check the buffer size as this would add to the code size.
Signed-off-by: Marek Vasut marex@denx.de Cc: Simon Glass sjg@chromium.org Cc: Stefan Roese sr@denx.de Cc: Tom Rini trini@konsulko.com Cc: lesne@alse-fr.com
This is how I would do it as well, and I can confirm that it builds and boots on a socfpga platform (sockit), when using part_dos.c (that includes sprintf() calls).
Reviewed-by: Sylvain Lesne lesne@alse-fr.com Tested-by: Sylvain Lesne lesne@alse-fr.com

On Tue, May 31, 2016 at 11:12:46PM +0200, Marek Vasut wrote:
Add a simple version of this function for SPL. It does not check the buffer size as this would add to the code size.
Signed-off-by: Marek Vasut marex@denx.de Cc: Simon Glass sjg@chromium.org Cc: Stefan Roese sr@denx.de Cc: Tom Rini trini@konsulko.com Cc: lesne@alse-fr.com Reviewed-by: Tom Rini trini@konsulko.com Reviewed-by: Sylvain Lesne lesne@alse-fr.com Tested-by: Sylvain Lesne lesne@alse-fr.com
Applied to u-boot/master, thanks!
participants (3)
-
Marek Vasut
-
Sylvain Lesne
-
Tom Rini