I received my Netduino Plus 2 about 1 week ago, and I have really enjoyed experimenting with it so far. What a great little board !!
But, I had found an issue that kinda drove me crazy....
Working on an ethernet type of app, I ended up finding out that the ethernet did not seem to initialize (show ACT LED) when power had been removed for 15 or more seconds (i.e. first Power Up). I found that simply pressing the onboard button to reset, or even just unplug it again quickly then reconnect would resolve the issue.
For reliability though, this bothered me. For instance: what if a device lost power, it would not reset itself until YOU push the button. Not good.
I found all sorts of issues posted here but couldn't find anything that sounded like my issue.
I also had tried using the power management command to cycle power to the ethernet chip, no go...
Doing a hardware reboot via software ( PowerState.RebootDevice(false); ) alone, did not solve the issue either.
FINALLY today, I found that if I send a reset to the ethernet IC, THEN reboot, VOILA !! it finally works
The reset "/ENC_RESET" comes out on pin 54 from the Micro, and relates to (Cpu.Pin)50. It is normally HIGH.
private static OutputPort resetEthernetPort = new OutputPort((Cpu.Pin)50, true); //0x32 hex
I cycle it low, sleep 50ms, then back high and RebootDevice:
resetEthernetPort.Write(false); Thread.Sleep(50); resetEthernetPort.Write(true);
PowerState.RebootDevice(false);
Just wanted to share, if this helps anyone else out.
Here is the section of code:
private static OutputPort resetEthernetPort = new OutputPort((Cpu.Pin)50, true); //0x32 hexpublic static bool DHCP = false;// if DHCP set to true, these two values dont matter. Subnet mask is set to: 255.255.255.0public static string myIPaddress = "192.168.137.10";public static string myGatewayAddress = "192.168.137.1";private static void resetEthernet() { resetEthernetPort.Write(false); Thread.Sleep(50); resetEthernetPort.Write(true); }private static void rebootME() { resetEthernet(); PowerState.RebootDevice(false); }private static void checkIP() { NetworkInterface NI; if (DHCP) { Debug.Print("Setting to DHCP."); NetworkInterface.GetAllNetworkInterfaces()[0].EnableDhcp(); } else { Debug.Print("Setting to static IP address."); NetworkInterface.GetAllNetworkInterfaces()[0].EnableStaticIP(myIPaddress, "255.255.255.0", myGatewayAddress); } int countTry = 1; while (true) { NI = NetworkInterface.GetAllNetworkInterfaces()[0]; if (NI.IPAddress != "0.0.0.0") { Debug.Print("IP Address Obtained: " + NI.IPAddress); break; } else { Debug.Print("Try #" + countTry + ". No IP Address ..."); Thread.Sleep(2000); } countTry++; if (countTry == 6) { Debug.Print("Failure after 5 tries. Rebooting device..."); rebootME(); } } }
I was hoping that just doing a quick reset at the beginning of the program would also work, but for some reason it doesn't. It seems to need the Reboot Device, also.
Oh... and I DO have the current firmware, v4.2.1.2
-Ron