tiny-printf: Handle formatting of %p with an extra Kconfig
PATCH 1/1 tiny-printf: Handle formatting of %p with an extra Kconfig
The formatting with %pa / %pap behaves like %x, which results in an incorrect value being output. To improve this, a new fine-tuning Kconfig XPL_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.
---
Cc: Tom Rini <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Michael Walle <[email protected]>
Cc: Quentin Schulz <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Benedikt Spranger <[email protected]>
Cc: Jerome Forissier <[email protected]>
Cc: John Ogness <[email protected]>
Cc: Ilias Apalodimas <[email protected]>
--- Kconfig | 1 + common/spl/Kconfig | 1 + lib/Kconfig | 8 ++++++++ lib/tiny-printf.c | 45 +++++++++++++++++++-------------------------- 4 files changed, 29 insertions(+), 26 deletions(-)
Kconfig +1 -0
@@ -757,6 +757,7 @@ config NET config NET_LWIP bool "Use lwIP for networking stack" + select XPL_USE_TINY_PRINTF_POINTER_SUPPORT if SPL_USE_TINY_PRINTF || TPL_USE_TINY_PRINTF || VPL_USE_TINY_PRINTF imply NETDEVICES help Include networking support based on the lwIP (lightweight IP)
common/spl/Kconfig +1 -0
@@ -1096,6 +1096,7 @@ config SPL_DM_SPI_FLASH config SPL_NET bool "Support networking" depends on !NET_LWIP + select XPL_USE_TINY_PRINTF_POINTER_SUPPORT if SPL_USE_TINY_PRINTF || TPL_USE_TINY_PRINTF || VPL_USE_TINY_PRINTF help Enable support for network devices (such as Ethernet) in SPL. This permits SPL to load U-Boot over a network link rather than
lib/Kconfig +8 -0
@@ -253,6 +253,14 @@ config VPL_USE_TINY_PRINTF The supported format specifiers are %c, %s, %u/%d and %x. +config XPL_USE_TINY_PRINTF_POINTER_SUPPORT + bool "Extend tiny printf with the pointer formatting %p" + depends on SPL_USE_TINY_PRINTF || TPL_USE_TINY_PRINTF || VPL_USE_TINY_PRINTF + help + This option enables the formatting of pointers %p. It supports + %p and %pa / %pap. If this option is selected by SPL_NET or NET_LWIP + it also supports the formatting with %pm, %pM and %pI4. + config PANIC_HANG bool "Do not reset the system on fatal error" help
lib/tiny-printf.c +19 -26
98 lines not on this page · raw message
Signature · 1 line
2.30.2
Quoted 57 lines · Christoph Niedermaier
The formatting with %pa / %pap behaves like %x, which results in an incorrect value being output. To improve this, a new fine-tuning
KconfigXPL_USE_TINY_PRINTF_POINTER_SUPPORTfor 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. ForSPL_NETandNET_LWIPit is selected by default. Then it also supports the formatting with %pm, %pM and %pI4.Signed-off-by Christoph Niedermaier <[email protected]>---
Cc: Tom Rini <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Michael Walle <[email protected]>
Cc: Quentin Schulz <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Benedikt Spranger <[email protected]>
Cc: Jerome Forissier <[email protected]>
Cc: John Ogness <[email protected]>
Cc: Ilias Apalodimas <[email protected]>--- Kconfig | 1 + common/spl/Kconfig | 1 + lib/Kconfig | 8 ++++++++ lib/tiny-printf.c | 45 +++++++++++++++++++-------------------------- 4 files changed, 29 insertions(+), 26 deletions(-)Kconfig +1
-0@@ -757,6 +757,7 @@ config NET config NET_LWIP bool "Use lwIP for networking stack" + select XPL_USE_TINY_PRINTF_POINTER_SUPPORT if SPL_USE_TINY_PRINTF || TPL_USE_TINY_PRINTF || VPL_USE_TINY_PRINTF imply NETDEVICES help Include networking support based on the lwIP (lightweight IP)common/spl/Kconfig +1
-0@@ -1096,6 +1096,7 @@ config SPL_DM_SPI_FLASH config SPL_NET bool "Support networking" depends on !NET_LWIP + select XPL_USE_TINY_PRINTF_POINTER_SUPPORT if SPL_USE_TINY_PRINTF || TPL_USE_TINY_PRINTF || VPL_USE_TINY_PRINTF help Enable support for network devices (such as Ethernet) in SPL. This permits SPL to load U-Boot over a network link rather thanlib/Kconfig +0
-0
lib/Kconfig config VPL_USE_TINY_PRINTF · line 262
Quoted 10 lines
lib/Kconfig +7
-0@@ -253,6 +253,14 @@ config VPL_USE_TINY_PRINTF The supported format specifiers are %c, %s, %u/%d and %x. +config XPL_USE_TINY_PRINTF_POINTER_SUPPORT + bool "Extend tiny printf with the pointer formatting %p" + depends on SPL_USE_TINY_PRINTF || TPL_USE_TINY_PRINTF || VPL_USE_TINY_PRINTF + help + This option enables the formatting of pointers %p. It supports + %p and %pa / %pap. If this option is selected by SPL_NET or NET_LWIP + it also supports the formatting with %pm, %pM and %pI4.
This isn't quite what I'd like to see. I don't want to start using the literal XPL namespace as that will lead to confusion down the line. Since we only have SPL_NET, I think we should name this symbol SPL_USE_TINY_PRINTF_POINTER_SUPPORT, not ask about it (so bool without "prompt text" following), and select from SPL_NET if SPL_USE_TINY_PRINTF.
Signature · 1 line
Tom
From: Tom Rini <[email protected]>
Sent: Tuesday, April 8, 2025 10:58 PM
Quoted 70 lines
To: Christoph Niedermaier <[email protected]>
Cc: [email protected]; Simon Glass <[email protected]>; Michael Walle <[email protected]>; Quentin Schulz <[email protected]>; Marek Vasut <[email protected]>; Benedikt Spranger <[email protected]>; Jerome Forissier <[email protected]>; John Ogness <[email protected]>; Ilias Apalodimas <[email protected]>
Subject: Re: [PATCH] tiny-printf: Handle formatting of %p with an extraKconfigQuoted 60 lines · Christoph Niedermaier
The formatting with %pa / %pap behaves like %x, which results in an incorrect value being output. To improve this, a new fine-tuning
KconfigXPL_USE_TINY_PRINTF_POINTER_SUPPORTfor 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. ForSPL_NETandNET_LWIPit is selected by default. Then it also supports the formatting with %pm, %pM and %pI4.Signed-off-by Christoph Niedermaier <[email protected]>---
Cc: Tom Rini <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Michael Walle <[email protected]>
Cc: Quentin Schulz <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Benedikt Spranger <[email protected]>
Cc: Jerome Forissier <[email protected]>
Cc: John Ogness <[email protected]>
Cc: Ilias Apalodimas <[email protected]>--- Kconfig | 1 + common/spl/Kconfig | 1 + lib/Kconfig | 8 ++++++++ lib/tiny-printf.c | 45 +++++++++++++++++++-------------------------- 4 files changed, 29 insertions(+), 26 deletions(-)Kconfig +1
-0@@ -757,6 +757,7 @@ config NET config NET_LWIP bool "Use lwIP for networking stack" + select XPL_USE_TINY_PRINTF_POINTER_SUPPORT if SPL_USE_TINY_PRINTF || TPL_USE_TINY_PRINTF || VPL_USE_TINY_PRINTF imply NETDEVICES help Include networking support based on the lwIP (lightweight IP)common/spl/Kconfig +1
-0@@ -1096,6 +1096,7 @@ config SPL_DM_SPI_FLASH config SPL_NET bool "Support networking" depends on !NET_LWIP + select XPL_USE_TINY_PRINTF_POINTER_SUPPORT if SPL_USE_TINY_PRINTF || TPL_USE_TINY_PRINTF || VPL_USE_TINY_PRINTF help Enable support for network devices (such as Ethernet) in SPL. This permits SPL to load U-Boot over a network link rather thanlib/Kconfig +0
-0@@ -253,6 +253,14 @@ config VPL_USE_TINY_PRINTF The supported format specifiers are %c, %s, %u/%d and %x.
Quoted 10 lines
lib/Kconfig config VPL_USE_TINY_PRINTF · line 262
Quoted 7 lines
lib/Kconfig +7
-0+config XPL_USE_TINY_PRINTF_POINTER_SUPPORT + bool "Extend tiny printf with the pointer formatting %p" + depends on SPL_USE_TINY_PRINTF || TPL_USE_TINY_PRINTF || VPL_USE_TINY_PRINTF + help + This option enables the formatting of pointers %p. It supports + %p and %pa / %pap. If this option is selected by SPL_NET or NET_LWIP + it also supports the formatting with %pm, %pM and %pI4.This isn't quite what I'd like to see. I don't want to start using the literal XPL namespace as that will lead to confusion down the line.
OK, in V2 I will only support SPL.
Quoted 4 lines
Since we only have
SPL_NET, I think we should name this symbolSPL_USE_TINY_PRINTF_POINTER_SUPPORT, not ask about it (so bool without "prompt text" following), and select fromSPL_NETifSPL_USE_TINY_PRINTF.
Now you will get the output '?' when using formatting with %p or %pa. If someone wants to use the pointer support e.g. %pa in pinctrl-single.c and is restricted to use tiny printf, then it would be good to have the option to enable it manually and not be forced to enable SPL_NET or NET_LWIP to have the pointer support enabled. In this case, it makes sense to allow switching it on in menuconfig.
Regards
Christoph
Hi,
Quoted 71 lines
Quoted 60 lines
Quoted 60 lines
The formatting with %pa / %pap behaves like %x, which results in an incorrect value being output. To improve this, a new fine-tuning
KconfigXPL_USE_TINY_PRINTF_POINTER_SUPPORTfor 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. ForSPL_NETandNET_LWIPit is selected by default. Then it also supports the formatting with %pm, %pM and %pI4.Signed-off-by Christoph Niedermaier <[email protected]>---
Cc: Tom Rini <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Michael Walle <[email protected]>
Cc: Quentin Schulz <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Benedikt Spranger <[email protected]>
Cc: Jerome Forissier <[email protected]>
Cc: John Ogness <[email protected]>
Cc: Ilias Apalodimas <[email protected]>--- Kconfig | 1 + common/spl/Kconfig | 1 + lib/Kconfig | 8 ++++++++ lib/tiny-printf.c | 45 +++++++++++++++++++-------------------------- 4 files changed, 29 insertions(+), 26 deletions(-)Kconfig +1
-0@@ -757,6 +757,7 @@ config NET config NET_LWIP bool "Use lwIP for networking stack" + select XPL_USE_TINY_PRINTF_POINTER_SUPPORT if SPL_USE_TINY_PRINTF || TPL_USE_TINY_PRINTF || VPL_USE_TINY_PRINTF imply NETDEVICES help Include networking support based on the lwIP (lightweight IP)common/spl/Kconfig +1
-0@@ -1096,6 +1096,7 @@ config SPL_DM_SPI_FLASH config SPL_NET bool "Support networking" depends on !NET_LWIP + select XPL_USE_TINY_PRINTF_POINTER_SUPPORT if SPL_USE_TINY_PRINTF || TPL_USE_TINY_PRINTF || VPL_USE_TINY_PRINTF help Enable support for network devices (such as Ethernet) in SPL. This permits SPL to load U-Boot over a network link rather thanlib/Kconfig +0
-0@@ -253,6 +253,14 @@ config VPL_USE_TINY_PRINTF The supported format specifiers are %c, %s, %u/%d and %x.Quoted 10 lines
lib/Kconfig config VPL_USE_TINY_PRINTF · line 262
Quoted 7 lines
lib/Kconfig +7
-0+config XPL_USE_TINY_PRINTF_POINTER_SUPPORT + bool "Extend tiny printf with the pointer formatting %p" + depends on SPL_USE_TINY_PRINTF || TPL_USE_TINY_PRINTF || VPL_USE_TINY_PRINTF + help + This option enables the formatting of pointers %p. It supports + %p and %pa / %pap. If this option is selected by SPL_NET or NET_LWIP + it also supports the formatting with %pm, %pM and %pI4.This isn't quite what I'd like to see. I don't want to start using the literal XPL namespace as that will lead to confusion down the line.
Quoted 6 lines
OK, in V2 I will only support SPL.
Quoted 4 lines
Since we only have
SPL_NET, I think we should name this symbolSPL_USE_TINY_PRINTF_POINTER_SUPPORT, not ask about it (so bool without "prompt text" following), and select fromSPL_NETifSPL_USE_TINY_PRINTF.
IIRC, the old one also enabled the pointer support if DEBUG is enabled. I don't think this will work with Kconfig.
Quoted 6 lines
Now you will get the output '?' when using formatting with %p or %pa. If someone wants to use the pointer support e.g. %pa in
pinctrl-single.cand is restricted to use tiny printf, then it would be good to have the option to enable it manually and not be forced to enableSPL_NETorNET_LWIPto have the pointer support enabled. In this case, it makes sense to allow switching it on in menuconfig.
FWIW, I'm also fine with enabling full printf support as long as the tiny one doesn't print misleading values.
-michael
Quoted 75 lines · Michael Walle
Hi,
Quoted 73 lines
Quoted 60 lines
Quoted 60 lines
The formatting with %pa / %pap behaves like %x, which results in an incorrect value being output. To improve this, a new fine-tuning
KconfigXPL_USE_TINY_PRINTF_POINTER_SUPPORTfor 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. ForSPL_NETandNET_LWIPit is selected by default. Then it also supports the formatting with %pm, %pM and %pI4.Signed-off-by Christoph Niedermaier <[email protected]>---
Cc: Tom Rini <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Michael Walle <[email protected]>
Cc: Quentin Schulz <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Benedikt Spranger <[email protected]>
Cc: Jerome Forissier <[email protected]>
Cc: John Ogness <[email protected]>
Cc: Ilias Apalodimas <[email protected]>--- Kconfig | 1 + common/spl/Kconfig | 1 + lib/Kconfig | 8 ++++++++ lib/tiny-printf.c | 45 +++++++++++++++++++-------------------------- 4 files changed, 29 insertions(+), 26 deletions(-)Kconfig +1
-0@@ -757,6 +757,7 @@ config NET config NET_LWIP bool "Use lwIP for networking stack" + select XPL_USE_TINY_PRINTF_POINTER_SUPPORT if SPL_USE_TINY_PRINTF || TPL_USE_TINY_PRINTF || VPL_USE_TINY_PRINTF imply NETDEVICES help Include networking support based on the lwIP (lightweight IP)common/spl/Kconfig +1
-0@@ -1096,6 +1096,7 @@ config SPL_DM_SPI_FLASH config SPL_NET bool "Support networking" depends on !NET_LWIP + select XPL_USE_TINY_PRINTF_POINTER_SUPPORT if SPL_USE_TINY_PRINTF || TPL_USE_TINY_PRINTF || VPL_USE_TINY_PRINTF help Enable support for network devices (such as Ethernet) in SPL. This permits SPL to load U-Boot over a network link rather thanlib/Kconfig +0
-0@@ -253,6 +253,14 @@ config VPL_USE_TINY_PRINTF The supported format specifiers are %c, %s, %u/%d and %x.Quoted 10 lines
lib/Kconfig config VPL_USE_TINY_PRINTF · line 262
Quoted 7 lines
lib/Kconfig +7
-0+config XPL_USE_TINY_PRINTF_POINTER_SUPPORT + bool "Extend tiny printf with the pointer formatting %p" + depends on SPL_USE_TINY_PRINTF || TPL_USE_TINY_PRINTF || VPL_USE_TINY_PRINTF + help + This option enables the formatting of pointers %p. It supports + %p and %pa / %pap. If this option is selected by SPL_NET or NET_LWIP + it also supports the formatting with %pm, %pM and %pI4.This isn't quite what I'd like to see. I don't want to start using the literal XPL namespace as that will lead to confusion down the line.
OK, in V2 I will only support SPL.
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Since we only have
SPL_NET, I think we should name this symbolSPL_USE_TINY_PRINTF_POINTER_SUPPORT, not ask about it (so bool without "prompt text" following), and select fromSPL_NETifSPL_USE_TINY_PRINTF.IIRC, the old one also enabled the pointer support if DEBUG is enabled. I don't think this will work with
Kconfig.
I was looking around for, but didn't quite see, a good existing option to "if .." around the prompt text for.
Quoted 9 lines
Quoted 6 lines
Now you will get the output '?' when using formatting with %p or %pa. If someone wants to use the pointer support e.g. %pa in
pinctrl-single.cand is restricted to use tiny printf, then it would be good to have the option to enable it manually and not be forced to enableSPL_NETorNET_LWIPto have the pointer support enabled. In this case, it makes sense to allow switching it on in menuconfig.FWIW, I'm also fine with enabling full printf support as long as the tiny one doesn't print misleading values.
I'm not sure if the one non-debug %pa print in pinctrl-single.c is really triggered within SPL, and I do hope that the way this patch is otherwise done will make it easier if someone needs %pa to work when debugging a problem in SPL, and can't enable full printf due to space.
Signature · 1 line
Tom
Quoted 81 lines · Tom Rini
Quoted 80 lines · Michael Walle
Hi,
Quoted 77 lines
Quoted 60 lines
Quoted 60 lines
The formatting with %pa / %pap behaves like %x, which results in an incorrect value being output. To improve this, a new fine-tuning
KconfigXPL_USE_TINY_PRINTF_POINTER_SUPPORTfor 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. ForSPL_NETandNET_LWIPit is selected by default. Then it also supports the formatting with %pm, %pM and %pI4.Signed-off-by Christoph Niedermaier <[email protected]>---
Cc: Tom Rini <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Michael Walle <[email protected]>
Cc: Quentin Schulz <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Benedikt Spranger <[email protected]>
Cc: Jerome Forissier <[email protected]>
Cc: John Ogness <[email protected]>
Cc: Ilias Apalodimas <[email protected]>--- Kconfig | 1 + common/spl/Kconfig | 1 + lib/Kconfig | 8 ++++++++ lib/tiny-printf.c | 45 +++++++++++++++++++-------------------------- 4 files changed, 29 insertions(+), 26 deletions(-)Kconfig +1
-0@@ -757,6 +757,7 @@ config NET config NET_LWIP bool "Use lwIP for networking stack" + select XPL_USE_TINY_PRINTF_POINTER_SUPPORT if SPL_USE_TINY_PRINTF || TPL_USE_TINY_PRINTF || VPL_USE_TINY_PRINTF imply NETDEVICES help Include networking support based on the lwIP (lightweight IP)common/spl/Kconfig +1
-0@@ -1096,6 +1096,7 @@ config SPL_DM_SPI_FLASH config SPL_NET bool "Support networking" depends on !NET_LWIP + select XPL_USE_TINY_PRINTF_POINTER_SUPPORT if SPL_USE_TINY_PRINTF || TPL_USE_TINY_PRINTF || VPL_USE_TINY_PRINTF help Enable support for network devices (such as Ethernet) in SPL. This permits SPL to load U-Boot over a network link rather thanlib/Kconfig +0
-0@@ -253,6 +253,14 @@ config VPL_USE_TINY_PRINTF The supported format specifiers are %c, %s, %u/%d and %x.Quoted 10 lines
lib/Kconfig config VPL_USE_TINY_PRINTF · line 262
Quoted 7 lines
lib/Kconfig +7
-0+config XPL_USE_TINY_PRINTF_POINTER_SUPPORT + bool "Extend tiny printf with the pointer formatting %p" + depends on SPL_USE_TINY_PRINTF || TPL_USE_TINY_PRINTF || VPL_USE_TINY_PRINTF + help + This option enables the formatting of pointers %p. It supports + %p and %pa / %pap. If this option is selected by SPL_NET or NET_LWIP + it also supports the formatting with %pm, %pM and %pI4.This isn't quite what I'd like to see. I don't want to start using the literal XPL namespace as that will lead to confusion down the line.
OK, in V2 I will only support SPL.
Quoted 4 lines
Since we only have
SPL_NET, I think we should name this symbolSPL_USE_TINY_PRINTF_POINTER_SUPPORT, not ask about it (so bool without "prompt text" following), and select fromSPL_NETifSPL_USE_TINY_PRINTF.
Quoted 5 lines
Quoted 2 lines
IIRC, the old one also enabled the pointer support if DEBUG is enabled. I don't think this will work with
Kconfig.I was looking around for, but didn't quite see, a good existing option to "if .." around the prompt text for.
What I meant was that you normally do -DDEBUG on a file (or equally a #define DEBUG). Thus you cannot add it to Kconfig.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Now you will get the output '?' when using formatting with %p or %pa. If someone wants to use the pointer support e.g. %pa in
pinctrl-single.cand is restricted to use tiny printf, then it would be good to have the option to enable it manually and not be forced to enableSPL_NETorNET_LWIPto have the pointer support enabled. In this case, it makes sense to allow switching it on in menuconfig.
Quoted 7 lines
Quoted 2 lines
FWIW, I'm also fine with enabling full printf support as long as the tiny one doesn't print misleading values.
I'm not sure if the one non-debug %pa print in
pinctrl-single.cis really triggered within SPL, and I do hope that the way this patch is otherwise done will make it easier if someone needs %pa to work when debugging a problem in SPL, and can't enable full printf due to space.
Yes, but the dev_dbg() triggered it because of the same reason as above, DEBUG isn't defined if you do it on a per-file basis. Or I'm getting that logic wrong, as I don't understand why _DEBUG (commit c091f65234cf introduced it but doesn't tell the reason).
-michael
From: Michael Walle <[email protected]>
Sent: Thursday, April 10, 2025 12:44 PM
Quoted 108 lines · Tom Rini
Quoted 37 lines · Michael Walle
Quoted 36 lines
Hi,
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
The formatting with %pa / %pap behaves like %x, which results in an incorrect value being output. To improve this, a new fine-tuning
KconfigXPL_USE_TINY_PRINTF_POINTER_SUPPORTfor 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. ForSPL_NETandNET_LWIPit is selected by default. Then it also supports the formatting with %pm, %pM and %pI4.Signed-off-by Christoph Niedermaier <[email protected]>---
Cc: Tom Rini <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Michael Walle <[email protected]>
Cc: Quentin Schulz <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Benedikt Spranger <[email protected]>
Cc: Jerome Forissier <[email protected]>
Cc: John Ogness <[email protected]>
Cc: Ilias Apalodimas <[email protected]>--- Kconfig | 1 + common/spl/Kconfig | 1 + lib/Kconfig | 8 ++++++++ lib/tiny-printf.c | 45 +++++++++++++++++++-------------------------- 4 files changed, 29 insertions(+), 26 deletions(-)Kconfig +0
-0@@ -757,6 +757,7 @@ config NETQuoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Kconfig config NET
Quoted 3 lines
Kconfig +1
-0config NET_LWIP bool "Use lwIP for networking stack" + select XPL_USE_TINY_PRINTF_POINTER_SUPPORT if SPL_USE_TINY_PRINTF ||
TPL_USE_TINY_PRINTF||VPL_USE_TINY_PRINTFQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Kconfig +0
-0imply NETDEVICES help Include networking support based on the lwIP (lightweight IP)common/spl/Kconfig +0
-0Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
common/spl/Kconfig config SPL_DM_SPI_FLASH · line 1099
Quoted 8 lines
index
94e118f8465..72736dbecf5100644common/spl/Kconfig +1
-0@@ -1096,6 +1096,7 @@ config SPL_DM_SPI_FLASH config SPL_NET bool "Support networking" depends on !NET_LWIP + select XPL_USE_TINY_PRINTF_POINTER_SUPPORT if SPL_USE_TINY_PRINTF ||
TPL_USE_TINY_PRINTF||VPL_USE_TINY_PRINTFQuoted 29 lines
Quoted 29 lines
Quoted 28 lines
Quoted 11 lines
Quoted 11 lines
common/spl/Kconfig +0
-0help Enable support for network devices (such as Ethernet) in SPL. This permits SPL to load U-Boot over a network link rather thanlib/Kconfig +0
-0@@ -253,6 +253,14 @@ config VPL_USE_TINY_PRINTF The supported format specifiers are %c, %s, %u/%d and %x.Quoted 10 lines
lib/Kconfig config VPL_USE_TINY_PRINTF · line 262
Quoted 7 lines
lib/Kconfig +7
-0+config XPL_USE_TINY_PRINTF_POINTER_SUPPORT + bool "Extend tiny printf with the pointer formatting %p" + depends on SPL_USE_TINY_PRINTF || TPL_USE_TINY_PRINTF || VPL_USE_TINY_PRINTF + help + This option enables the formatting of pointers %p. It supports + %p and %pa / %pap. If this option is selected by SPL_NET or NET_LWIP + it also supports the formatting with %pm, %pM and %pI4.This isn't quite what I'd like to see. I don't want to start using the literal XPL namespace as that will lead to confusion down the line.
OK, in V2 I will only support SPL.
Quoted 4 lines
Since we only have
SPL_NET, I think we should name this symbolSPL_USE_TINY_PRINTF_POINTER_SUPPORT, not ask about it (so bool without "prompt text" following), and select fromSPL_NETifSPL_USE_TINY_PRINTF.Quoted 5 lines
Quoted 2 lines
IIRC, the old one also enabled the pointer support if DEBUG is enabled. I don't think this will work with
Kconfig.I was looking around for, but didn't quite see, a good existing option to "if .." around the prompt text for.
What I meant was that you normally do -DDEBUG on a file (or equally a #define DEBUG). Thus you cannot add it to
Kconfig.Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Now you will get the output '?' when using formatting with %p or %pa. If someone wants to use the pointer support e.g. %pa in
pinctrl-single.cand is restricted to use tiny printf, then it would be good to have the option to enable it manually and not be forced to enableSPL_NETorNET_LWIPto have the pointer support enabled. In this case, it makes sense to allow switching it on in menuconfig.Quoted 7 lines
Quoted 2 lines
FWIW, I'm also fine with enabling full printf support as long as the tiny one doesn't print misleading values.
I'm not sure if the one non-debug %pa print in
pinctrl-single.cis really triggered within SPL, and I do hope that the way this patch is otherwise done will make it easier if someone needs %pa to work when debugging a problem in SPL, and can't enable full printf due to space.
Quoted 4 lines
Yes, but the
dev_dbg()triggered it because of the same reason as above, DEBUG isn't defined if you do it on a per-file basis. Or I'm getting that logic wrong, as I don't understand why_DEBUG(commitc091f65234cfintroduced it but doesn't tell the reason).
Should I replace _DEBUG with defined(DEBUG) in the next version?
I also found something else:
[...]
@@ -307,6 +299,7 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
case '%':
out(info, '%');
default:
+ out(info, '?');
break;
}
[...]
If I add "out(info, '?');" in the default case for case '%' a break is missing. So for "%%" the output will be "%?".
Regards
Christoph
From: Christoph Niedermaier
Sent: Thursday, April 10, 2025 2:17 PM
Quoted 129 lines
From: Michael Walle <[email protected]>
Sent: Thursday, April 10, 2025 12:44 PMQuoted 64 lines · Tom Rini
Quoted 37 lines · Michael Walle
Quoted 36 lines
Hi,
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
The formatting with %pa / %pap behaves like %x, which results in an incorrect value being output. To improve this, a new fine-tuning
KconfigXPL_USE_TINY_PRINTF_POINTER_SUPPORTfor 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. ForSPL_NETandNET_LWIPit is selected by default. Then it also supports the formatting with %pm, %pM and %pI4.Signed-off-by Christoph Niedermaier <[email protected]>---
Cc: Tom Rini <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Michael Walle <[email protected]>
Cc: Quentin Schulz <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Benedikt Spranger <[email protected]>
Cc: Jerome Forissier <[email protected]>
Cc: John Ogness <[email protected]>
Cc: Ilias Apalodimas <[email protected]>--- Kconfig | 1 + common/spl/Kconfig | 1 + lib/Kconfig | 8 ++++++++ lib/tiny-printf.c | 45 +++++++++++++++++++-------------------------- 4 files changed, 29 insertions(+), 26 deletions(-)Kconfig +0
-0@@ -757,6 +757,7 @@ config NETQuoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Kconfig config NET · line 760
Quoted 3 lines
Kconfig +1
-0config NET_LWIP bool "Use lwIP for networking stack" + select XPL_USE_TINY_PRINTF_POINTER_SUPPORT if SPL_USE_TINY_PRINTF ||
TPL_USE_TINY_PRINTF||VPL_USE_TINY_PRINTFQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Kconfig +0
-0imply NETDEVICES help Include networking support based on the lwIP (lightweight IP)common/spl/Kconfig +0
-0Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
common/spl/Kconfig config SPL_DM_SPI_FLASH · line 1099
Quoted 8 lines
index
94e118f8465..72736dbecf5100644common/spl/Kconfig +1
-0@@ -1096,6 +1096,7 @@ config SPL_DM_SPI_FLASH config SPL_NET bool "Support networking" depends on !NET_LWIP + select XPL_USE_TINY_PRINTF_POINTER_SUPPORT if SPL_USE_TINY_PRINTF ||
TPL_USE_TINY_PRINTF||VPL_USE_TINY_PRINTFQuoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
common/spl/Kconfig +0
-0help Enable support for network devices (such as Ethernet) in SPL. This permits SPL to load U-Boot over a network link rather thanlib/Kconfig +0
-0@@ -253,6 +253,14 @@ config VPL_USE_TINY_PRINTFQuoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
lib/Kconfig config VPL_USE_TINY_PRINTF · line 258
Quoted 5 lines
lib/Kconfig +3
-0The supported format specifiers are %c, %s, %u/%d and %x. +config XPL_USE_TINY_PRINTF_POINTER_SUPPORT + bool "Extend tiny printf with the pointer formatting %p" + depends on SPL_USE_TINY_PRINTF || TPL_USE_TINY_PRINTF ||
VPL_USE_TINY_PRINTFQuoted 39 lines
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Quoted 7 lines
lib/Kconfig config VPL_USE_TINY_PRINTF · line 262
Quoted 4 lines
lib/Kconfig +4
-0+ help + This option enables the formatting of pointers %p. It supports + %p and %pa / %pap. If this option is selected by SPL_NET or NET_LWIP + it also supports the formatting with %pm, %pM and %pI4.This isn't quite what I'd like to see. I don't want to start using the literal XPL namespace as that will lead to confusion down the line.
OK, in V2 I will only support SPL.
Quoted 4 lines
Since we only have
SPL_NET, I think we should name this symbolSPL_USE_TINY_PRINTF_POINTER_SUPPORT, not ask about it (so bool without "prompt text" following), and select fromSPL_NETifSPL_USE_TINY_PRINTF.Quoted 5 lines
Quoted 2 lines
IIRC, the old one also enabled the pointer support if DEBUG is enabled. I don't think this will work with
Kconfig.I was looking around for, but didn't quite see, a good existing option to "if .." around the prompt text for.
What I meant was that you normally do -DDEBUG on a file (or equally a #define DEBUG). Thus you cannot add it to
Kconfig.Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Now you will get the output '?' when using formatting with %p or %pa. If someone wants to use the pointer support e.g. %pa in
pinctrl-single.cand is restricted to use tiny printf, then it would be good to have the option to enable it manually and not be forced to enableSPL_NETorNET_LWIPto have the pointer support enabled. In this case, it makes sense to allow switching it on in menuconfig.Quoted 7 lines
Quoted 2 lines
FWIW, I'm also fine with enabling full printf support as long as the tiny one doesn't print misleading values.
I'm not sure if the one non-debug %pa print in
pinctrl-single.cis really triggered within SPL, and I do hope that the way this patch is otherwise done will make it easier if someone needs %pa to work when debugging a problem in SPL, and can't enable full printf due to space.Quoted 4 lines
Yes, but the
dev_dbg()triggered it because of the same reason as above, DEBUG isn't defined if you do it on a per-file basis. Or I'm getting that logic wrong, as I don't understand why_DEBUG(commitc091f65234cfintroduced it but doesn't tell the reason).Should I replace
_DEBUGwith defined(DEBUG) in the next version?I also found something else:
[...](quoted diff) +1
-0@@ -307,6 +299,7 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va) case '%': out(info, '%'); default: + out(info, '?'); break; }
Quoted 2 lines
If I add "
out(info, '?');" in the default case for case '%' a break is missing. So for "%%" the output will be "%?".
I will send a version 2 as a new basis.
Regards
Christoph