Forum Discussion
Altera TSE driver and example program for lwIP (1.3.2)
After many many requests and complaints about lack of support and/or documentation for support of lwIP for the Altera TSE, I have developed a drop-in TSE driver and example program and made this available to the NIOS II community. This was done for NIOS II 8.1 SP0.01. I don't expect difficulty with version 9.x.
This is for the latest version of lwIP (the latest is as of this post) for a minimal program and HTTP server based on the http server in the lwIP contrib folder. The lwIP TSE driver uses the altera_avalon_tse driver and SGDMA as-is. There is a complete (as in 41-step) set of instructions on creating the project and example program. More information and the link to the driver is available here: http://lwip.wikia.com/wiki/available_device_drivers#lwip_1.3.2 Please direct any questions, changes for NIOS II 9.1, or comments to this thread. 12-16-2010 update: This example works with NIOS Version 10.0 with some tweaks to the procedure to create the project. Also, a lwIP 1.4 release candidate has been out for a while and it drops into this example (in place of 1.3) without changes. Bill257 Replies
- Altera_Forum
Honored Contributor
Tomas, I have# include "lwip/tcp_impl.h" in my main.c. In lwIP 1.3.2 TCP_TMR_INTERVAL was defined in tcp.h, but starting from lwIP 1.4.0rc1 this definition have been moved into tcp_impl.h. I don’t know why.
- Altera_Forum
Honored Contributor
Seems like this causes an error-chain :)
Now I get error here:
Error:# if LWIP_TIMERS && (MEMP_NUM_SYS_TIMEOUT < (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_SUPPORT)) # error "MEMP_NUM_SYS_TIMEOUT is too low to accomodate all required timeouts"# endif
Either I need to increase MEMP_NUM_SYS_TIMEOUT or disable some options like DHCP, etc. I choose first one and increase MEMP_NUM_SYS_TIMEOUT from 3 to 5. Then I get these errors:src/core/init.c:152:4: error:# error "MEMP_NUM_SYS_TIMEOUT is too low to accomodate all required timeouts"
sys_now() is prototyped in sys.h, but I can't find the function itself. P.S. Maybe someone use lwIP with MicroC/OS-II?obj/src/core/timers.o: In function `sys_timeouts_init': C:\Projects\cycloneIII_3c120_dev_niosII\software\lwIP_NIOS_II_Example/src/core/timers.c:245: undefined reference to `sys_now' obj/src/core/timers.o: In function `sys_check_timeouts': C:\Projects\cycloneIII_3c120_dev_niosII\software\lwIP_NIOS_II_Example/src/core/timers.c:365: undefined reference to `sys_now' obj/src/core/timers.o: In function `sys_restart_timeouts': C:\Projects\cycloneIII_3c120_dev_niosII\software\lwIP_NIOS_II_Example/src/core/timers.c:405: undefined reference to `sys_now' collect2: ld returned 1 exit status make: *** Error 1 - Altera_Forum
Honored Contributor
I have no experience with UCOS. Does it work without OS and with# define NO_SYS 1 in lwipopts.h?
- Altera_Forum
Honored Contributor
--- Quote Start --- I have no experience with UCOS. Does it work without OS and with# define NO_SYS 1 in lwipopts.h? --- Quote End --- No, then I get this:
Maybe I should try 1.32, since the driver is old? Or maybe I should use hello world example with RTOS enabled? One guy here (afaik) on this thread succeeded running 1.4 or 1.4rc1, so I hope he could help me here. Ofcourse it would be perfect to get an example of working system with uC/OS-II and lwIP, but I still hope to do it myself.**** Build of configuration Nios II for project lwIP_NIOS_II_Example **** make all Info: Building ../lwIP_NIOS_II_Example_bsp make --no-print-directory -C ../lwIP_NIOS_II_Example_bsp Info: Compiling alteraTseEthernetif.c to obj/alteraTseEthernetif.o nios2-elf-gcc -xc -MP -MMD -c -I../lwIP_NIOS_II_Example_bsp/drivers/inc -I../lwIP_NIOS_II_Example_bsp/HAL/inc -I../lwIP_NIOS_II_Example_bsp -I../lwIP_NIOS_II_Example_bsp/drivers/inc -I. -Isrc/include -Isrc/include/ipv4 -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_INSTRUCTION_EMULATION -DALTERA_TRIPLE_SPEED_MAC -DALT_SINGLE_THREADED -O0 -g -Wall -EL -mno-hw-div -mhw-mul -mno-hw-mulx -o obj/alteraTseEthernetif.o alteraTseEthernetif.c In file included from alteraTseEthernetif.c:47: src/include/lwip/sys.h:107: error: expected ')' before '*' token src/include/lwip/sys.h:110: error: expected ')' before '*' token src/include/lwip/sys.h:113: error: expected ')' before '*' token src/include/lwip/sys.h:116: error: expected ')' before '*' token src/include/lwip/sys.h:119: error: expected ')' before '*' token src/include/lwip/sys.h:123: error: expected ')' before '*' token src/include/lwip/sys.h:142: error: conflicting types for 'sys_arch_sem_wait' ./arch/sys_arch.h:60: error: previous declaration of 'sys_arch_sem_wait' was here src/include/lwip/sys.h:185: error: conflicting types for 'sys_arch_mbox_fetch' ./arch/sys_arch.h:57: error: previous declaration of 'sys_arch_mbox_fetch' was here alteraTseEthernetif.c: In function 'low_level_init': alteraTseEthernetif.c:83: warning: value computed is not used make: *** Error 1 - Altera_Forum
Honored Contributor
Tomas, I get the same errors if I define NO_SYS 0 instead of 1. Verify, that you have
# define NO_SYS 1 in lwipopts.h and that this macro is not redefined in your code or compiler args. - Altera_Forum
Honored Contributor
--- Quote Start --- Tomas, I get the same errors if I define NO_SYS 0 instead of 1. Verify, that you have # define NO_SYS 1 in lwipopts.h and that this macro is not redefined in your code or compiler args. --- Quote End --- Yep, I use NO_SYS 1, but the error occoured is about sys_now() function.
This function has prototype in sys.h header file, but there is no function itself anywhere... Could You please check where sys_now() function exist in Your project files? Thanks. BR, Tomas D.**** Build of configuration Nios II for project lwIP_NIOS_II_Example **** make all Info: Building ../lwIP_NIOS_II_Example_bsp make --no-print-directory -C ../lwIP_NIOS_II_Example_bsp Info: Linking lwIP_NIOS_II_Example.elf nios2-elf-g++ -T'../lwIP_NIOS_II_Example_bsp/linker.x' -msys-crt0='../lwIP_NIOS_II_Example_bsp/obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../lwIP_NIOS_II_Example_bsp -Wl,-Map=lwIP_NIOS_II_Example.map -O0 -g -Wall -EL -mno-hw-div -mhw-mul -mno-hw-mulx -o lwIP_NIOS_II_Example.elf obj/alteraTseEthernetif.o obj/fs.o obj/fsdata.o obj/httpd.o obj/lwip_tse_mac.o obj/main.o obj/src/api/api_lib.o obj/src/api/api_msg.o obj/src/api/err.o obj/src/api/netbuf.o obj/src/api/netdb.o obj/src/api/netifapi.o obj/src/api/sockets.o obj/src/api/tcpip.o obj/src/core/def.o obj/src/core/dhcp.o obj/src/core/dns.o obj/src/core/init.o obj/src/core/ipv4/autoip.o obj/src/core/ipv4/icmp.o obj/src/core/ipv4/igmp.o obj/src/core/ipv4/inet.o obj/src/core/ipv4/inet_chksum.o obj/src/core/ipv4/ip.o obj/src/core/ipv4/ip_addr.o obj/src/core/ipv4/ip_frag.o obj/src/core/mem.o obj/src/core/memp.o obj/src/core/netif.o obj/src/core/pbuf.o obj/src/core/raw.o obj/src/core/snmp/asn1_dec.o obj/src/core/snmp/asn1_enc.o obj/src/core/snmp/mib2.o obj/src/core/snmp/mib_structs.o obj/src/core/snmp/msg_in.o obj/src/core/snmp/msg_out.o obj/src/core/stats.o obj/src/core/sys.o obj/src/core/tcp.o obj/src/core/tcp_in.o obj/src/core/tcp_out.o obj/src/core/timers.o obj/src/core/udp.o obj/src/netif/etharp.o obj/src/netif/ethernetif.o obj/src/netif/ppp/auth.o obj/src/netif/ppp/chap.o obj/src/netif/ppp/chpms.o obj/src/netif/ppp/fsm.o obj/src/netif/ppp/ipcp.o obj/src/netif/ppp/lcp.o obj/src/netif/ppp/magic.o obj/src/netif/ppp/md5.o obj/src/netif/ppp/pap.o obj/src/netif/ppp/ppp.o obj/src/netif/ppp/ppp_oe.o obj/src/netif/ppp/randm.o obj/src/netif/ppp/vj.o obj/src/netif/slipif.o -lm obj/src/core/timers.o: In function `sys_timeouts_init': C:\Projects\cycloneIII_3c120_dev_niosII\software\lwIP_NIOS_II_Example/src/core/timers.c:245: undefined reference to `sys_now' obj/src/core/timers.o: In function `sys_check_timeouts': C:\Projects\cycloneIII_3c120_dev_niosII\software\lwIP_NIOS_II_Example/src/core/timers.c:365: undefined reference to `sys_now' obj/src/core/timers.o: In function `sys_restart_timeouts': C:\Projects\cycloneIII_3c120_dev_niosII\software\lwIP_NIOS_II_Example/src/core/timers.c:405: undefined reference to `sys_now' collect2: ld returned 1 exit status make: *** Error 1 - Altera_Forum
Honored Contributor
Tomas, this function is not defined in my project. The only reference to sys_now() in tcp_out.c is removed by preprocessor due to LWIP_TCP_TIMESTAMPS is 0, and 3 references in timers.c — due to LWIP_TIMERS is 0. In lwIP 1.4.0rc1 LWIP_TIMERS is defined in lwIP/src/include/timers.h as
# define LWIP_TIMERS (!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS)) So, you should try # define NO_SYS_NO_TIMERS 1 in lwipopts.h. I have this# define in my code (probably added while upgrading from v.1.3.2). - Altera_Forum
Honored Contributor
Hm, there's no such define on lwipopts.h in 1.40.
Could You please check whats defined here:
If I leave this number 3, I get the fallowing error:#define MEMP_NUM_SYS_TIMEOUT 3
So I've increased it to 5. Maybe I should write to lwIP mailing list? Edit: commenting out those three lines of timers lets the code to compile. The system starts, sees that there is link (I've checked removing cable and it catches that there's no link), but arp doesn't respond. No arp - no ping response. If I create my own function called sys_now() which returns 32bit variable with a number, increased every main cycle - the results are the same.src/core/init.c:152:4: error:# error "MEMP_NUM_SYS_TIMEOUT is too low to accomodate all required timeouts" make: *** Error 1 - Altera_Forum
Honored Contributor
Tomas,
1)# define MEMP_NUM_SYS_TIMEOUT 3 works fine for me 2) You should ADD# define NO_SYS_NO_TIMERS 1 into lwipopts.h (for lwIP-1.3.2 this was not necessary) - Altera_Forum
Honored Contributor
--- Quote Start --- 2) You should ADD# define NO_SYS_NO_TIMERS 1 into lwipopts.h (for lwIP-1.3.2 this was not necessary) --- Quote End --- This line helped to solve compilation errors. Now the stack compiles, but it doesn't respond to ARP (and PING) requests. I am sure my design is OK, because Simple Socket Server and Web Server examples are working fine. I suppose the problem is RGMII interface. Edit: yep, that was RGMII issue - solved now by adding tse_my_system.c file from "Simple Socket Server (RGMII) example". The stack works, thanks for help! Edit2: Now would be cool to run this on uCOS RTOS :-) BR, Tomas D.