Latest lwip build (634) compile errors

17 Nov 2009

Hi All,

I had just upgraded to build 634 of the following Ethernet modules and now receive many compile errors where there were zero before.

http://mbed.org/projects/cookbook/svn/EMAC/lwip/tag/13
http://mbed.org/projects/cookbook/svn/EMAC/lwip/trunk

How can I go back to the previously released build -or- is there a fix on the way?

...kevin

17 Nov 2009

Hi,

Kevin Braun wrote:
I had just upgraded to build 634 of the following Ethernet modules and now receive many compile errors where there were zero before.

Rolf can probably tell you about the errors (I think he is working on it now and wasn't expecting it to be picked up so quickly!) But...

Kevin Braun wrote:
How can I go back to the previously released build -or- is there a fix on the way?

With regard to revisions, to import a specific revision of a library (repository), you just append @number when importing. For example, for this library, the url is:

  • http://mbed.org/projects/cookbook/svn/EMAC/lwip/trunk

So this would bring in the latest. Looking in the revision log, revision 604 is a few weeks old, so you could "Import Library...":

  • http://mbed.org/projects/cookbook/svn/EMAC/lwip/trunk@604

You can upgrade by clicking the "Update this library" button, but to revert/go backwards, you just have to delete and reimport for now.

Simon

17 Nov 2009

Simon,

How about another build?  This one gets errors as well, though different than before.  Do you remember the last "official" build that was put up in the Cookbook's Networking section?

...kevin

17 Nov 2009

Hi Kevin,

 

If you want to find out about older builds just use the svn view like here. You will have a link in the top right corner (right under SVN) named "Last Change". If you click there you get a view of the last change set. And you can navigate with the links in that corner through the changesets of that directory (

  • ← Previous Change
  • Next Change →).

  • The number of the changeset you are in is simply in the Title of the page

    Cheers

    Rolf

     

    P.S. Lets see whats wrong with the lib.

    Error reports welcome :-D

    17 Nov 2009

    Hi Kevin,

    Kevin Braun wrote:
    Do you remember the last "official" build that was put up in the Cookbook's Networking section?

    Nothing in the cookbook is official :) It is just whatever any users post up! But it does suggest if people use a trunk/branch convention or make a note of logs/what revisions are "releases" in the project documentation would be useful.

    We're hoping to revamp this whole version control/libraries area at some point (however it is not top of our list so may be some time), and we'll try and cover these sorts of cases, so this sort of usability feedback is great to help set some goals for it. Thanks!

    Simon

    17 Nov 2009

    Hi Kevin,

    What exactly are your build errors? I've started to test the code and it looks fine. My old programs compile without an error (Just one warning).

    Do you have an example which you can share with me?

     

    Cheers

    Rolf

    17 Nov 2009

    The number of errors has dropped significantly since I brought this up this morning.  Now there are just 2 warnings and one error:

    "Variable "mem_sem" was set but never used" in file "EthWebTest-1/lib/lwip/Core/lwIP/core/mem.c"

    "Variable "mem_sem" was set but never used" in file "EthWebTest-1/lib/13/Core/lwIP/core/mem.c"

    "Cannot open source input file "netif/device.h": No such file or directory (E5)" in file "EthWebTest-1/main.cpp"

    "Unable to download. Fix the reported errors..." in file "/"

    ...kevin

    18 Nov 2009

    Rolf,

    When trying this again, I received many more errors.  All but one in the 13 library.  The first errors:

    9 in etharp.c,  2 in tcp_out.c and  8 in dhcp.c before giving up

    Some are:

    "Pointer to incomplete class type is not allowed (E393)" in file "EthWebTest-1/lib/13/Core/lwIP/netif/etharp.c"

    "Class "etharp_hdr" has no member "ethhdr" (E135)" in file "EthWebTest-1/lib/13/Core/lwIP/netif/etharp.c"

    "Class "tcp_pcb" has no member "snd_max" (E135)" in file "EthWebTest-1/lib/13/Core/lwIP/core/tcp_out.c"

    "Class "dhcp" has no member "p" (E135)" in file "EthWebTest-1/lib/13/Core/lwIP/core/dhcp.c"

    What build was in the Cookbook's Networking a few days ago?  That one worked.

    ...kevin

    18 Nov 2009

    Hi Kevin,

    I'm sorry but I cannot reproduce it.

    Maybe you can publish your application and send me the link.

    It sounds worth to investigate.

     

    Regards

    Rolf

    18 Nov 2009

    Sure Rolf,

    It's pretty simple since I'm just getting started.

    By the way.  I went back to build 604 and of course, it compiled with errors.  I then updated to 634 by hitting the update button.  It then compiled without errors.  However, the Linker generated many errors.  That's a totally different behavior than deleting the libraries and putting in build 634 from the start.

    ...kevin

    18 Nov 2009

    Sorry Rolf,

    I meant build 626 to 634, not 604.  Here's the link to my project.

    http://mbed.org/users/loopsva/published/d1220d53d86bd53456bf848c8cad3508/EthWebTest-1.zip

    ...kevin

    18 Nov 2009

    Hi Kevin,

    Now I start to understand you try to build something with the raw lwIP API. I didn't port them over to the new lwIP version jet. There are still some fixes in the library to do.

    But as you corrected right the #include "netif/device.h" is now #include "device.h"

    The other compiler errors which seem magically to appear and disappear are caused by the fact that you are including the library twice. That was not a problem with the old version in tag/13 caused by the fact that it was a precompiled library. Background: Library files get only pulled in the binary if there is no other implementation of the function in your application. But in the updated version the tag is changed to a source version. I've restructured the project tree.

    So to solve this just get rid of the library 13.

    Another linking time error is caused by the fact that the symbol eth is already defined by the device.cpp. If you make your line 118: Ethernet eth; to extern Ethernet eth; it’s marked as extern and both files will use the same object.

    Here is the fixed version back.

    By the way what is you program about? Do you try to make your own experience to implement an HTTP server?

    If you just want to use one try the HTTPServer class, in the new version it should be more reliable and can do the static IP/ dhcp trick of its own. Furthermore I would like to hear some improvement ideas ;-)

     

    Cheers

    Rolf

    19 Nov 2009

    Thanks Rolf,

    I'm up and running again.  I'm a hardware engineer and am very good with various assembly codes.  However, I have very little knowledge of C and C++.  I thought that this would be a great tool to get started, so I'm hacking away....

    Just as a thought for future fumblers like myself, it might be good to either get rid of library 13 or add the comment "upload either the trunk library -or- the 13 library, but not both".

    Thanks again,

    ...kevin

    19 Nov 2009

    Kevin Braun wrote:
    Just as a thought for future fumblers like myself, it might be good to either get rid of library 13 or add the comment "upload either the trunk library -or- the 13 library, but not both".

    Yep I've done that, and I've updated to the new precompiled library path as well.

    Your welcome ;-)

    Rolf

    20 Nov 2009

    Rofl,

    I tried the new HTTP server and seem to be running into issues similar to the other thread.  Using Wireshark, I see that I'm getting an IP address from a local server.  And when I try to access the mbed HTTP server, some accesses do happen, but a timeout on the client eventually occurs.  A couple of questions.

    1. Using the new HTTP server and current lwip stack, how can I find out my IP and gateway address?  I can get my hw address from the mbed commands.

    2. What Web client is best used for the PC.  I'm currently using Windows IE.

    Best Regards,

    ...kevin

    20 Nov 2009

    Hi Kevin,

     

    Kevin Braun wrote:
    I tried the new HTTP server and seem to be running into issues similar to the other thread.  Using Wireshark, I see that I'm getting an IP address from a local server.  And when I try to access the mbed HTTP server, some accesses do happen, but a timeout on the client eventually occurs.  A couple of questions.

    Which server are you useing? The HTTPServer class or the wacky purehttpd?

     

    Kevin Braun wrote:
    1. Using the new HTTP server and current lwip stack, how can I find out my IP and gateway address?

    With the HTTPServer class the IP address is printed out on stdout.

     

    Kevin Braun wrote:
    2. What Web client is best used for the PC.  I'm currently using Windows IE.

    With the HTTPServer class I'm happily using Chrome, Firefox and Internet explorer. All do respond fine here.

     

    Cheers

    Rolf

     

     

    20 Nov 2009
    Which server are you useing? The HTTPServer class or the wacky purehttpd?

    This one:   http://mbed.org/projects/cookbook/svn/EMAC/lwip/examples/HTTPServer

    With the HTTPServer class the IP address is printed out on stdout.

    Hmmm...Where are they located.  I'd like to be able to get at them for other reasons.  Also, where can I change the host name?

    ...kevin

    20 Nov 2009 . Edited: 20 Nov 2009

     

    Kevin Braun wrote:
    Also, where can I change the host name?

    Try to create your object like this:

     

    HTTPServer server("hostname");

    But it might take a while until the network picks it up.

     

    Kevin Braun wrote:
    Hmmm...Where are they located.  I'd like to be able to get at them for other reasons.

    Somewhere very deep inside the lwip dhcp structures.

    Probably the best way to get a hand on them is to use the NetServer object and the provided functions.

    Don't get a NetServer pointer before you create the HTTPServer, otherwise the HTTPServer configuration is omitted and your hostname is lost.

    Have a look here: http://mbed.org/projects/cookbook/svn/EMAC/lwip/trunk/Core/NetServer.h (It's internal API and WILL change)

    Use something like:

     

    HTTPServer server("hostname");
    LocalFileSystem("/local");
    
    int main() {
        server.addHandler(new HTTPFS("/", "/local/"));
        server.bind();
        
        NetServer *net = NetServer::get();
        struct ip_addr ip = net->getIPAddr();
        struct ip_addr gw = net->getGateway();
        struct ip_addr nm = net->getNetmask();
        struct ip_addr dns = net->getDNS1();
        // ...
    }

    Don't change these values I have no idea what will happen if you change them after the network stack is initialized. Probably nothing nice.

    How to use these structs? Have a look in NetServer.cpp

    Cheers

    Rolf

     

     

     

    23 Nov 2009

    Rolf,

    I can no longer get a valid Ethernet hardware link status.  It use to work:

    extern Ethernet eth;

    .....

        while(eth.link() == 0) {
            int link();
            led2 = !led2;
            wait(1.0);
            lcd.cls();
            lcd.printf("Link DOWN"); 
        }

    Do you know what's up?

    ...kevin

     

    23 Nov 2009 . Edited: 23 Nov 2009

    Hi Kevin,

    Do you use this code earlier as the lwip init? or later?

    If you use it earlier do:

    Ethernet eth2;
    //...
        while(eth2.link() == 0) {
            int link();
            led2 = !led2;
            wait(1.0);
            lcd.cls();
            lcd.printf("Link DOWN");  
        }

    else

    extern Ethernet *eth;
    //...
        while(eth->link() == 0) {
            int link();
            led2 = !led2;
            wait(1.0);
            lcd.cls();
            lcd.printf("Link DOWN");  
        }

     

    The other version of eth declared in driver.cpp is a Ethernet * (a pointer to an ethernet object). This object will be created if the lwip init is made. Usualy this happens if you make the first HTTPClient request or HTTPServer bind().
    Cheers
    Rolf
    24 Nov 2009

    Thanks Rolf,

    Another rookie question... I am trying to take the value from above "struct ip_addr ip = net->getIPAddr();" and put it into 4 separate byte variables or an array.  For the life of me, I cannot get it to work.  The value is there and valid because I can print it as 8 hex digits.  What I want to do is convert it to a normal IP printout of something like 192.168.45.111 .

    Are you sure I can't change the host name?  What do I have to do in the structure above to display it?

    Finally, this should be a different topic.  Is there mbed code out there for a NTP client and interface directly to the mbed's RTC?  I think this would be a very useful tool.

    ...kevin

    24 Nov 2009

    Reading ip_addr.h, you can use ip4_addr1(ip), ... ip4_addr4(ip) to get the four digits. There is also ip_addr_debug_print(ip) but I'm not sure if it will be routed to mbed's stdout.

    24 Nov 2009 . Edited: 24 Nov 2009

    Hi Kevin,

    Kevin Braun wrote:
    Another rookie question... I am trying to take the value from above "struct ip_addr ip = net->getIPAddr();" and put it into 4 separate byte variables or an array.  For the life of me, I cannot get it to work.  The value is there and valid because I can print it as 8 hex digits.  What I want to do is convert it to a normal IP printout of something like 192.168.45.111 .

    Thats pretty simple if you had a look around in the code you've found this in http://mbed.org/projects/cookbook/svn/EMAC/lwip/trunk/Core/NetServer.cpp:

    struct ip_addr ip = net->getIPAddr();
    printf("IP: %hhu.%hhu.%hhu.%hhu\n", (ip.addr)&0xFF, (ip.addr>>8)&0xFF, (ip.addr>>16)&0xFF, (ip.addr>>24)&0xFF);
     

    But the ip4_addr*(ip) macros are saver, if you want to move to another platform.

     

    Kevin Braun wrote:
    Are you sure I can't change the host name?  What do I have to do in the structure above to display it?

    Well you can but if you initiated DHCP before it will do nothing. Updating the internal hostname will not transmit a new host name to the DHCP server. You can try (I did not).

    Have a look in the header file the functions are setHostname and getHostname ;-)

     

    Kevin Braun wrote:
    Finally, this should be a different topic.  Is there mbed code out there for a NTP client and interface directly to the mbed's RTC?  I think this would be a very useful tool.

    Jeah, this would be pretty useful I agree, wana write one? I've started but I run out of time and never finished. If you want I can publish the source and you can have a play with it. But it dose not work at all at the moment. It just has the structure of an NTP packet and tries to get NTP packets.

     

    Cheers

    Rolf

    24 Nov 2009

    I found an implementation for uIP. Looks pretty simple, so shouldn't be much effort to port it to lwip.

    31 Dec 2009

    I found SNTP implementation in LWIP/contrib and made it work. See my post http://mbed.org/forum/post/1765/. Any interest in that? Please post there since it is NTP-related thread.