Skip to contentSkip to conversation

tiny-printf: Support sprintf()

PATCH New Marek Vasut 3 participants 7 messages May 31, 2016 – Jun 3, 2016 Library code

lore
Share & tools
lore
#0 lore raw

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.

Cc Simon Glass <[email protected]>
Cc Stefan Roese <[email protected]>
Cc Tom Rini <[email protected]>
Cc lesne at alse-fr.com
---
 lib/tiny-printf.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
lib/tiny-printf.c +14 -2
index 4b70263..5ea2555 100644
@@ -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;
+}
Signature · 1 line
2.7.0
#1 lore raw

PATCH 2/2 ARM: omap: Enable tiny printf on omap3_logic

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.

Cc Simon Glass <[email protected]>
Cc Tom Rini <[email protected]>
Cc lesne at alse-fr.com
---
 configs/omap3_logic_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/omap3_logic_defconfig +1 -0
index 3226247..e7bf385 100644
@@ -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"
Signature · 1 line
2.7.0
#2 lore raw

PATCH 2/2 ARM: omap: Enable tiny printf on omap3_logic

Quoted 8 lines · Marek Vasut

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.

Cc Simon Glass <[email protected]>
Cc Tom Rini <[email protected]>
Cc lesne at alse-fr.com
Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160531/7bbd0b25/attachment.sig>
#3 lore raw

PATCH 2/2 ARM: omap: Enable tiny printf on omap3_logic

In reply to Marek Vasut
Quoted 9 lines · Marek Vasut

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.

Cc Simon Glass <[email protected]>
Cc Tom Rini <[email protected]>
Cc lesne at alse-fr.com

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160603/b7084dd8/attachment.sig>
#4 lore raw

PATCH 1/2 tiny-printf: Support sprintf()

In reply to Marek Vasut
Quoted 8 lines · Marek Vasut

Add a simple version of this function for SPL. It does not check the buffer size as this would add to the code size.

Cc Simon Glass <[email protected]>
Cc Stefan Roese <[email protected]>
Cc Tom Rini <[email protected]>
Cc lesne at alse-fr.com
Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160531/42053a4e/attachment.sig>
#5 lore raw

PATCH 1/2 tiny-printf: Support sprintf()

In reply to Marek Vasut

Hi,

Quoted 8 lines · Marek Vasut

Add a simple version of this function for SPL. It does not check the buffer size as this would add to the code size.

Cc Simon Glass <[email protected]>
Cc Stefan Roese <[email protected]>
Cc Tom Rini <[email protected]>
Cc lesne at 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).

Signature · 1 line
Sylvain
#6 lore raw

PATCH 1/2 tiny-printf: Support sprintf()

In reply to Marek Vasut
Quoted 11 lines · Marek Vasut

Add a simple version of this function for SPL. It does not check the buffer size as this would add to the code size.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160603/72f63bd1/attachment.sig>