* [U-Boot] [PATCH] Fix enetaddr initialization with CONFIG_NET_MULTI
@ 2009-07-28 15:44 Albin Tonnerre
2009-08-13 5:01 ` Mike Frysinger
0 siblings, 1 reply; 3+ messages in thread
From: Albin Tonnerre @ 2009-07-28 15:44 UTC (permalink / raw)
To: u-boot
When CONFIG_NET_MULTI is defined, the NetLoop code looks in
eth_get_device()->enetaddr for the MAC address. However, this value may
not be set. In fact, it will not be if ethaddr was not present in the
environment when uboot was started. Therefore, even with 'setenv ethaddr
xx:xx:xx:xx:xx:xx', eg. tftp will error out because it doesn't find the
MAC address.
This patch tries to fix this by checking the ethaddr for the current
ethernet device in the environment and setting the enetaddr field
accordingly when NetLoop is called.
As I don't have a good knowledge of how the whole net subsystem works in
u-boot, I'm not sure this is the right way to do it, and would
appreciate guidance on the matter.
Signed-off-by: Albin Tonnerre <albin.tonnerre@free-electrons.com>
---
net/net.c | 23 +++++++++++++++++------
1 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/net/net.c b/net/net.c
index 5637cf5..99666e9 100644
--- a/net/net.c
+++ b/net/net.c
@@ -341,19 +341,30 @@ NetLoop(proto_t protocol)
eth_halt();
#ifdef CONFIG_NET_MULTI
eth_set_current();
+
+ if (memcmp (eth_get_dev()->enetaddr, "\0\0\0\0\0\0", 6) == 0) {
+ int eth_cur_index;
+ char eth_cur_name[8];
+
+ eth_cur_index = eth_get_dev_index();
+ if (eth_cur_index)
+ sprintf(eth_cur_name, "eth%iaddr", eth_cur_index);
+ else
+ strcpy(eth_cur_name, "ethaddr");
+
+ eth_getenv_enetaddr(eth_cur_name, NetOurEther);
+ }
+#else
+ eth_getenv_enetaddr("ethaddr", NetOurEther);
#endif
+ memcpy(eth_get_dev()->enetaddr, NetOurEther, 6);
+
if (eth_init(bd) < 0) {
eth_halt();
return(-1);
}
restart:
-#ifdef CONFIG_NET_MULTI
- memcpy (NetOurEther, eth_get_dev()->enetaddr, 6);
-#else
- eth_getenv_enetaddr("ethaddr", NetOurEther);
-#endif
-
NetState = NETLOOP_CONTINUE;
/*
--
1.6.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] Fix enetaddr initialization with CONFIG_NET_MULTI
2009-07-28 15:44 [U-Boot] [PATCH] Fix enetaddr initialization with CONFIG_NET_MULTI Albin Tonnerre
@ 2009-08-13 5:01 ` Mike Frysinger
2009-08-13 7:41 ` Albin Tonnerre
0 siblings, 1 reply; 3+ messages in thread
From: Mike Frysinger @ 2009-08-13 5:01 UTC (permalink / raw)
To: u-boot
On Tuesday 28 July 2009 11:44:27 Albin Tonnerre wrote:
> When CONFIG_NET_MULTI is defined, the NetLoop code looks in
> eth_get_device()->enetaddr for the MAC address. However, this value may
> not be set. In fact, it will not be if ethaddr was not present in the
> environment when uboot was started. Therefore, even with 'setenv ethaddr
> xx:xx:xx:xx:xx:xx', eg. tftp will error out because it doesn't find the
> MAC address.
please grab the latest git tree and try again. this should be fixed by commit
86848a74c3c8...
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090813/f6b5cc77/attachment.pgp
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] Fix enetaddr initialization with CONFIG_NET_MULTI
2009-08-13 5:01 ` Mike Frysinger
@ 2009-08-13 7:41 ` Albin Tonnerre
0 siblings, 0 replies; 3+ messages in thread
From: Albin Tonnerre @ 2009-08-13 7:41 UTC (permalink / raw)
To: u-boot
On Thu, Aug 13, 2009 at 01:01:16AM -0400, Mike Frysinger wrote :
> On Tuesday 28 July 2009 11:44:27 Albin Tonnerre wrote:
> > When CONFIG_NET_MULTI is defined, the NetLoop code looks in
> > eth_get_device()->enetaddr for the MAC address. However, this value may
> > not be set. In fact, it will not be if ethaddr was not present in the
> > environment when uboot was started. Therefore, even with 'setenv ethaddr
> > xx:xx:xx:xx:xx:xx', eg. tftp will error out because it doesn't find the
> > MAC address.
>
> please grab the latest git tree and try again. this should be fixed by commit
> 86848a74c3c8...
> -mike
Indeed ... I noticed there was already a patch for this a couple days after
sending mine, sorry for that.
Regards,
--
Albin Tonnerre, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: Digital signature
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090813/2625ab13/attachment.pgp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-08-13 7:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-28 15:44 [U-Boot] [PATCH] Fix enetaddr initialization with CONFIG_NET_MULTI Albin Tonnerre
2009-08-13 5:01 ` Mike Frysinger
2009-08-13 7:41 ` Albin Tonnerre
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox