5 years, 7 months ago.

Error: Cannot open source input file "EthernetInterface.h": No such file or directory in ...

About two weeks ago I had a working project with the online compiler for K64F with Ethernet at version mbed-os 5.7.7. On Sunday I would make some tests and start a compile and got the upper error message. I tried a lot of changes and read a lot of documentation, I don't find an answer or could fix the problem. I moved the folder lwip-interface one stage higher, then I could compile but during initialisation, the eth.connect() call will hang. It seems, it has to do with chaning the environment for OS 5.10.0. I also updated to version 5.9.7 but with this I get the Error: "/tmp/CLzx3V", line 124 (column 3): Warning: L6312W: Empty Execution region description for region RW_IRAM1. Thank's in advance and best Regards, Peter S.

1 Answer

5 years, 7 months ago.

Hello Peter,

It seems that in mbed-os 5.10.0 some features and components have been integrated into the mbed system (see for example this issue) and from now on are optional. We have to add them to our projects in case we would like to use them. I'd suggest to add an mbed_app.json file to the project with the following content:

mbed_app.json

{
    "target_overrides": {
        "K64F": {
            "target.features_add": ["LWIP"]
        }
    }
}

Accepted Answer

Hello Zoltan, thank's for your answer. Indeed, the compile run successful with this additional file but the result is the same as I moved the folder before. The application did not run, it hang at eth.connect() after I have set the IP-Address. May be the reason is, I use a fix IP address. I have read, that mbed-os5.10.0 only work on DHCP. But this is not useful for me, I need a fix IP-Address. Best Regards, Peter

posted by Peter S. 03 Oct 2018

Although it throws two warnings about deprecated stuff, the following server is running well on mbed-os 5.10.0 and it's using static IP address:

#include "mbed.h"
#include "EthernetInterface.h"
#include "TCPServer.h"
#include "TCPSocket.h"
 
#define SERVER_PORT 80
 
EthernetInterface   ethernet;
TCPServer           server;
TCPSocket           client;
SocketAddress       clientAddress;
char                buffer[1024];
 
int main(void)
{
    ethernet.set_network("192.168.1.181","255.255.255.0","192.168.1.1");  // use static IP address, netmask, gateway
    ethernet.connect();
    printf("\nServer IP Address is %s\n\r", ethernet.get_ip_address());
 
    server.open(&ethernet);
    server.bind(ethernet.get_ip_address(), SERVER_PORT);
    server.listen(5);
    
    while (true) {
        printf("Server bound and listening\n");
 
        while (true) {
            server.accept(&client, &clientAddress);
            printf("Client %s connected.\n\r", clientAddress.get_ip_address());
 
            int     n = client.recv(buffer, sizeof(buffer));
 
            printf("Received %u bytes from remote host\n", n);  //print received message to terminal
            buffer[n] = '\0';
            printf("Received message from Client :'%s'\n", buffer);
 
            client.close();
        }
    }
}
posted by Zoltan Hudak 03 Oct 2018