Known Bug: EtherTen and Ardunio 1.0 DHCP

The EtherTen combines an Uno-equivalent Arduino-compatible board and Wiznet-based Ethernet support, along with a microSD card slot and Power-over-Ethernet support. [Product page]
User avatar
jonoxer
Freetronics Staff
Freetronics Staff
Posts:298
Joined:Sat Oct 15, 2011 11:31 am
Location:Melbourne, Australia
Contact:
Re: Known Bug: EtherTen and Ardunio 1.0 DHCP

Post by jonoxer » Thu May 10, 2012 1:48 am

Yes, that sounds logical. I haven't gone as far as storing the address in EEPROM (the code just looks for it on every boot) but that's feasible.

Just in case this saves anyone else some time, a curly problem I found last weekend is that sometimes the 1-wire address sets bits that cause problems if it's used as an Ethernet MAC address. I got around the problem by hard-coding the first 3 bytes of the Ethernet MAC and just using the tail of the 1-wire address to populate the rest. I'll provide more detail when I write it up.
--
Jon

User avatar
Simon
Posts:25
Joined:Wed May 02, 2012 2:40 am

Re: Known Bug: EtherTen and Ardunio 1.0 DHCP

Post by Simon » Thu May 10, 2012 1:53 am

Why bother writing the address to EEPROM at all? Is there some hidden cost/complexity with looking it up "dynamically" at each boot?

User avatar
jonoxer
Freetronics Staff
Freetronics Staff
Posts:298
Joined:Sat Oct 15, 2011 11:31 am
Location:Melbourne, Australia
Contact:

Re: Known Bug: EtherTen and Ardunio 1.0 DHCP

Post by jonoxer » Thu May 10, 2012 2:00 am

I assume as a fall-back in case the DS18B20 can't be contacted, but I don't really see a huge benefit either. What I do is hard-code a default MAC in the sketch and use that as a fall-back, but of course if more than 1 device on the network does that it'll result in MAC collisions anyway. My inclination is that if the DS18B20 can't be contacted, the device should fail to come up on the network at all. Less potential for collateral damage then.
--
Jon

hads
Posts:10
Joined:Tue May 01, 2012 3:58 am

Re: Known Bug: EtherTen and Ardunio 1.0 DHCP

Post by hads » Thu May 10, 2012 2:13 am

Doesn't use a DS18B20 but I blogged something similar the other day too;

https://nicegear.co.nz/blog/autogenerat ... -ethernet/

User avatar
jonoxer
Freetronics Staff
Freetronics Staff
Posts:298
Joined:Sat Oct 15, 2011 11:31 am
Location:Melbourne, Australia
Contact:

Re: Known Bug: EtherTen and Ardunio 1.0 DHCP

Post by jonoxer » Thu May 10, 2012 2:24 am

Hey Hads, that's a nice solution too! I notice that in your code you only populate the last 3 bytes dynamically, same as I'm doing now. I assume that's for the same reason, to keep the values within an acceptable range and prevent problems with smart switches that discard packets from invalid MACs.
--
Jon

bcdaus
Posts:3
Joined:Thu May 10, 2012 12:43 am

Re: Known Bug: EtherTen and Ardunio 1.0 DHCP

Post by bcdaus » Thu May 10, 2012 2:57 am

Actually you are right about reading it from eeprom vs. reading from the actual device.
My original idea was to have it as part of a command line option to set the MAC thus the storage in EEPROM idea. I guess I didn't think it through that the DS1820 will always be attached !

I found some similar code at http://nicegear.co.nz/blog/autogenerate ... -ethernet/ and http://nicegear.co.nz/blog/auto-generat ... -ethernet/ but I see the author has already added to the post.

I'd be inclined to use the DS1820 to only set the last 3 octets with the first 3 hard coded. I wonder what the possibility of getting 2 units with the same 6 digits in the first 24 bits of the serial number is.

Bill.

hads
Posts:10
Joined:Tue May 01, 2012 3:58 am

Re: Known Bug: EtherTen and Ardunio 1.0 DHCP

Post by hads » Thu May 10, 2012 3:19 am

jonoxer wrote:I notice that in your code you only populate the last 3 bytes dynamically, same as I'm doing now. I assume that's for the same reason, to keep the values within an acceptable range and prevent problems with smart switches that discard packets from invalid MACs.
Yes exactly, I've discovered over the last little while of deploying devices that this does happen in the real world.

Sleurhutje
Posts:28
Joined:Thu Mar 01, 2012 9:18 am

Re: Known Bug: EtherTen and Ardunio 1.0 DHCP

Post by Sleurhutje » Thu May 10, 2012 2:08 pm

As written in this thread, problems occur when the DNS contains non-printable characters. I've tested some more by modifying the library so the last three characters of the DNS name aren't the CHAR values of the last three bytes of the MAC address but normal readable characters (a-z, A-Z, 0-9). All works fine after modifications.

Looks like DHCP can't register the host name correctly when it contains illegal characters. Or results in problems when refreshing the DHCP address.

User avatar
jonoxer
Freetronics Staff
Freetronics Staff
Posts:298
Joined:Sat Oct 15, 2011 11:31 am
Location:Melbourne, Australia
Contact:

Re: Known Bug: EtherTen and Ardunio 1.0 DHCP

Post by jonoxer » Fri May 11, 2012 1:43 am

That's very valuable information @Sleurhutje, thanks!
--
Jon

bcdaus
Posts:3
Joined:Thu May 10, 2012 12:43 am

Re: Known Bug: EtherTen and Ardunio 1.0 DHCP

Post by bcdaus » Sun May 20, 2012 3:43 am

I was doing some digging into this recently as I saw this issue discussed. Looks like its been patched and it is certainly the code in the 1.0.1-rc2 release :
http://code.google.com/p/arduino/issues/detail?id=742

I had a look at the code for the DHCP.cpp in Arduino-1.0 and it still uses the old way of doing it - thus you can get scrambled MAC addresses that some routers may choke on.

bill.

Post Reply