[PATCH V3] tiny-printf: Handle formatting of %p with an extra Kconfig

Tom Rini trini at konsulko.com
Wed May 7 19:42:33 CEST 2025


On Wed, Apr 30, 2025 at 12:35:48PM +0200, Christoph Niedermaier wrote:

> The formatting with %pa / %pap behaves like %x, which results in an
> incorrect value being output. To improve this, a new fine-tuning
> Kconfig SPL_USE_TINY_PRINTF_POINTER_SUPPORT for pointer formatting
> has been added. If it is enabled, the output of %pa / %pap should
> be correct, and if it is disabled, the pointer formatting is
> completely unsupported. In addition to indicate unsupported formatting,
> '?' will be output. This allows enabling pointer formatting only
> when needed. For SPL_NET and NET_LWIP it is selected by default.
> Then it also supports the formatting with %pm, %pM and %pI4.
> 
> In summery this level of %p support for tiny printf is possible now:
> 
> 1) The standard tiny printf won't have support for pointer formatting.
>    So it doesn't print misleading values for %pa, instead '?' will be
>    output:
>    %p   => ?
>    %pa  => ?a
>    %pap => ?ap
> 
> 2) If SPL_USE_TINY_PRINTF_POINTER_SUPPORT is enabled or DEBUG is defined
>    tiny printf supports formatting %p and %pa / %pap.
> 
> 3) If SPL_NET or NET_LWIP is enabled the support of pointers is extended
>    for %pm, %pM and %pI4.
> 
> Signed-off-by: Christoph Niedermaier <cniedermaier at dh-electronics.com>
> ---
> Cc: Tom Rini <trini at konsulko.com>
> Cc: Simon Glass <sjg at chromium.org>
> Cc: Michael Walle <mwalle at kernel.org>
> Cc: Quentin Schulz <quentin.schulz at cherry.de>
> Cc: Marek Vasut <marex at denx.de>
> Cc: Benedikt Spranger <b.spranger at linutronix.de>
> Cc: Jerome Forissier <jerome.forissier at linaro.org>
> Cc: John Ogness <john.ogness at linutronix.de>
> Cc: Ilias Apalodimas <ilias.apalodimas at linaro.org>
> ---
> V2: - Rebase on current master
>     - Extend commit message
>     - Restrict use to SPL
>     - Rename Kconfig to SPL_USE_TINY_PRINTF_POINTER_SUPPORT
>     - Replace _DEBUG with defined(DEBUG)
>     - Output '?' if %pm, %pM and %pI4 isn't available
>     - Add break on case '%'
> V3: - Add missing output '?' for the default case
> ---
>  Kconfig            |  1 +
>  common/spl/Kconfig |  1 +
>  lib/Kconfig        |  8 +++++++
>  lib/tiny-printf.c  | 52 +++++++++++++++++++++++-----------------------
>  4 files changed, 36 insertions(+), 26 deletions(-)
> 
> diff --git a/Kconfig b/Kconfig
> index 51358633762..b8eec3fc931 100644
> --- a/Kconfig
> +++ b/Kconfig
> @@ -774,6 +774,7 @@ config NET
>  
>  config NET_LWIP
>  	bool "Use lwIP for networking stack"
> +	select SPL_USE_TINY_PRINTF_POINTER_SUPPORT if SPL_USE_TINY_PRINTF
>  	imply NETDEVICES
>  	help
>  	  Include networking support based on the lwIP (lightweight IP)

Sorry I missed this bug until now. This (and the subsequent parts of the
patch referencing lwIP) aren't right. There's no SPL_NET_LWIP support
(and not planned at this point), so what this does is grow platforms
like xilinx_zynq_virt which use lwIP in U-Boot and tiny printf in SPL,
but shouldn't since there's no SPL_NET_LWIP.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20250507/5219b7e1/attachment.sig>


More information about the U-Boot mailing list