Ethernet module and the February SDK - DHCP is not working

I just updated to the February SDK. Using the FEZ Spider and an ethernet module from the Spider kit, the following code:


    public partial class Program
    {
        void ProgramStarted()
        {
            Debug.Print("Program Started");

            SetupEthernet();
        }


        void SetupEthernet()
        {
            ethernet.UseDHCP();

            if (ethernet.IsNetworkConnected)
                ListNetworkInterfaces();
            else
                Debug.Print("Not connected to network.");
        }

        void ListNetworkInterfaces()
        {
            foreach (NetworkInterface info in NetworkInterface.GetAllNetworkInterfaces())
            {
                Debug.Print("------------------------------------------------");
                Debug.Print("MAC: " + ByteExtensions.ToHexString(info.PhysicalAddress, "-"));
                Debug.Print("IP Address:   " + info.IPAddress);
                Debug.Print("DHCP Enabled: " + info.IsDhcpEnabled);
                Debug.Print("Subnet Mask:  " + info.SubnetMask);
                Debug.Print("Gateway:      " + info.GatewayAddress);
                Debug.Print("------------------------------------------------");
            }
        }

    }

produces this:

Program Started
    #### Exception System.Exception - CLR_E_FAIL (3) ####
    #### Message: 
    #### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::UpdateConfiguration [IP: 0000] ####
    #### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::EnableDhcp [IP: 000f] ####
    #### Gadgeteer.Modules.Module+NetworkModule::DHCPThread [IP: 0028] ####
A first chance exception of type 'System.Exception' occurred in Microsoft.SPOT.Net.dll
------------------------------------------------
MAC: 00-1A-F1-00-42-0D
IP Address:   192.168.1.200
DHCP Enabled: False
Subnet Mask:  255.255.255.0
Gateway:      0.0.0.0
------------------------------------------------
Ethernet_J11D ERROR : DHCP Error - networking may not work

You can see I have an IP address, although the gateway is empty and the subnet mask is incorrect and DHCP is not enabled. Here’s the output of ipconfig from my PC:


Ethernet adapter Local Area Connection 2:

   Connection-specific DNS Suffix  . : home.irritatedvowel.com
   Link-local IPv6 Address . . . . . : fe80::d42f:cbc6:c8de:8f22%20
   IPv4 Address. . . . . . . . . . . : 192.168.1.6
   Subnet Mask . . . . . . . . . . . : 255.255.254.0
   Default Gateway . . . . . . . . . : 192.168.1.1

Tunnel adapter isatap.home.irritatedvowel.com:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . : home.irritatedvowel.com

Tunnel adapter Teredo Tunneling Pseudo-Interface:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

C:\Windows\system32>

I had removed all references and re-added, and also cleaned the solution. I also updated the firmware on the Spider during the install.

GHI Assembly versions in my project:
GHIElectronics.Gadgeteer.FEZSpider : 4.1.2.0
GTM.GHIElectronics.UsbClientDP: 4.1.1.0
GTM.GHIElectronics.Ethernet_J11D: 4.1.1.0
GTM.GHIElectronics.Display_T35: 4.1.2.0

Any suggestions on where to start looking? I really need to use DHCP as I want to be able to take this demo on the road with me, where a static IP is not usually an option.

I looked through posts here, but they were pre-February SDK and seemed to indicate that the Feb SDK updates would have the underlying fixes required.

Pete

With EMX, you can set networking stuff in MFDeploy. Check there and see what it reports, clear anything that shouldn’t be there etc etc. I don’t have my Cobra around to check firmware versions, but according to my readme in my SDK the EMX firmware is:

which doesn’t look right on your board? Edit: maybe the Gadgeteer versions are ok, ignore me

Thanks. I don’t see anything useful from MFDeploy


HalSystemInfo.halVersion:               4.1.2821.0
HalSystemInfo.halVendorInfo:            Microsoft Copyright (C) Microsoft Corporation.  All rig
HalSystemInfo.oemCode:                  255
HalSystemInfo.modelCode:                0
HalSystemInfo.skuCode:                  65535
HalSystemInfo.moduleSerialNumber:       FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
HalSystemInfo.systemSerialNumber:       FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
ClrInfo.clrVersion:                     4.1.2821.0
ClrInfo.clrVendorInfo:                  Microsoft Copyright (C) Microsoft Corporation.  All rig
ClrInfo.targetFrameworkVersion:         4.1.2821.0
SolutionReleaseInfo.solutionVersion:    4.1.8.0
SolutionReleaseInfo.solutionVendorInfo: GHI Electronics, LLC
SoftwareVersion.BuildDate:              Dec 22 2011
SoftwareVersion.CompilerVersion:        410561
FloatingPoint:                          True
SourceLevelDebugging:                   True
ThreadCreateEx:                         True
LCD.Width:                              320
LCD.Height:                             240
LCD.BitsPerPixel:                       16
AppDomains:                             True
ExceptionFilters:                       True
IncrementalDeployment:                  True
SoftReboot:                             True
Profiling:                              False
ProfilingAllocations:                   False
ProfilingCalls:                         False
IsUnknown:                              False

But aha! DHCP Wasn’t enabled via MFDeploy (Target -> Configuration -> Network). I would have never thought I had to configure it there. Thanks :slight_smile:

But alas, even with that, no go. Same long delay followed by the error.


The thread '<No Name>' (0x2) has exited with code 0 (0x0).
Using mainboard GHIElectronics-FEZSpider version 1.0
Program Started
    #### Exception System.Exception - CLR_E_FAIL (3) ####
    #### Message: 
    #### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::UpdateConfiguration [IP: 0000] ####
    #### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::RenewDhcpLease [IP: 0006] ####
    #### Gadgeteer.Modules.Module+NetworkModule::DHCPThread [IP: 0031] ####
A first chance exception of type 'System.Exception' occurred in Microsoft.SPOT.Net.dll
------------------------------------------------
MAC: 00-1A-F1-00-42-0D
IP Address:   0.0.0.0
DHCP Enabled: True
Subnet Mask:  0.0.0.0
Gateway:      0.0.0.0
------------------------------------------------
Ethernet_J11D ERROR : DHCP Error - networking may not work

I went back into MFDeploy and confirmed that DHCP is marked as enabled.

Pete

at least now the info you have displayed looks consistent with what you expect ! Small consolation ! :wink:

Is the MAC address you have shown there the correct MAC? And you’re sure the DHCP server is alive and well? Do you have a hub and netmon running somewhere that you can check to see if Fez sends out the dhcp request?

And finally, you have had this combination (besides firmware) working before in your network, right?

Reading the error messages more, the first CLR_E_FAIL was when attempting to enable DHCP, in hindsight that seems to be related to MFDeploy not having that set.

The 2nd CLR_E_FAIL is different - it’s on DHCP RENEW, so there’s a comms issue getting an address from your network - that’s where I’d focus, check your connections are good, make sure your MAC is valid, make sure your router is responding to other devices (ipconfig/all will show you when your PC’s lease was obtained, ipconfig/renew should renew it, and /all again should show the updated time obtained).

IP Address: 192.168.1.200 is the default static IP of EMX. IT was not acquired by your Dhcp server

The code you posted is not optimal for Etherent usage. UseDhcp() does not acquire Dhcp lease. it just runs the Dhcp thread. You need to check the Ethernet module network events.

Good catch on the actual error.

I have never connected this device to my network. No netmon running anywhere, and my router doesn’t appear to log DHCP requests.

I released and renewed my IP address on my desktop. (Release took forever, but renew was pretty instantaneous.) 13 active devices on my networking, but this isn’t one of them.

Swapped cables with a known working network cable and port (I have a second hub on my desk that everything is plugged into. I snagged the connection from my laptop)

Rebooted my router.

Still no go.

Pete

Try this code

 public partial class Program
    {
        void ProgramStarted()
        {
            Debug.Print("Program Started");
            //ethernet.UseStaticIP("192.168.0.250","255.255.255.0","192.168.0.1",new String[]{"10.1.10.1"});
            ethernet.UseDHCP();
            ethernet.NetworkUp += new GTM.Module.NetworkModule.NetworkEventHandler(ethernet_NetworkUp);
            ethernet.NetworkDown += new GTM.Module.NetworkModule.NetworkEventHandler(ethernet_NetworkDown);
            
        }

        void ethernet_NetworkDown(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
        {
            Debug.Print("Network is Down");
        }

        void ethernet_NetworkUp(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
        {
            Debug.Print("Network is Up");
            Debug.Print("IP Address: "+ethernet.NetworkSettings.IPAddress.ToString());
            Debug.Print("Subnet Mask: " + ethernet.NetworkSettings.SubnetMask.ToString());
            Debug.Print("Gateway: " + ethernet.NetworkSettings.GatewayAddress.ToString());
            Debug.Print("DNS Server: " + ethernet.NetworkSettings.DnsAddresses[0].ToString());
        }
    }

@ Joe

Interesting, thanks. I had assumed that would use DHCP :slight_smile:

I tried looking through the source on codeplex to see what the expected behavior was, but looks like this module doesn’t have source (one of the EMX modules you have private, I assume)

Checking network events (network up/down), I never get “Network Up”. When I checked the threads here, I saw network events weren’t working in previous versions of the firmware (a comment from Gus). Should they be working in this version?

Is there an example of using this network interface?

FWIW, even with DHCP enabled, the LCD module still shows the built-in network address on boot.

Thanks.

Pete

Thanks Joe. I’ll try out that code.

Pete

Joe, event with your code (which is what I was using before the firmware update), it still fails.

[quote]The thread ‘’ (0x2) has exited with code 0 (0x0).
Using mainboard GHIElectronics-FEZSpider version 1.0
Program Started
#### Exception System.Exception - CLR_E_FAIL (3) ####
#### Message:
#### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::UpdateConfiguration [IP: 0000] ####
#### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::RenewDhcpLease [IP: 0006] ####
#### Gadgeteer.Modules.Module+NetworkModule::DHCPThread [IP: 0031] ####
A first chance exception of type ‘System.Exception’ occurred in Microsoft.SPOT.Net.dll
Network down.
Ethernet_J11D ERROR : DHCP Error - networking may not work[/quote]

I’m trying to figure out where the error is whether it is on my network, my code, GHI code etc. Is the Spider DHCP code known to work in the February SDK?

Thanks.

Pete

FWIW, I hard-coded a static IP and that appears to work. So it’s DHCP client code on the Spider or DHCP server code on my router. Not sure which.

Pete

yes sure it should be fine.

The exception means that it failed to communicate with a DHCP server. Assign static IP and ping it from your PC to make sure if it is a DHCP or network connectivity.

Also set the MAC address found on the stick on the back of FEZ Spider. This is not very an important step, but just to make usre that you got an acceptable MAC address on the device, since some dhcp servers do not like invalid MAC addresses.

Static IP worked.

Then updated the mac to match the sticker. I also went into MFDeploy and re-enabled DHCP, which was automatically unchecked after doing the Static IP test. Should I assume that UseDHCP would do the equivalent of checking that value, or do I need to include that in my setup steps?

In any case, still no go on DHCP.

Using mainboard GHIElectronics-FEZSpider version 1.0
Program Started
    #### Exception System.Exception - CLR_E_FAIL (3) ####
    #### Message: 
    #### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::UpdateConfiguration [IP: 0000] ####
    #### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::EnableDhcp [IP: 000f] ####
    #### Gadgeteer.Modules.Module+NetworkModule::DHCPThread [IP: 0028] ####
A first chance exception of type 'System.Exception' occurred in Microsoft.SPOT.Net.dll
Network down.
Ethernet_J11D ERROR : DHCP Error - networking may not work

I’m going to try a few other things and let you know what I find out.

Pete

The DHCP option in MFDeploy is ignored in EMX firmware. to avoid letting the system lock out on startup. Do no’t depend on it.

I am not sure what to suggest next.
Try another network or DHCP server. Maybe there is some kind of compatibly with your router!? There might something worng with the configuration sector, so erase memory and update the firmware just in case.
One of our old community members encounter some problem with the DHCP server of ORANGE LIVEBOX PROII (from SAGEM). I think this is the only case. Do you have a similar device?
http://www.tinyclr.com/forum/18/3479/

Thanks Joe.

So I tried a Netduino Plus with 4.1 NETMF and had the same problem. I then upgrade it to 4.2 NETMF, still can’t get a DHCP address.

PCs have no issues getting an address. Our two Kindle Fires (wireless through a separate access point on my network) also have no issues getting an address through DHCP.

The router providing DNS in my house is my FIOS router. It’s an Actiontec MI424-WR. I rebooted it just in case.

Pete

Find an old hub and netmon and watch traffic… or just plug Fez into your PC directly and try capturing the traffic there (that obviously means you won’t see a return packet sent)

http://www.macvendorlookup.com/ and make yourself a new random MAC and see if that works?

Ok. third set of cables and now I have an IP address.

The other two cables worked with my PCs, just not with the Netduino or the Spider. Different ports, same ports, same thing.

Still not working with my Netduino though. Odd.

Pete

Hi Pete,
Can you please report what exactly is written on the non woring cables and the working one…

i would like to know the category, AWG and the MHZ of the cables…they might be related…

thanks.