9 years, 9 months ago.

Ethernet not working

I've LPC1768 mBed mounted on application board that has inbuilt RJ45 ethernet connector. I am trying out following code but not getting IP address. It is taking lot of time in connect() and returning blank address then after.

EthernetInterface eth; eth.init(); eth.connect(); printf("IP Address is %s\n", eth.getIPAddress());

Above code I copied from handbook example.

I've also tried below handbook examples, but eth.receive() always returns 0. https://developer.mbed.org/handbook/Ethernet

I've connected via router & direct connection as well. I'm not sure LED should glow as it glows when ethernet cable is connected with PC / laptop.

Please help me to solve this issue.

Hi have you solved this problem? If yes could you please kindly reply me?

posted by Zi Jen Sam 21 Nov 2015

2 Answers

7 years ago.

I am having the same issue connecting to ethernet with the LPC1768 mbed application board. I have tried countless EthernetInterface and EthernetNetIf cookbook examples. As well as… checking my ethernet port cable.

The RJ45 data and power LED’s NEVER light up. My ethernet cable is NOT the problem, because it connects just fine to a raspberry Pi. Im starting to think it’s a manufacturing fault on the mbed application board!!

Have you tried https://os.mbed.com/teams/sandbox/code/http-example/ or https://github.com/ARMmbed/mbed-os-example-sockets examples? Some examples could be outdated in cookbooks. Also can you share your code and mbed-os version.

posted by Daniel Klioc 16 Nov 2017

I haven’t come across either of these examples… I will give them a try know now. I will try anything new at this point. thanks!

posted by jodie nye 16 Nov 2017
9 years, 9 months ago.

Hi prashant,

My solution is much like yours -

    EthernetInterface eth;
    ...
    pc.printf("Initializing network interface...\r\n");
    if (0 == eth.init()) {  //Use DHCP
        do {
            pc.printf("Connecting to network...\r\n");
            if (0 == eth.connect()) {
                linkup = true;
                pc.printf("Ethernet connected as %s\r\n", eth.getIPAddress());
                while (get_link_status()) {
                   // do work here...
                }; // lost the link
           };  / canot connect
        };   // can't connect
    };  // not using dhcp

but with a small expansion, the return values could be checked and reported, and this may lead you to identifying the root cause. I've been using this technique for some time now, presently with mbed official EthernetInterface library version 45.

You might also want to check the cable itself. If you plug you PC in to that cable, does it work?