All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/2] Small fixes to SPL/TPL logging
@ 2019-10-02 14:55 Simon South
  2019-10-02 14:55 ` [U-Boot] [PATCH 1/2] common: Kconfig: Fix typo in TPL_LOG_CONSOLE description Simon South
  2019-10-02 14:55 ` [U-Boot] [PATCH 2/2] tiny-printf: Support vsnprintf() Simon South
  0 siblings, 2 replies; 5+ messages in thread
From: Simon South @ 2019-10-02 14:55 UTC (permalink / raw)
  To: u-boot

These two patches fix small issues I encountered when enabling
debugging output for U-Boot's TPL.

The first fixes a typo in the description of the TPL_LOG_CONSOLE
configuration option.

The second adds a simple implementation of vsnprintf() to the
tiny-printf library. Without this, enabling either SPL or TPL logging
for systems (such as the PINE64 ROCK64) that also use the tiny
printf() implementation causes the build to fail with error messages
like

    aarch64-linux-gnu-ld.bfd: common/built-in.o: in function `_log':
    (...)/u-boot/common/log.c:212: undefined reference to `vsnprintf'
    make[1]: *** [scripts/Makefile.spl:404: spl/u-boot-spl] Error 1
    make: *** [Makefile:1762: spl/u-boot-spl] Error 2

To minimize the impact on code size, the function is built only when
logging is enabled, as it appears to be unneeded otherwise.

Note we could probably shave off a few bytes by having the existing
sprintf() and snprintf() functions call vsnprintf() when it's
available. I haven't made this change only because it isn't how the
existing code is written (printf() could call vprintf(), and
snprintf() could call sprintf(), yet neither do) and I assume this is
for a reason.

Simon South (2):
  common: Kconfig: Fix typo in TPL_LOG_CONSOLE description
  tiny-printf: Support vsnprintf()

 common/Kconfig    |  2 +-
 lib/tiny-printf.c | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

-- 
2.23.0

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH 1/2] common: Kconfig: Fix typo in TPL_LOG_CONSOLE description
  2019-10-02 14:55 [U-Boot] [PATCH 0/2] Small fixes to SPL/TPL logging Simon South
@ 2019-10-02 14:55 ` Simon South
  2019-11-01 13:29   ` Tom Rini
  2019-10-02 14:55 ` [U-Boot] [PATCH 2/2] tiny-printf: Support vsnprintf() Simon South
  1 sibling, 1 reply; 5+ messages in thread
From: Simon South @ 2019-10-02 14:55 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Simon South <simon@simonsouth.net>
---
 common/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/Kconfig b/common/Kconfig
index 28d5e9a0cc..d9ecf79e0a 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -764,7 +764,7 @@ config SPL_LOG_CONSOLE
 	  line number are omitted.
 
 config TPL_LOG_CONSOLE
-	bool "Allow log output to the console in SPL"
+	bool "Allow log output to the console in TPL"
 	depends on TPL_LOG
 	default y
 	help
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH 2/2] tiny-printf: Support vsnprintf()
  2019-10-02 14:55 [U-Boot] [PATCH 0/2] Small fixes to SPL/TPL logging Simon South
  2019-10-02 14:55 ` [U-Boot] [PATCH 1/2] common: Kconfig: Fix typo in TPL_LOG_CONSOLE description Simon South
@ 2019-10-02 14:55 ` Simon South
  2019-11-01 13:29   ` Tom Rini
  1 sibling, 1 reply; 5+ messages in thread
From: Simon South @ 2019-10-02 14:55 UTC (permalink / raw)
  To: u-boot

Add a simple implementation of this function, to allow logging to be
enabled in the SPL or TPL for systems that rely on the tiny printf()
implementation.

To keep the code size small,

- The function is built only when logging is enabled, as it
  (currently) is not needed otherwise; and
- Like the existing implementation of snprintf(), its buffer-size
  parameter is ignored.

Signed-off-by: Simon South <simon@simonsouth.net>
---
 lib/tiny-printf.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c
index ebef92fc9f..62e6381961 100644
--- a/lib/tiny-printf.c
+++ b/lib/tiny-printf.c
@@ -366,6 +366,22 @@ int sprintf(char *buf, const char *fmt, ...)
 	return ret;
 }
 
+#if CONFIG_IS_ENABLED(LOG)
+/* Note that size is ignored */
+int vsnprintf(char *buf, size_t size, const char *fmt, va_list va)
+{
+	struct printf_info info;
+	int ret;
+
+	info.outstr = buf;
+	info.putc = putc_outstr;
+	ret = _vprintf(&info, fmt, va);
+	*info.outstr = '\0';
+
+	return ret;
+}
+#endif
+
 /* Note that size is ignored */
 int snprintf(char *buf, size_t size, const char *fmt, ...)
 {
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH 1/2] common: Kconfig: Fix typo in TPL_LOG_CONSOLE description
  2019-10-02 14:55 ` [U-Boot] [PATCH 1/2] common: Kconfig: Fix typo in TPL_LOG_CONSOLE description Simon South
@ 2019-11-01 13:29   ` Tom Rini
  0 siblings, 0 replies; 5+ messages in thread
From: Tom Rini @ 2019-11-01 13:29 UTC (permalink / raw)
  To: u-boot

On Wed, Oct 02, 2019 at 10:55:06AM -0400, Simon South wrote:

> Signed-off-by: Simon South <simon@simonsouth.net>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191101/7b193abb/attachment.sig>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH 2/2] tiny-printf: Support vsnprintf()
  2019-10-02 14:55 ` [U-Boot] [PATCH 2/2] tiny-printf: Support vsnprintf() Simon South
@ 2019-11-01 13:29   ` Tom Rini
  0 siblings, 0 replies; 5+ messages in thread
From: Tom Rini @ 2019-11-01 13:29 UTC (permalink / raw)
  To: u-boot

On Wed, Oct 02, 2019 at 10:55:07AM -0400, Simon South wrote:

> Add a simple implementation of this function, to allow logging to be
> enabled in the SPL or TPL for systems that rely on the tiny printf()
> implementation.
> 
> To keep the code size small,
> 
> - The function is built only when logging is enabled, as it
>   (currently) is not needed otherwise; and
> - Like the existing implementation of snprintf(), its buffer-size
>   parameter is ignored.
> 
> Signed-off-by: Simon South <simon@simonsouth.net>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191101/89abe8e7/attachment.sig>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-11-01 13:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-02 14:55 [U-Boot] [PATCH 0/2] Small fixes to SPL/TPL logging Simon South
2019-10-02 14:55 ` [U-Boot] [PATCH 1/2] common: Kconfig: Fix typo in TPL_LOG_CONSOLE description Simon South
2019-11-01 13:29   ` Tom Rini
2019-10-02 14:55 ` [U-Boot] [PATCH 2/2] tiny-printf: Support vsnprintf() Simon South
2019-11-01 13:29   ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.