Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Lwip basic question

Altera_Forum
Honored Contributor II
2,614 Views

Hi all, 

 

I'm starting with lwip, but have some problems with functions calling. I`m trying to create a simple UDP connection, the code is as follows: 

 

#include <stdio.h># include "lwip/api.h" int main() {  struct netconn *conn;  conn = netconn_new(NETCONN_UDP);     }   

 

But seems like I&#39;m doing something wrong, because it&#39;s giving me this error: 

 

" undefined reference to `netconn_new&#39; " 

 

I&#39;ve tryied with all the connection types with the same result, and seems like they are all defined in "lwip/api.h". Don&#39;t know what I&#39;m doing wrong, can someone help me??? 

 

Thanks!!!!!
0 Kudos
15 Replies
Altera_Forum
Honored Contributor II
946 Views

You'll find better help on the lwIP forum: 

 

https://savannah.nongnu.org/mail/?group=lwip
0 Kudos
Altera_Forum
Honored Contributor II
946 Views

Hi, I have same problem even if I add directory to "include paths" in NIOS II IDE ! 

 

It is NOT a lwip problem, It is a nios ii ide problem 

Nios II IDE lets me go to api.h of the lwip when i double-click on the file in "outline" window. 

 

EDIT : :rolleyes:  

I had to :  

  • open properties window, 

  • go to "C/C++ Build" tab, 

  • "configuration settings", 

  • "tool settings" tab, 

  • select "general" under "Nios II compiler", 

  • "include path", add the path. 

 

 

It is very bad that i have to do so many manipulations ! 

But I hope it helps you. 

 

EDIT 2 : similar problem on ip_addr.h :mad: :mad:
0 Kudos
Altera_Forum
Honored Contributor II
946 Views

It's not a NIOS IDE problem - all tools need# include paths to find user-supplied H files. I've had to add search paths for 3 different tools I've used lwIP with. Perhaps lwIP could be more friendly and use a "master include", but it doesn't. This doesn't make it an IDE issue. 

 

I agree it's "many manipulations" - that's how Eclipse works. Several companies (including Xilinx) have adopted it for their IDE. So maybe open source isn't better! :) Frankly I like every commercial IDE I've used to date better than Eclipse. 

 

Bill A.
0 Kudos
Altera_Forum
Honored Contributor II
946 Views

I agree that compilation tools needs# include paths but the spécific "include paths" tab in project properties in NIOS II IDE doesn't work well :  

the .h are recognized by editor but not by compiler.  

I think it would be obvious. 

 

many other bugs that harm the use of NIOS II IDE. 

 

with Lwip (version 1.3.1), I have "syntax error" hard to solve. 

 

Wich LwiP works well with NIOS II IDE ? Wich do you use ? 

 

Best regards.
0 Kudos
Altera_Forum
Honored Contributor II
946 Views

 

--- Quote Start ---  

I agree that compilation tools needs# include paths but the spécific "include paths" tab in project properties in NIOS II IDE doesn't work well :  

the .h are recognized by editor but not by compiler.  

I think it would be obvious. 

 

--- Quote End ---  

 

 

I don't follow this - tell me what you mean by not recognized by the compiler. 

 

 

--- Quote Start ---  

 

many other bugs that harm the use of NIOS II IDE. 

 

with Lwip (version 1.3.1), I have "syntax error" hard to solve. 

 

Wich LwiP works well with NIOS II IDE ? Wich do you use ? 

 

--- Quote End ---  

Tell me the error and I'll see if I can help you. I'm using 1.3.1 also. 

 

Bill A.
0 Kudos
Altera_Forum
Honored Contributor II
946 Views

Hi, 

 

First of all, 

I have to make decision between InterNiche Stack and LwIP stack. 

I am using opencores ethernet mac which is tested with InterNiche stack, but i don't know how to make that. 

 

LwIP stack is formerly used in my company but for an old project that used different MAC, NIOS, IDE.... 

 

After I add the path to the include path in build project properties (even if i already add it in include path & symbols), I have errors :  

 

--- Quote Start ---  

Severity and Description Path Resource Location Creation Time Id 

D:/essai_ethernet/IP/lwip/src/include/lwip/api.h error: syntax error before '}' token essai_ethernet line 159 1253277801181 32122 

 

--- Quote End ---  

 

 

When I double-click on this error, it doesn't lead me to the error location, I have to manually edit file and go to the error line. 

"go to error location" works well with opencores ethernet files (component in fpga and then in system library)

 

I suspect bad syntax handler with some C keywords like struct, typedef, enum...

I say that because I had experienced troubles with typedef keyword. 

 

If it is too hard to implemant LwIP, I will have a look at InterNiche. 

 

Maybe those include problems is related to your first post : undefined reference to netconn_new() 

OR NETCONN_UDP is badly defined (exists in api.h ;-))
0 Kudos
Altera_Forum
Honored Contributor II
946 Views

 

--- Quote Start ---  

Hi, 

 

First of all, 

I have to make decision between InterNiche Stack and LwIP stack. 

I am using opencores ethernet mac which is tested with InterNiche stack, but i don't know how to make that. 

 

LwIP stack is formerly used in my company but for an old project that used different MAC, NIOS, IDE.... 

 

--- Quote End ---  

 

 

We chose lwIP because it's smaller, faster, and more reliable (and the support behind it is good). It's also free but this was a bonus - that didn't matter. The Altera TSE driver is slow and inefficient - and buggy. If you need IPv6 then lwIP is not an option for you. 

 

 

--- Quote Start ---  

 

After I add the path to the include path in build project properties (even if i already add it in include path & symbols), I have errors :  

 

When I double-click on this error, it doesn't lead me to the error location, I have to manually edit file and go to the error line. 

"go to error location" works well with opencores ethernet files (component in fpga and then in system library)

 

--- Quote End ---  

OK, well, I see this with all errors in Eclipse - so this is an IDE problem. I've just gotten used to it I suppose. :mad: 

 

--- Quote Start ---  

 

I suspect bad syntax handler with some C keywords like struct, typedef, enum...

I say that because I had experienced troubles with typedef keyword. 

 

If it is too hard to implemant LwIP, I will have a look at InterNiche. 

 

--- Quote End ---  

It may be hard to implement, but it will be worth it. 

 

 

--- Quote Start ---  

 

Maybe those include problems is related to your first post : undefined reference to netconn_new() 

OR NETCONN_UDP is badly defined (exists in api.h ;-)) 

--- Quote End ---  

This wasn't my post, but I do see the error tracking bug you're talking about. 

 

Bill A.
0 Kudos
Altera_Forum
Honored Contributor II
945 Views

Hi,  

 

--- Quote Start ---  

If you need IPv6 then lwIP is not an option for you. 

--- Quote End ---  

 

LwIP 1.3.1 include ipV6. So it is an option. Sorry if I didn't understood :-) 

 

Do you use Nios II IDE eclipse to compile your project ? You seem to successfully implement lwip. 

Do you work with standalone lwIP ? 

Could you tell us how to implement lwip in NIOS II ? how easy/hard is it ?
0 Kudos
Altera_Forum
Honored Contributor II
945 Views

 

--- Quote Start ---  

Hi,  

 

LwIP 1.3.1 include ipV6. So it is an option. Sorry if I didn't understood :-) 

 

--- Quote End ---  

 

 

Sorry but IPv6 is not fully developed in lwIP - it was started but not completed. They are looking for someone to continue with it and develop it if you're interested in contributing to lwIP. :) 

 

 

--- Quote Start ---  

 

Do you use Nios II IDE eclipse to compile your project ? You seem to successfully implement lwip. 

Do you work with standalone lwIP ? 

 

--- Quote End ---  

Yes, I use the NIOS II to build an lwIP library and my Cyclone III/NIOS II application using lwIP. lwIP source code builds fine in NIOS II Eclipse without changes to the base code. 

 

 

--- Quote Start ---  

 

Could you tell us how to implement lwip in NIOS II ? how easy/hard is it? 

--- Quote End ---  

It wasn't as easy as it could be because the TSE driver directly interfaces into some Interniche code and structures. ins_tse_mac.c is the main file that you change for lwIP. Where it gets packets and stores into an Interniche-based queue, you would add packets to an lwIP pbuf pool to be picked up by code calling low_level_input (see ethernetif.c). lwIP low_level_output sends a packet - you can use tse_raw_send in ins_tse_mac.c to do that - with some changes. 

 

As we don't use an OS (Interniche recommends uc/OS-II although there is a "super-loop" mode that you may find more information about) our driver is custom compared to a more general driver so it should be easier for you than it was for me. We also had to have very high bandwidth requirements for our application. We have the ability to generate Internet checksums in hardware as we receive data from hardware connected to the Cyclone III to send (by UDP) so we also had to customize lwIP in several places to accommodate this. 

 

Bill A.
0 Kudos
Altera_Forum
Honored Contributor II
945 Views

Hi, thanks for answer. 

 

In LwIP 1.3.1, it seems to lack some file like :  

  • lwipopts.h to Define# define NO_SYS 1, etc 

  • arch/cc.h to Define generic types used in lwIP 

 

That answers to my "syntax errors".I look for examples like lwIPv1_1.zip in niosforum.com http://www.niosforum.com/pages/project_details.php?p_id=68&t_id=17 which provides a few answers. 

 

I am new to IP stacks and have a very light knowledge of all about networking. 

I had hoped that it must be simple because Ethernet is wiiiiiiiiiiiiiiidely used. As for SD cards. 

 

I look at LwIP wiki, go to "get started" and wasted :huh:. 

 

You have succeeded in make LWIP working.  

Could you suggest me/us some good documents, please ? in order to start with a good point. 

0 Kudos
Altera_Forum
Honored Contributor II
946 Views

 

--- Quote Start ---  

Hi, thanks for answer. 

 

In LwIP 1.3.1, it seems to lack some file like :
  • lwipopts.h to Define# define NO_SYS 1, etc 

  • arch/cc.h to Define generic types used in lwIP
 

--- Quote End ---  

 

 

These are user supplied files - copy and past opts.h into lwipopts.h and make change as necessary for your system (depends on amount of memory and other lwIP features that you require). cc.h is your platform dependent include file - start with another from the contrib folder as a starting point for yours. 

 

--- Quote Start ---  

 

That answers to my "syntax errors".I look for examples like lwIPv1_1.zip in niosforum.com http://www.niosforum.com/pages/project_details.php?p_id=68&t_id=17 which provides a few answers. 

 

I am new to IP stacks and have a very light knowledge of all about networking. 

I had hoped that it must be simple because Ethernet is wiiiiiiiiiiiiiiidely used. As for SD cards. 

 

--- Quote End ---  

You don't need to know about networking to bring lwIP up - but you must get an ethernet driver working. The Altera tse driver is a start and it's not super hard to get that talking through lwIP's low_level_input and low_level_output. 

 

If you want a standalone working stack already for NIOS II like Interniche is - that's only possible if you find someone who can provide a working build of everything. One issue I don't know about is if someone has an lwIP ethernet driver based on the Interniche/Altera code (most of the code is altera's), what can be redistributed without violating licenses? 

 

--- Quote Start ---  

 

I look at LwIP wiki, go to "get started" and wasted :huh:. 

 

--- Quote End ---  

Yeah, it could be better. 

 

--- Quote Start ---  

 

You have succeeded in make LWIP working.  

Could you suggest me/us some good documents, please ? in order to start with a good point. 

 

--- Quote End ---  

The lwIP Wiki and the mailing lists documented here is a start: http://www.nongnu.org/lwip/ 

 

I will see if I can throw together a "bridge" file from the Altera driver to lwIP's ethernetif interface. No promises... 

 

Bill A.
0 Kudos
Altera_Forum
Honored Contributor II
946 Views

Great thanks ! 

 

 

--- Quote Start ---  

cc.h is your platform dependent include file - start with another from the contrib folder as a starting point for yours. 

--- Quote End ---  

 

I found http://cvs.savannah.gnu.org/viewvc/contrib/ports/?root=lwip 

is there a nios ii port ? All I have found is that Altera don't use LwIP anymore. 

For cc.h, we have just to typedef u8_t; s8_t; u16_t; s16_t; u32_t; s32_t; # define BYTE_ORDER LITTLE_ENDIAN 

 

You mentioned Altera TSE driver, but it is "designed" for InterNiche stack and ucOS II. Not simple.
0 Kudos
Altera_Forum
Honored Contributor II
946 Views

 

--- Quote Start ---  

You mentioned Altera TSE driver, but it is "designed" for InterNiche stack and ucOS II. Not simple. 

--- Quote End ---  

 

Are looking for a driver for lwip for an Altera 10/100MbS MAC or one for the Altera TSE (100/1000MbS) MAC? I see another post of yours that mentions 10/100. 

 

Bill
0 Kudos
Altera_Forum
Honored Contributor II
946 Views

Hi, I xas looking a LWIP driver for Opencores Ethernet MAC. Not TSE MAC, neither LAN91c911.

0 Kudos
Altera_Forum
Honored Contributor II
946 Views

Ok, well I did the port for the TSE since I didn't see the OpenCores Ethernet MAC mentioned in an early post. The TSE does work in 10/100 mode (I'm not positive about the 10MbS support). 

 

Bill
0 Kudos
Reply