Small fixes to SPL/TPL logging
cover Small fixes to SPL/TPL logging
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 2To 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(-)
Signature · 1 line
2.23.0
PATCH 1/2 common: Kconfig: Fix typo in TPL_LOG_CONSOLE description
--- common/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
common/Kconfig +1 -1
@@ -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
Signature · 1 line
2.23.0
PATCH 1/2 common: Kconfig: Fix typo in TPL_LOG_CONSOLE description
Quoted 1 line · Simon South
Signed-off-by Simon South <[email protected]>
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: 833 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191101/7b193abb/attachment.sig>
PATCH 2/2 tiny-printf: Support vsnprintf()
In reply to Simon SouthAdd 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.
--- lib/tiny-printf.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
lib/tiny-printf.c +16 -0
@@ -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, ...) {
Signature · 1 line
2.23.0
PATCH 2/2 tiny-printf: Support vsnprintf()
Quoted 4 lines · Simon South
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.
Quoted 8 lines
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 ofsnprintf(), its buffer-size parameter is ignored.Signed-off-by Simon South <[email protected]>
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: 833 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191101/89abe8e7/attachment.sig>