Wiznet MAC Address

I think I know the answer, but I guess I am somewhat surprised. Question is, is there a way to programmatically determine the MAC address of this device. Mine is recent enough to have a sticker, so it's easy enough to type that address into the code for my prototype, but this doesn't seem a viable solution for a real product. Searches for "mac address" here mostly reveal all the copies of the sample code with the "humorous" DEAD BEEF FEED address. Ha ha. My searches have come up with one interesting thread here:

http://arduino.cc/forum/index.php/topic,19742.0.html

And a note in the W5100 Datasheet (http://www.sparkfun.com/datasheets/DevTools/Arduino/W5100_Datasheet_v1_1_6.pdf) that says, "The Source Hardware Address Register (SHAR) is the H/W address to be used in MAC layer, and can be used with the address that manufacturer has been assigned. The MAC address can be assigned from IEEE. For more detail, refer to IEEE homepage."

Not too helpful. I was hoping to find some function for extracting the "real" address, but in the forum postings linked above, it was suggested that a hardware mac address may be more of a "board" concept, and what we're buying is more like a chip. Well, the chip does come on a board, and it would be a nice value add.

Assuming the answer is, "No, there is no function to return you the 'real' hardware address" has anyone solved the problem in a real way for a real product? Certainly, one answer is to use an LAA, but do you just randomly assign the other 62 bits? Does anyone have real experience with this?

Thanks for any wisdom!

Question is, is there a way to programmatically determine the MAC address of this device.

If your device can connect to a router, then looking at the router's connected devices may show the device's mac address.

By "programmatically" I meant within an Arduino sketch. To do what you're suggesting, my Arduino based device would have to already make its presence known to the router, and in order to do so, I'd have to initialize the Ethernet shield, and in order to do so, I'd have to tell it what ethernet address to use! Catch-22 :slight_smile:

There ought to be a low-level function to retrieve the information from the hardware, but my research suggests there isn't because it simply isn't in the hardware. It may be on the hardware in the form of a sticker, but it isn't in there to be queried. But I'm hoping someone will prove me wrong!

I don't have a new enough wiznet to have a sticker, but what happens if you try this: in ethernet.cpp, comment out this line in EthernetClass::Begin():

W5100.setMACAddress(mac);

Also, what happens if you specify a MAC different from the one on the sticker.

It seems to me you're asking the wrong question. You don't need to read the MAC from the board, you just want to tell the wiznet to use it. If it works to comment out the line that sets it, a minor code revision would be to check if the MAC is null in EthernetClass::Begin() and not call setMACAddress() if it is.

Interesting thoughts!

Testing with another MAC address works fine.

Removing the line in Ethernet.cpp to setup the MAC address appears to leave it at its previous setting. Even after removing power, my router shows the DHCP request from whatever MAC address I last asserted.

So it might be interesting to do the test on a brand new board, which I don't have. Seems to me there are three reasonably likely outcomes. The address might show up on the network as all FF's, all 00's, or "the correct" address. The first two wouldn't likely work well on an actual network, but if someone wanted to test it out, I'd be anxious to learn.

And another thread here, FWIW: GAAAAAHGHHAAARRR!! What is the correct format for the mac address? - Networking, Protocols, and Devices - Arduino Forum

Yes indeed! That was one of the most informative threads I came across in my searching.

So the sticker is just a suggestion of a valid MAC address to use? That's lame.

So the sticker is just a suggestion of a valid MAC address to use? That's lame.

Maybe not. Could be there so people unfamiliar with a mac address will know what one looks like. It may be initially embedded in the chip to get people started. Mac addresses are only of interest to applications that use them.

My guess is that the printed MAC address is in fact a reserved address, but AFAIK there's nothing in the hardware that favors it. But I'd be happy to be proven wrong!