[PATCH] The patch fixes the bug of partial intialization of

Michael Zaidman michael.zaidman at gmail.com
Tue Mar 31 13:21:35 CEST 2009


global network parameters.

Upon u-boot's start up the first ping command causes a failure of the
consequent TFTP transfers. It happens in the recently added mechanism of
NetLoop initialization where initialization of global network parameters is
separated in the NetInitLoop routine which is called per env_id change.
Thus, ping request will initialize the network parameters necessary for pin=
g
operation only, afterwards the env_changed_id will be set to the env_id
that will prevent all following initialization requests from other protocol=
s.
The problem is that the initialized by ping subset of network parameters is=
 not
sufficient for other protocols and particularly for TFTP
which requires the NetServerIp also.

Signed-off-by: Michael Zaidman <michael.zaidman at gmail.com>
---
 net/net.c |   66 +++++----------------------------------------------------=
---
 1 files changed, 6 insertions(+), 60 deletions(-)

diff --git a/net/net.c b/net/net.c
index a89f6a0..91ed0d7 100644
--- a/net/net.c
+++ b/net/net.c
@@ -288,64 +288,13 @@ NetInitLoop(proto_t protocol)
 	if (env_changed_id =3D=3D env_id)
 		return 0;

-	switch (protocol) {
-#if defined(CONFIG_CMD_NFS)
-	case NFS:
-#endif
-#if defined(CONFIG_CMD_PING)
-	case PING:
-#endif
-#if defined(CONFIG_CMD_SNTP)
-	case SNTP:
-#endif
-	case NETCONS:
-	case TFTP:
-		NetCopyIP(&NetOurIP, &bd->bi_ip_addr);
-		NetOurGatewayIP =3D getenv_IPaddr ("gatewayip");
-		NetOurSubnetMask=3D getenv_IPaddr ("netmask");
-		NetOurVLAN =3D getenv_VLAN("vlan");
-		NetOurNativeVLAN =3D getenv_VLAN("nvlan");
+	NetCopyIP(&NetOurIP, &bd->bi_ip_addr);
+	NetOurGatewayIP =3D getenv_IPaddr ("gatewayip");
+	NetOurSubnetMask=3D getenv_IPaddr ("netmask");
+	NetServerIP =3D getenv_IPaddr ("serverip");
+	NetOurNativeVLAN =3D getenv_VLAN("nvlan");
+	NetOurVLAN =3D getenv_VLAN("vlan");

-		switch (protocol) {
-#if defined(CONFIG_CMD_NFS)
-		case NFS:
-#endif
-		case NETCONS:
-		case TFTP:
-			NetServerIP =3D getenv_IPaddr ("serverip");
-			break;
-#if defined(CONFIG_CMD_PING)
-		case PING:
-			/* nothing */
-			break;
-#endif
-#if defined(CONFIG_CMD_SNTP)
-		case SNTP:
-			/* nothing */
-			break;
-#endif
-		default:
-			break;
-		}
-
-		break;
-	case BOOTP:
-	case RARP:
-		/*
-		 * initialize our IP addr to 0 in order to accept ANY
-		 * IP addr assigned to us by the BOOTP / RARP server
-		 */
-		NetOurIP =3D 0;
-		NetServerIP =3D getenv_IPaddr ("serverip");
-		NetOurVLAN =3D getenv_VLAN("vlan");	/* VLANs must be read */
-		NetOurNativeVLAN =3D getenv_VLAN("nvlan");
-	case CDP:
-		NetOurVLAN =3D getenv_VLAN("vlan");	/* VLANs must be read */
-		NetOurNativeVLAN =3D getenv_VLAN("nvlan");
-		break;
-	default:
-		break;
-	}
 	env_changed_id =3D env_id;
 	return 0;
 }
@@ -440,10 +389,7 @@ restart:

 #if defined(CONFIG_CMD_DHCP)
 		case DHCP:
-			/* Start with a clean slate... */
 			BootpTry =3D 0;
-			NetOurIP =3D 0;
-			NetServerIP =3D getenv_IPaddr ("serverip");
 			DhcpRequest();		/* Basically same as BOOTP */
 			break;
 #endif
--=20
1.5.6.3


More information about the U-Boot mailing list