Dhcp on EMX module

Hi,

Way back in July - I was using a Panda with wiznet to prototype a new product.

I finalised the design with an EMX module, and now have my boards back.

The board is up and running - but once again I find that DHCP is not working on this board either ??.

I just get an exception if I try to either ‘EnableDhcp’ OR ‘RenewDhcpLease’ (having enabled DHCP using MfDeploy).

When looking at a packet sniff on the network - there appear to be requests coming from my PC for an IP address - but not from the board (senders MAC is my PC port!!). The PC requests have a MAC address of all zero’s.

None of the MAC addresses seem to correspond with what is on the EMX board label. Even MfDeploy reports a different MAC address :-O.

So - what am I doing wrong here ??? Should I override the MfDeploy MAC with that on the EMX label or what ???.

Help please…

NB I did update the firmware to 4.1.8.0 using your updater tool.

Many Thanks

Best Regards

Graham

Use mfdeploy to set the MAC address you see on sticker please.

Gus,

This is probably a dumb question, but…

I’ve been using the MAC address configured by MFDeploy for my Cobra, and it works fine. I don’t remember there being a “sticker” on the packaging for the Cobra. Was there one, and is the MAC address hardcoded into the Cobra?

Thanks.

EMX doesn’t have a hard-coded MAC but we provide a MAX with EMX modules.

Cobra uses EMX so same applies.

Thanks Gus. I understand now.

Gus,

Sorry for the delay - I was not in the office for most of yesterday.

Been trying unsuccessfully to get Ethernet working on ANY EMX product :-((. I have a couple of my own boards with EMX modules.

I also have a Cobra and just put the same code into it, it also will not work :-((.

Using 4.1.8 codebase…

If I set for dhcp - it just barfs with a System Exception after a long timeout.

I have tried setting a static IP using MfDeploy.

I then run some very simple code, and sit in a loop. Ethernet tells me that the cable is connected, and I get a Networkavailabilitychanged event when unplugging and plugging in my cable.

If I try a simple Ping to the board(s) ARP does not even respond (using Netmon on a local non-switching Hub). Tried 2 different cables (as per some posts). Proven the cables in my PC and they are OK there.

MAC set to be that on the EMX sticker. Gateway set to my router. IP set to 192.168.1.200 (Cobra board).

What else do I need to do just to bring up the Ethernet IF :-O.

Code is taken from your or Microsofts ?? simple example with the webclient stuff removed…


        public static void Init()
        {
            if (!Ethernet.IsEnabled)
            {
                Ethernet.Enable();
            }

           NetworkInterface[] netif = NetworkInterface.GetAllNetworkInterfaces();
            // Ethernet is always the first interface netif[0]
            NetworkAvailablityBlocking = new ManualResetEvent(false);

            if (!Ethernet.IsCableConnected)
            {
                Debug.Print("Cable is not connected!");
                NetworkAvailablityBlocking.Reset();
                while (!NetworkAvailablityBlocking.WaitOne(5000, false))
                {
                    if (!Ethernet.IsCableConnected)
                    {
                        Debug.Print("Cable is not connected!");
                        Debug.Print("Still waiting.");
                    }
                    else
                        break;
                }
            }

            Debug.Print("Ethernet cable is connected!");

            
            while (true)
            {
                Debug.Print("Waiting...");
                Thread.Sleep(30000);

            }

        }


Thanks…

Graham

try enabling the Ethernet interface as dhcp or static addressing. then after the cable is inserted, print out the ip address and gateway of the interface

Mike,

Thanks for the suggestion, but I already tried that :

        netif[0].EnableStaticIP("192.168.1.200", "255.255.255.0", "192.168.1.1");

Made no difference. netif[0] shows the same IP’s before and after.

If I call EnableDhcp - it just blocks until it eventually raised a system Exception.

Thanks

Graham

If Dhcp fails it assign the last static ip assigned.i .e. 192.168.1.200.

Please try another Dhcp server and different cable (even if the cable works with your PC) to isolate the problem. Some community members have encounter some incompatibility issues.

Joe,

Not a simple matter to change DHCP server :-(. I also swapped the cable anyway = no difference.

I think thats misleading anyway - as it won’t even come up in Static IP mode.

I think I need to see it working in static mode first and only then start to worry about DHCP.

When ping’d it should first see the ARP request for the defined IP address - and send a response to that - its not doing that.

I will try to use a different hub (but I don’t think that will be the issue :-O).

Regards

Graham

Added a new 10/100/1000 switch directly connected to the board and it made no difference.

Graham

[quote]I think I need to see it working in static mode first and only then start to worry about DHCP.

When ping’d it should first see the ARP request for the defined IP address - and send a response to that - its not doing that.[/quote]

That’s a good strategy.

If you like, There are some free applications that simulate Dhcp server on a PC.

If neither static IP nor Dhcp method worked. Then I beleive there is something wrong in the phsical connection or network settings. Double check the subnet mask, the netwrok ID.

Connect the system directly to your PC using a crossover cable and set static IPs on both sides and ping Cobra’s IP address from the PC.

Ignore last message - I lied !!.

After connecting the new switch - I forgot that I had set the Static IP Address in code to 200 instead of 101, so I was pinging the wrong address :-((.

SO - the upshot is that the EMX modules don’t appear to like my VERY OLD 10M Hub :-((.

NB I ONLY ever use this when I need to sniff packets on a non-PC hardware :-O, as a switch filters and thus won’t permit this.

So - the Hub is still ‘in circuit’ (so that I can sniff packets) but interfaced through a 10/100/1000 DLink switch, between it and the EMX board.

The board which is working is my own hardware - so an even better result :slight_smile:

With the 10M hub directly connected, the ‘link pulse’ LED was lit (Green) but the yellow one was not (ie it sensed 10M), but now its running at 100M I guess - as this LED is also lit (yellow).

Maybe the driver code just doesn’t like working at 10M ?? - 10M IS pretty ‘old hat’ these days I guess :-O.

Anyway - that seems to be this problem resolved.

Many Thanks to those who suggested things to try ;-)).

Best regards

Graham

OK - final testing :

  1. remove line forcing StaticIp - and it still works, picking up Static IP from MfDeploy (I know - I made it 102 instead of 101 :wink:

  2. Set MfDeploy Enable DHCP flag, and add back in the DHCP code (see below for those who want it). This also worked, gave me a new IP (correctly DHCP allocated ;-), as well as new DNS server IP’s - even better ;-).

So - problem resolved - down to the hardware I was plugging in to :-(( - which has never failed me before with many ‘other’ hardware interfaces!!

Hope this saga might just help someone else ;-)).

Best regards

Graham


            Debug.Print("Enable DHCP");
            try
            {
                if (!netif[0].IsDhcpEnabled)
                    netif[0].EnableDhcp();// This function is blocking
                else
                {
                    netif[0].RenewDhcpLease();// This function is blocking
                }
                network_is_read = true;
                Debug.Print("Network settings:");
                Debug.Print("IP Address: " + netif[0].IPAddress);
                Debug.Print("Subnet Mask: " + netif[0].SubnetMask);
                Debug.Print("Default Getway: " + netif[0].GatewayAddress);
                Debug.Print("DNS Server: " + netif[0].DnsAddresses[0]);
            }
            catch (Exception ex)
            {
                Debug.Print("DHCP Failed");
            }


The LED is for speed indication. On= 100Mbps Off= 10Mbps