Skip to contentSkip to conversation

tiny-printf: Handle %pM format when CONFIG_SPL_NET_SUPPORT is enabled

PATCH Superseded Matwey V. Kornilov 3 participants 5 messages Aug 5, 2021 – Aug 22, 2021 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tiny-printf: Handle %pM format when CONFIG_SPL_NET_SUPPORT is enabled

%pM format string is used to print MAC-address and this is required while SPL network boot.

This patch fixes the SPL boot issues like the following:

Trying to boot from USB eth
## Error: flags type check failure for "ethaddr" <= "40309614M" (type: m) ## Error inserting "ethaddr" variable, errno=1
eth0: eth_cpsw## Error: flags type check failure for "eth1addr" <= "81f01114M" (type: m)
## Error inserting "eth1addr" variable, errno=1
, eth1: usb_ether
eth_cpsw Waiting for PHY auto negotiation to complete......... TIMEOUT ! Problem booting with BOOTP
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

---
 lib/tiny-printf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/tiny-printf.c +1 -1
index 8fc7e48d99..0b2fabf118 100644
@@ -269,7 +269,7 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
 				}
 				break;
 			case 'p':
-#ifdef DEBUG
+#if IS_ENABLED(CONFIG_SPL_NET_SUPPORT) || defined(DEBUG)
 				pointer(info, fmt, va_arg(va, void *));
 				/*
 				 * Skip this because it pulls in _ctype which is
Signature · 1 line
2.31.1
Reviewed-by on v1 1/1
#1 lore raw

Hi Matwey,

Quoted 37 lines · Matwey V. Kornilov

%pM format string is used to print MAC-address and this is required while SPL network boot.

This patch fixes the SPL boot issues like the following:

Trying to boot from USB eth
## Error: flags type check failure for "ethaddr" <= "40309614M" (type: m) ## Error inserting "ethaddr" variable, errno=1
eth0: eth_cpsw## Error: flags type check failure for "eth1addr" <= "81f01114M" (type: m)
## Error inserting "eth1addr" variable, errno=1
, eth1: usb_ether
eth_cpsw Waiting for PHY auto negotiation to complete......... TIMEOUT ! Problem booting with BOOTP
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

---
 lib/tiny-printf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/tiny-printf.c +1 -2
index 8fc7e48d99..0b2fabf118 100644
@@ -269,7 +269,7 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
                                }
                                break;
                        case 'p':
-#ifdef DEBUG
+#if IS_ENABLED(CONFIG_SPL_NET_SUPPORT) || defined(DEBUG)
                                pointer(info, fmt, va_arg(va, void *));
                                /*
                                 * Skip this because it pulls in _ctype which is
--
Quoted 2 lines

2.31.1

But can you try something like:

case 'p':
if (CONFIG_IS_ENABLED(NET_SUPPORT) || _DEBUG) {
...
}

instead? Will need to include log-h though. We try to avoid the preprocessor.

Regards,
Simon

#2 lore raw

PATCH v2 1/1 tiny-printf: Handle %pM format when CONFIG_SPL_NET_SUPPORT is enabled

%pM format string is used to print MAC-address and this is required while SPL network boot.

This patch fixes the SPL boot issues like the following:

Trying to boot from USB eth
## Error: flags type check failure for "ethaddr" <= "40309614M" (type: m) ## Error inserting "ethaddr" variable, errno=1
eth0: eth_cpsw## Error: flags type check failure for "eth1addr" <= "81f01114M" (type: m)
## Error inserting "eth1addr" variable, errno=1
, eth1: usb_ether
eth_cpsw Waiting for PHY auto negotiation to complete......... TIMEOUT ! Problem booting with BOOTP
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

---
Changes since v1:
- avoid the preprocessor as suggested by Simon Glass

 lib/tiny-printf.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
lib/tiny-printf.c +13 -13
index 8fc7e48d99..89aaa85477 100644
@@ -9,8 +9,9 @@
  */
 
 #include <common.h>
-#include <stdarg.h>
+#include <log.h>
 #include <serial.h>
+#include <stdarg.h>
 #include <linux/ctype.h>
 
 struct printf_info {
@@ -269,20 +270,19 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
 				}
 				break;
 			case 'p':
-#ifdef DEBUG
-				pointer(info, fmt, va_arg(va, void *));
-				/*
-				 * Skip this because it pulls in _ctype which is
-				 * 256 bytes, and we don't generally implement
-				 * pointer anyway
-				 */
-				while (isalnum(fmt[0]))
-					fmt++;
-				break;
-#else
+				if (CONFIG_IS_ENABLED(NET_SUPPORT) || _DEBUG) {
+					pointer(info, fmt, va_arg(va, void *));
+					/*
+					 * Skip this because it pulls in _ctype which is
+					 * 256 bytes, and we don't generally implement
+					 * pointer anyway
+					 */
+					while (isalnum(fmt[0]))
+						fmt++;
+					break;
+				}
 				islong = true;
 				/* no break */
-#endif
 			case 'x':
 				if (islong) {
 					num = va_arg(va, unsigned long);
Signature · 1 line
2.31.1
Reviewed-by on v2 1/1
#3 lore raw
Quoted 18 lines · Matwey V. Kornilov

%pM format string is used to print MAC-address and this is required while SPL network boot.

This patch fixes the SPL boot issues like the following:

Trying to boot from USB eth
## Error: flags type check failure for "ethaddr" <= "40309614M" (type: m) ## Error inserting "ethaddr" variable, errno=1
eth0: eth_cpsw## Error: flags type check failure for "eth1addr" <= "81f01114M" (type: m)
## Error inserting "eth1addr" variable, errno=1
, eth1: usb_ether
eth_cpsw Waiting for PHY auto negotiation to complete......... TIMEOUT ! Problem booting with BOOTP
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

Quoted 7 lines

---
Changes since v1:
- avoid the preprocessor as suggested by Simon Glass

 lib/tiny-printf.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
#4 lore raw
In reply to Matwey V. Kornilov
Quoted 17 lines · Matwey V. Kornilov

%pM format string is used to print MAC-address and this is required while SPL network boot.

This patch fixes the SPL boot issues like the following:

Trying to boot from USB eth
## Error: flags type check failure for "ethaddr" <= "40309614M" (type: m) ## Error inserting "ethaddr" variable, errno=1
eth0: eth_cpsw## Error: flags type check failure for "eth1addr" <= "81f01114M" (type: m)
## Error inserting "eth1addr" variable, errno=1
, eth1: usb_ether
eth_cpsw Waiting for PHY auto negotiation to complete......... TIMEOUT ! Problem booting with BOOTP
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

Quoted 2 lines

Applied to u-boot/master, thanks!

Signature · 1 line
Tom