Main Site Documentation

G400D Dev Board ethernet test program


#21

I hooked ethenet cable between Ethernet port of G400-D Dev board and my home Wifi wireless gateway Ethernet port. After I run the firmware, output keep showing “Waiting for DHCP”, in the middle, it prints out “Network availability: True” once.

I cannot use Wifi for Etherent connection?


#22

Then your network is not leasing an IP to your G400 board. Check your network settings. This should just work be default normally, so I am surprised it didn’t.

This means the cable was detected to be connected.


#23

I use my computer to disable the wireless, and enable ethernet. I use ethernet cable to hook my computer up to home wifi gateway ethernet port. I can get on the internet. So the home ethernet is working.

Then I hook up the ethernet cable from wife gateway to ethernet port of G400-D Dev board, use USB Debug port to load the firmware into the board, still show “Waiting for DHCP” forever.

What is wrong?
I have the code as follows:

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Input;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;
using GHI.Processor;

using GHI.Networking;
using Microsoft.SPOT.Net.NetworkInformation;
using System.Net;

namespace NETMFBook
{

public class Program
{
    private static EthernetBuiltIn netif;

    public static void Main()
    {
        NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged;
        NetworkChange.NetworkAddressChanged += NetworkChange_NetworkAddressChanged;

        netif = new EthernetBuiltIn();
        netif.Open();
        netif.EnableDhcp();
        netif.EnableDynamicDns();

        while (netif.IPAddress == "0.0.0.0")
        {
            Debug.Print("Waiting for DHCP");
            Thread.Sleep(250);
        }
        Debug.Print("Good Ethernet");
        //The network is now ready to use.
    }

    private static void NetworkChange_NetworkAddressChanged(object sender, Microsoft.SPOT.EventArgs e)
    {
        Debug.Print("Network address changed");
    }

    private static void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
    {
        Debug.Print("Network availability: " + e.IsAvailable.ToString());
    }
}

}


#24

my first guess is your MAC address is not valid or not in an appropriate range, and is being discarded by your DHCP server (your router/wifi gateway device). Pick a different MAC address.


#25

Sorry I am new to the networking stuff. How do I specify the MAC address of G400-D Dev board? Do I write the firmware to do this? If so, is there any example for this?


#26

This is easiest with GHI FEZConfig


#27


#28

I use FEZ to change MAC Address as above into the board.
Still the same thing when plug in home wireless gateway Etheret port.

Any idea?


#29

so that’s a valid DELL MAC address. As long as it’s not the same as a Dell device on your network, that should be OK.

Next idea is you need an old-school HUB and wireshark to capture network packets.


#30

I do not have an old-school hub and I have to finish this ethernet hardware test fast. So i connect Ethernet cable between my comuter and G400D Dev board. In cmd.exe, I type: ping 192.168.50.10(the static IP address in the FEZ Config, which is IP address of G400-D board). But the message returned shows no reply.

Anything I am missing with ping command?


#31

Yes. You set your code to DHCP and then ping an address. Even if you have set the address properly you have to make sure your network is on 192.168.50.xxx. Also, setting the config tool is not enough to enable the network.

So, set the MAC address and then run your code with static IP but then check your network for proper IP address. For example, check your connected devices address and make a note of the IP address. For example if your PC is 192.168.4.xxx then you have to set your IP to the same first three numbers and then change the forth number (marked xxx) to a unique one that is not being used.

Read here about subnetting https://en.wikipedia.org/wiki/IP_address

An easier approach is to run the original code with DHCP (from the example in the docs) and figure out why your networking is not giving G400 an IP address. The problem is in your network, not G400.

Until you can ping G400 successfully, nothing will work.


#32

“So, set the MAC address and then run your code with static IP …”
After I set MAC address with FEZ Config, when I run my code, it uses dynamic IP by “netif.EnableDhcp(); and netif.EnableDynamicDns();” Do I need to comment these 2 statements to use static IP?

To specify specific static IP address, which command I need to use? netif.EnableStaticIP(“192.168.4.xxx”)?


#33

This will only work if your subnet is 192.168.4 and yo need a number that in unique to your network to replace xxx


#34

I see page 58 of G400 SoM User Manual (IP address DHCP or static section) indicating that “If using dynamic IP, the G400 will not obtain an IP lease at power up."

Does that mean in order for the wife gateway to lease IP address for my G400-D board, I have to use static IP, not DHCP in the application firmware?


#35

No.
If you want to use DHCP, use DHCP. Never set a fixed IP address, otherwise it can conflict with DHCP.