Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

MAC Address getting reset to all 00's - Anyone else seen this?


  • Please log in to reply
16 replies to this topic

#1 Valkyrie-MT

Valkyrie-MT

    Advanced Member

  • Members
  • PipPipPip
  • 315 posts
  • LocationIndiana, USA

Posted 01 November 2011 - 02:04 PM

I have now had several instances where my networking on the NetduinoPlus seems to start behaving strangely and when I open up MF Deploy, the MAC address is reset to all 00's and the DNS servers I had setup are changed. I am currently using a 4.2 RTM based firmware... but I have been seeing this from time to time for a while now. I am aware that these values are reset when flashing the ER_CONFIG, but I am fairly sure it is happening spontaneously (or at least triggered by something else). Related link: http://forums.netdui...ndpost__p__5317 -Valkyrie-MT

#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 01 November 2011 - 05:25 PM

Hi Valkyrie,

I have now had several instances where my networking on the NetduinoPlus seems to start behaving strangely and when I open up MF Deploy, the MAC address is reset to all 00's and the DNS servers I had setup are changed. I am currently using a 4.2 RTM based firmware... but I have been seeing this from time to time for a while now.

I am aware that these values are reset when flashing the ER_CONFIG, but I am fairly sure it is happening spontaneously (or at least triggered by something else).


Could you please verify that this is indeed happening spontaneously (i.e. without intentionally editing the config sector) by reading it from code (and not from MFDeploy) when it misbehaves?

The config sector should only be read--never written to--unless you specifically do so with your code. [Changing from DHCP to static IP or vice-versa or setting your IP address may trigger a write.]

Chris

#3 Valkyrie-MT

Valkyrie-MT

    Advanced Member

  • Members
  • PipPipPip
  • 315 posts
  • LocationIndiana, USA

Posted 02 November 2011 - 01:16 AM

Could you please verify that this is indeed happening spontaneously (i.e. without intentionally editing the config sector) by reading it from code (and not from MFDeploy) when it misbehaves?

The config sector should only be read--never written to--unless you specifically do so with your code. [Changing from DHCP to static IP or vice-versa or setting your IP address may trigger a write.]


Great advice Chris. I was just about to integrate a MAC address checker in the code so I would know immediately when it had happened and try to determine what I was doing to trigger it.

I am using DHCP and (perhaps redundantly) call the EnableDHCP() method in my initialization code, but I am never changing from or to static. I always use DHCP.

I'll keep an eye on it.

-Valkyrie-MT

#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 02 November 2011 - 02:06 AM

HI Valkyrie,

I am using DHCP and (perhaps redundantly) call the EnableDHCP() method in my initialization code, but I am never changing from or to static. I always use DHCP.

I'd recommend checking to see whether your Netduino Plus is using DHCP or static IP during startup...and only enabling DHCP if it's not using IP. The config sector doesn't have a backup so if it's being rewritten when the device is unplugged you could lose the data in that sector. Also, flash does have an upper limit to rewrite cycle (10,000's or 100,000 cycles)...so you could in theory wear out the erase/rewrite cycles by looping through that code enough times.

Chris

#5 Valkyrie-MT

Valkyrie-MT

    Advanced Member

  • Members
  • PipPipPip
  • 315 posts
  • LocationIndiana, USA

Posted 03 November 2011 - 01:22 AM

Ok, it happened again, and I definitely have not just flashed the firmware. Also, I removed the EnableDHCP call from my code yesterday. It had been running great for about a day. Every startup it would output the MAC address. Then, I restarted a debug session in VisualStudio, the MAC address was good (I think), but the NTP calls started throwing an exception, so I started up Wire Shark and there was nothing going over the wire. Every attempt to send a message with the socket was throwing an exception. So, I pressed the reset button on the Netduino and when it started running again, I saw this: "MAC Address: 000000000001"

All I did was press the reset button while my app had been running. I did not pull the USB cable or anything else.

So, I entered MFDeploy and saw that DHCP had been disabled and the MAC address was reset to 000000000001.

Posted Image

I think that the MAC address and DHCP were actually hosed before I pressed the reset button and that's why the NTP was failing. So, I don't think it was caused by pushing the reset button on Netduino.

After setting the MAC and DHCP again everything worked again. I pressed the reset button again, but this time it restarted perfectly.

-Valkyrie-MT

#6 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 03 November 2011 - 05:03 AM

Hi Valkyrie, The story gets even more interesting. When you get the bad MAC address, does turning off and then re-powering the unit do anything for you? If it's working and you cycle power on the Netduino Plus does that fix/break anything? Also...do you have another Netduino Plus? I wonder if the config sector is worn out (rare but possible). Although the inconsistency of the issue here leads me to lean towards the possibility an lwIP network stack bug. Chris

#7 Valkyrie-MT

Valkyrie-MT

    Advanced Member

  • Members
  • PipPipPip
  • 315 posts
  • LocationIndiana, USA

Posted 03 November 2011 - 05:19 PM

The story gets even more interesting. When you get the bad MAC address, does turning off and then re-powering the unit do anything for you? If it's working and you cycle power on the Netduino Plus does that fix/break anything?

Also...do you have another Netduino Plus? I wonder if the config sector is worn out (rare but possible). Although the inconsistency of the issue here leads me to lean towards the possibility an lwIP network stack bug.


Ha, I have many Netduino Pluses actually. I haven't seen this follow any particular one, but I'll switch to another to see what happens.

If I power cycle, nothing changes. Once the MAC is set to 000000000001, it stays that way on all subsequent boots... until I set it back with MFDeploy. It's too bad the field is read-only on the N+ because I could store the correct MAC in the SD card and restore it and reboot automatically when N+ boots with a MAC starting with "000000". I would love to see a future version of the firmware enable the setter on the MAC. It's likely to be a simple change and could have other interesting uses to others... Until then, I might create a timer to check the MAC every minute to try and catch when it changes...

-Valkyrie-MT

#8 Valkyrie-MT

Valkyrie-MT

    Advanced Member

  • Members
  • PipPipPip
  • 315 posts
  • LocationIndiana, USA

Posted 04 November 2011 - 12:52 AM

I would love to see a future version of the firmware enable the setter on the MAC.


Wow, I just looked at the firmware source and realized there IS a setter for MAC address. So I just tried it and it totally works. I don't know why I though that you couldn't set the MAC address. I suppose, I will add some code to detect when it is set to 000000000001 and restore the MAC address automatically. Hopefully, in the next few days, I'll see it happen again...

I'll use something like this to start:

var ni = NetworkInterface.GetAllNetworkInterfaces()[0];

if (ni.PhysicalAddress[0] == 0x00)
{
     Debug.Print("Restoring Physical Address...");
     ni.PhysicalAddress = new byte[] { 0x5C, 0x86, 0x4A, 0x99, 0x99, 0x99 };
     Debug.Print("MAC Address: " + ni.PhysicalAddress.ToHexString());
}

-Valkyrie-MT

#9 Valkyrie-MT

Valkyrie-MT

    Advanced Member

  • Members
  • PipPipPip
  • 315 posts
  • LocationIndiana, USA

Posted 04 November 2011 - 03:33 AM

Making more progress! I just had it spontaneously change to 0000000001 again. I still don't see what the trigger might be, but this time it partially recovered! It detected the bogus MAC address and changed it back successfully, but, DHCP had been disabled as well, so it couldn't get an IP address. When the MAC address spontaneously changes, it also seems to set the IP to 192.168.5.100 and Static. Here is my log output of the event:

MAC Address: 000000000001
********** Restoring Physical Address... +=+=+=+=
MAC Address: 5C864A009999
DNS server 1 is: 192.168.5.1
Network initialized!  IP address is 192.168.5.100
Gateway Address is: 192.168.5.1
DNS server 1 is: 192.168.5.1
Subnet: 255.255.255.0
DHCP is enabled? False
DynamicDNS is enabled? False
MAC Address: 5C864A009999
Setting Date and Time from Network
Time Server: nist1-chi.ustiming.org
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in Microsoft.SPOT.Net.dll
Exception was thrown: System.Net.Sockets.SocketExceptionMicrosoft.SPOT.Net.SocketNative::getaddrinfo
System.Net.Dns::GetHostEntry
Extension::SetFromNetwork
Extension::SetFromNetwork
NetduinoPlusWebServer.Program::SyncTime
NetduinoPlusWebServer.Program::Main

Notice how it failed on "Dns::GetHostEntry" which is probably only because the DNS server is set wrong! I also pulled up Wireshark when this happened, and sure enough it was using the restored MAC address (Notice "SecretLa_00:99:99" below) and was ARPing with the bogus static IP address. So, now, I'm adding back the EnableDHCP command before the MAC Address restore and perhaps next time this happens it will automatically fix itself! :unsure:

WireShark:
542	87.474419	SecretLa_00:99:99	Broadcast	ARP	60	Who has 192.168.5.1?  Tell 192.168.5.100

Note: MAC addresses altered to protect the innocent. :)

-Valkyrie-MT

#10 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 04 November 2011 - 03:37 AM

Note: MAC addresses altered to protect the innocent. :)

Well, protecting everyone except the person with that MAC address ;)

It seems like your config sector is getting wiped out or the entwork stack is not reading in the config sector properly. I have an idea to determine which one it is.

Can you try setting the "USB Name" of your device? So instead of NetduinoPlus, name it something else. Then when the configuration changes...see if the name has reverted to "NetduinoPlus".

My guess is that it's a software glitch in the .NET MF lwIP integration which is acting up in your particular situation...although the fact that depower/repower doesn't fix it pushes me towards thinking it's a config sector issue. [Also, if having written to the config sector 10,000's of times...it might have gotten worn out.]

Chris

#11 Valkyrie-MT

Valkyrie-MT

    Advanced Member

  • Members
  • PipPipPip
  • 315 posts
  • LocationIndiana, USA

Posted 08 November 2011 - 02:43 AM

OK, more progress. It happened again. I checked the USB Name and it did not revert back to the default and kept the name that I created. Although, this time, it was able to completely recover itself. Part of the problem for me is that I didn't know when the networking was done being initialized. Partly because in the 4.1 firmware, the initial IP address was 0.0.0.0, but with 4.2, it seems that it is using the IP address from the previous bootup, then the IP changes 3-20 seconds later when it gets it for real from the router with DHCP. Usually it's the same address anyway, but sometimes it's not. So, I decided to intentionally assign an address of 0.0.0.0, then enable DHCP and loop until I have an address. So far it's perfect, but I need more data points. -Valkyrie-MT

#12 BanksySan

BanksySan

    Member

  • Members
  • PipPip
  • 28 posts
  • LocationBristol, United Kingdom

Posted 23 January 2012 - 03:21 PM

Hia,

Was there any conclusion to this? My new (and only) N+ is doing the same, MAC-Addy suddenly is 0, also, even after correcting it I can't connect via Ethernat (This post: cant-connect-via-ethernet).

Also, if I untick the use DHCP box in MFDeploy and click "update", it is always back on again when I go back into the Network config window.

#13 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 23 January 2012 - 04:46 PM

Hi BanksySan,

Was there any conclusion to this? My new (and only) N+ is doing the same, MAC-Addy suddenly is 0, also, even after correcting it I can't connect via Ethernat (This post: cant-connect-via-ethernet).

Also, if I untick the use DHCP box in MFDeploy and click "update", it is always back on again when I go back into the Network config window.

Are you enabling DHCP via an app which is on your Netduino Plus? If so, then that box would get auto-checked again...

Could you please try the following?
1. ERASE your current app using the Erase button in MFDeploy
2. Check the firmware version on your device using MFDeploy's "device capabilities option". Is it "Netduino" or "Netduino Plus" firmware? What version?
3. Set your device's MAC Address and give it a Static IP address (not DHCP). Save it.
4. Wait 5 seconds.
5. Now query the MAC address and IP address. Are they what you set it to?

There might be a glitch between the DHCP server and the Netduino Plus. If we can establish the static IP works, then we can debug from there...

Chris

#14 BanksySan

BanksySan

    Member

  • Members
  • PipPip
  • 28 posts
  • LocationBristol, United Kingdom

Posted 23 January 2012 - 08:48 PM

Hia Chris, Thanks for replying so fast. Followed your instructions, and the changes I make stick. I assume I was too quick on checking the config after the change before, I didn't give it time to take affect. The zero-ing of the Mac addy has happened though, if it happens again I'll post it here! Cheers.

#15 Valkyrie-MT

Valkyrie-MT

    Advanced Member

  • Members
  • PipPipPip
  • 315 posts
  • LocationIndiana, USA

Posted 25 January 2012 - 05:15 AM

Was there any conclusion to this?


Here is my conclusion... I am still seeing this about once in 15 reboots but have worked around it. It may be that because I always use DHCP (and most others don't), I see it more. Fortunately, restoring the MAC address as I stated earlier in this thread did the trick. It works EVERY time. My Netduino boots on DHCP perfectly and automatically corrects and restores MAC addresses when needed. It also sets the static/dhcp setting to DHCP because that seems to get set back to static and 192.168.5.1. Thankfully, the 4.2 RC3 firmware fixed just enough of the Netowrking stuff to make this workaround possible...

I saw some bug fixes checked into codeplex after the .NET MF 4.2 RTM that may address this issue so I was holding back on reporting the issue until I had time to test a new version...

-Valkyrie-MT

#16 control-labs

control-labs

    New Member

  • Members
  • Pip
  • 1 posts

Posted 09 March 2012 - 03:05 AM

I have a web application and I need to be able to switch from static to DHCP as requested in a config file. I also change DNS from static to dynamic. Using 4.2 RC 4 it happens frequently to get the MAC to zeros.

#17 ColinR

ColinR

    Advanced Member

  • Members
  • PipPipPip
  • 142 posts
  • LocationCape Town, South Africa

Posted 26 April 2012 - 06:15 AM

Fortunately, restoring the MAC address as I stated earlier in this thread did the trick. It works EVERY time.


I've tried setting the MAC address in code - and I can confirm in code that the address is changed (ie the byte array reflects the new bytes) But when checking the ARP table, I still see the previous mac listed.

Does your other network hardware see the updated MAC?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.