[U-Boot] [PATCH v5 013/101] RFC: sandbox: net: Suppress the MAC-address warnings

Simon Glass sjg at chromium.org
Mon Nov 25 04:09:23 UTC 2019


These warnings appear every thing sandbox is run (see below) and dwarf the
actual useful output. Suppress them in two ways:

1. For the mismatch warnings, only set the eth<x>addr environment
variables when running tests.

2. For the 'MAC address from ROM' warning, never print this on sandbox.

Signed-off-by: Simon Glass <sjg at chromium.org>
---
Unfortunately this breaks the tests so is not applicable as is:

$ /tmp/b/sandbox/u-boot -T -c "ut dm eth_prime"

U-Boot 2019.10-00508-g95f6257285-dirty (Oct 13 2019 - 09:21:34 -0600)

Model: sandbox
DRAM:  128 MiB
WDT:   Started with servicing (60s timeout)
MMC:   mmc2: 2 (SD), mmc1: 1 (SD), mmc0: 0 (SD)
In:    serial
Out:   vidconsole
Err:   vidconsole
Model: sandbox
SCSI:
Net:
Error: eth at 10002000 address not set.
eth-1: eth at 10002000
Error: eth at 10003000 address not set.
, eth-1: eth at 10003000
Error: sbe5 address not set.
, eth-1: sbe5
Error: eth at 10004000 address not set.
, eth-1: eth at 10004000
Test: dm_test_eth_prime: eth.c
Test: dm_test_eth_prime: eth.c (flat tree)
Failures: 0

Old output:

U-Boot 2019.10-rc2

Model: sandbox
DRAM:  128 MiB

Warning: host_lo MAC addresses don't match:
Address in ROM is          a6:28:b7:47:28:93
Address in environment is  00:00:11:22:33:44

Warning: host_enp5s0 MAC addresses don't match:
Address in ROM is          a6:28:b7:47:28:93
Address in environment is  00:00:11:22:33:45

Warning: host_eth6 using MAC address from ROM

Warning: host_docker0 MAC addresses don't match:
Address in ROM is          a6:28:b7:47:28:93
Address in environment is  00:00:11:22:33:46

Warning: host_docker_gwbridge using MAC address from ROM

Warning: host_veth1118e68 MAC addresses don't match:
Address in ROM is          a6:28:b7:47:28:93
Address in environment is  00:00:11:22:33:47
WDT:   Not found!
MMC:
In:    cros-ec-keyb
Out:   vidconsole
Err:   vidconsole
Model: sandbox
SCSI:
Net:   eth0: host_lo, eth1: host_enp5s0, eth2: host_eth6, eth3: host_docker0, eth4: host_docker_gwbridge, eth5: host_veth1118e68
Error: eth at 10002000 address not set.
, eth-1: eth at 10002000
Test 'pmc_base' not found

Warning: host_lo MAC addresses don't match:
Address in ROM is          2a:24:9a:31:90:f8
Address in environment is  00:00:11:22:33:44

Warning: host_enp5s0 MAC addresses don't match:
Address in ROM is          ce:23:d9:74:6f:6c
Address in environment is  00:00:11:22:33:45

Warning: host_eth6 using MAC address from ROM

Warning: host_docker0 MAC addresses don't match:
Address in ROM is          ee:22:1c:3b:be:bc
Address in environment is  00:00:11:22:33:46

Warning: host_docker_gwbridge using MAC address from ROM

Warning: host_veth1118e68 MAC addresses don't match:
Address in ROM is          ae:20:9e:3d:a4:9f
Address in environment is  00:00:11:22:33:47

New output:
U-Boot 2019.10

Model: sandbox
DRAM:  128 MiB
WDT:   Not found!
MMC:
In:    cros-ec-keyb
Out:   vidconsole
Err:   vidconsole
Model: sandbox
SCSI:
Net:   eth0: host_lo, eth1: host_enp5s0, eth2: host_eth6, eth3: host_docker0, eth4: host_docker_gwbridge, eth5: host_vethc7e1b9e
Error: eth at 10002000 address not set.
, eth-1: eth at 10002000
Hit any key to stop autoboot:  0
=>


Changes in v5: None
Changes in v4: None
Changes in v3:
- Only supress the 'MAC address from ROM' warning on sandbox
- Set the environment variables at runtime to avoid other warnings

Changes in v2: None

 arch/sandbox/cpu/state.c         | 12 ++++++++++--
 arch/sandbox/include/asm/state.h |  5 ++++-
 cmd/nvedit.c                     |  8 ++++++++
 include/configs/sandbox.h        |  7 ++-----
 include/env.h                    | 12 ++++++++++++
 net/eth-uclass.c                 | 11 +++++++++--
 test/dm/test-main.c              |  2 +-
 7 files changed, 46 insertions(+), 11 deletions(-)

diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c
index dee5fde4f7..70b278e4e2 100644
--- a/arch/sandbox/cpu/state.c
+++ b/arch/sandbox/cpu/state.c
@@ -351,7 +351,7 @@ bool state_get_skip_delays(void)
 	return state->skip_delays;
 }
 
-void state_reset_for_test(struct sandbox_state *state)
+void state_reset_for_test(struct sandbox_state *state, bool eth_vars)
 {
 	/* No reset yet, so mark it as such. Always allow power reset */
 	state->last_sysreset = SYSRESET_COUNT;
@@ -367,6 +367,14 @@ void state_reset_for_test(struct sandbox_state *state)
 	 */
 	INIT_LIST_HEAD(&state->mapmem_head);
 	state->next_tag = state->ram_size;
+
+	if (eth_vars) {
+		/* set up some environment variables needed by the eth tests */
+		env_set_for_test("ethaddr", "00:00:11:22:33:44");
+		env_set_for_test("eth1addr", "00:00:11:22:33:45");
+		env_set_for_test("eth3addr", "00:00:11:22:33:46");
+		env_set_for_test("eth5addr", "00:00:11:22:33:47");
+	}
 }
 
 int state_init(void)
@@ -377,7 +385,7 @@ int state_init(void)
 	state->ram_buf = os_malloc(state->ram_size);
 	assert(state->ram_buf);
 
-	state_reset_for_test(state);
+	state_reset_for_test(state, false);
 	/*
 	 * Example of how to use GPIOs:
 	 *
diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h
index ad3e94beb9..4fa3b094a9 100644
--- a/arch/sandbox/include/asm/state.h
+++ b/arch/sandbox/include/asm/state.h
@@ -251,8 +251,11 @@ bool state_get_skip_delays(void);
  * state_reset_for_test() - Reset ready to re-run tests
  *
  * This clears out any test state ready for another test run.
+ *
+ * @param state		Sandbox state to update
+ * @param eth_vars	Set environment variables for eth tests
  */
-void state_reset_for_test(struct sandbox_state *state);
+void state_reset_for_test(struct sandbox_state *state, bool eth_vars);
 
 /**
  * state_show() - Show information about the sandbox state
diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 99a3bc57b1..6a01d755bb 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -299,6 +299,14 @@ static int _do_env_set(int flag, int argc, char * const argv[], int env_flag)
 	return 0;
 }
 
+int env_set_for_test(const char *varname, const char *value)
+{
+	const char * const argv[4] = { "setenv", varname, value, NULL };
+
+	assert(value);
+	return _do_env_set(0, 3, (char * const *)argv, 0);
+}
+
 int env_set(const char *varname, const char *varvalue)
 {
 	const char * const argv[4] = { "setenv", varname, varvalue, NULL };
diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index 1c13055cdc..0866cc3b63 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -96,11 +96,8 @@
 					"stderr=serial,vidconsole\0"
 #endif
 
-#define SANDBOX_ETH_SETTINGS		"ethaddr=00:00:11:22:33:44\0" \
-					"eth1addr=00:00:11:22:33:45\0" \
-					"eth3addr=00:00:11:22:33:46\0" \
-					"eth5addr=00:00:11:22:33:47\0" \
-					"ipaddr=1.2.3.4\0"
+/* Note that some ethernet variables are set in state_reset_for_test() */
+#define SANDBOX_ETH_SETTINGS		"ipaddr=1.2.3.4\0"
 
 #define MEM_LAYOUT_ENV_SETTINGS \
 	"bootm_size=0x10000000\0" \
diff --git a/include/env.h b/include/env.h
index b72239f6a5..bc48a72cde 100644
--- a/include/env.h
+++ b/include/env.h
@@ -145,6 +145,18 @@ int env_get_yesno(const char *var);
  */
 int env_set(const char *varname, const char *value);
 
+/**
+ * env_set_for_test() - Set the value of a variable for testing
+ *
+ * This works as if the variable value was defined in the built-in environment,
+ * so uses a flags value of 0. This should only be used in tests.
+ *
+ * @varname: Variable to adjust
+ * @value: Value to set for the variable (cannot be NULL)
+ * @return 0 if OK, 1 on error
+ */
+int env_set_for_test(const char *varname, const char *value);
+
 /**
  * env_get_ulong() - Return an environment variable as an integer value
  *
diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index 3bd98b01ad..6c19536138 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -485,6 +485,12 @@ static int eth_post_probe(struct udevice *dev)
 	struct eth_device_priv *priv = dev->uclass_priv;
 	struct eth_pdata *pdata = dev->platdata;
 	unsigned char env_enetaddr[ARP_HLEN];
+	/*
+	 * These warnings always appear on sandbox and are not useful. They have
+	 * been here for some time and the issue has not been resolved. So for
+	 * now, disable them.
+	 */
+	bool show_warnings = !IS_ENABLED(CONFIG_SANDBOX);
 
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
 	struct eth_ops *ops = eth_get_ops(dev);
@@ -538,8 +544,9 @@ static int eth_post_probe(struct udevice *dev)
 		memcpy(pdata->enetaddr, env_enetaddr, ARP_HLEN);
 	} else if (is_valid_ethaddr(pdata->enetaddr)) {
 		eth_env_set_enetaddr_by_index("eth", dev->seq, pdata->enetaddr);
-		printf("\nWarning: %s using MAC address from ROM\n",
-		       dev->name);
+		if (show_warnings)
+			printf("\nWarning: %s using MAC address from ROM\n",
+			       dev->name);
 	} else if (is_zero_ethaddr(pdata->enetaddr) ||
 		   !is_valid_ethaddr(pdata->enetaddr)) {
 #ifdef CONFIG_NET_RANDOM_ETHADDR
diff --git a/test/dm/test-main.c b/test/dm/test-main.c
index 72648162a9..14a520944e 100644
--- a/test/dm/test-main.c
+++ b/test/dm/test-main.c
@@ -28,7 +28,7 @@ static int dm_test_init(struct unit_test_state *uts, bool of_live)
 	memset(dms, '\0', sizeof(*dms));
 	gd->dm_root = NULL;
 	memset(dm_testdrv_op_count, '\0', sizeof(dm_testdrv_op_count));
-	state_reset_for_test(state_get_current());
+	state_reset_for_test(state_get_current(), true);
 
 #ifdef CONFIG_OF_LIVE
 	/* Determine whether to make the live tree available */
-- 
2.24.0.432.g9d3f5f5b63-goog



More information about the U-Boot mailing list