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
--- Quote Start --- ERROR : MAC Group[0] - No PHY connected! ERROR : PHY[0.0] - No PHY connected! Speed = 100, Duplex = Full --- Quote End --- WAIT!!! I missed this - the PHY is not detected. In 8.1 (which I'm still using) the Marvell 88E1119R is not supported. If it's not supported in altera_avalon_tse.h/.c you will have to add it. Model the other PHY's# defines and the initialization structure table to add support for the 88E1119R. The OUI model and rev are:
Bill Aenum { MV88E1119_OUI = 0x005043, MV88E1119_MODEL = 0x28 , MV88E1119_REV = 0x2 }; - Altera_Forum
Honored Contributor
You can also call alt_tse_phy_add_profile (I'm not sure when) to add the PHY without customizing altera_avalon_tse.c/.h.
Bill - Altera_Forum
Honored Contributor
--- Quote Start --- Hi! Many thanks to Bill for useful example and step-by-step pass-throw. I successfully compiled lwIP_NIOS_II_Example in EDS 10.0. A couple of minor issues I faced with: 1) steps 25-40. I tried to set paths and symbols through the GUI, but this didn't work. The workaround was to edit lwIP_NIOS_II_Example/Makefile manually. Also, to get “INFO” output like in Readme.txt ALT_DEBUG must be defined for lwIP_NIOS_II_Example_bsp project. 2) TSE-related components in SOPC must have standard names: 'tse_mac', 'sgdma_tx', 'sgdma_rx' and 'descriptor_memory'. If different names are used the code successfully compiles, but does not function. --- Quote End --- Hi Igor! Can you post your lwIP_NIOS_II_Example/Makefile please? Thanks! - Altera_Forum
Honored Contributor
--- Quote Start --- You can also call alt_tse_phy_add_profile (I'm not sure when) to add the PHY without customizing altera_avalon_tse.c/.h. Bill --- Quote End --- Bill! I've done as you suggested and now the driver detects my PHY and correctly reports network speed. DHCP does not work at 1000M yet, but I think this might be a hardware problem, probably with clock phase. Trying to make out with this... Thank you for your help, Igor - Altera_Forum
Honored Contributor
--- Quote Start --- Hi Igor! Can you post your lwIP_NIOS_II_Example/Makefile please? Thanks! --- Quote End --- Attached. Diff at line 7 only: ALT_INCLUDE_DIRS := . ./lwIP/src/include ./lwIP/src/include/ipv4 - Altera_Forum
Honored Contributor
Guys,I am in troubles.
First of all,I cannot get this example working. Basically, I need to build application, similar to FTP. Application, which has two(2) open connections with two ports.Over one of ports, received commands and sent responses. Over second port,I send data.But this is in general. At this stage I want to build application (based on BillA's example), which shall be able to receive packets from other side(PC,for example). When i use BillA's example,and there is connection to external net,i receive the packets,exactly like BillA sad, but it happens not on Transport layer(not by tcp_... functions).I think,it happens on IP leyer(by netif... functions). If i want to receive packets, do i need to define callback functions and why? If YES, how to do it? Somebody can show me on example.I do not need the application,i need a little push,some help. P.S. When i tried to fined the problem, i fount,that in httpd.c file in httpd_init there is some error(maybe it is not an error and it is suppose to be like this,but i think there is an error). In line: pcb = tcp_listen(pcb); tcp_listen function returns NULL and think it is must be different. Thank,you guys!!!!!!!!!!!!!! - Altera_Forum
Honored Contributor
--- Quote Start --- Guys,I am in troubles. First of all,I cannot get this example working. Basically, I need to build application, similar to FTP. Application, which has two(2) open connections with two ports.Over one of ports, received commands and sent responses. Over second port,I send data.But this is in general. At this stage I want to build application (based on BillA's example), which shall be able to receive packets from other side(PC,for example). When i use BillA's example,and there is connection to external net,i receive the packets,exactly like BillA sad, but it happens not on Transport layer(not by tcp_... functions).I think,it happens on IP leyer(by netif... functions). --- Quote End --- Why do you say this? If you use the code in httpd.c, you see how to make a connection, handle incoming data (replace http_recv with your function), send data (send data first and then send subsequent data (if any) using the http_sent callback). HTTP runs on top of TCP so this is using the TCP transport. If you want a reliable connection this is how you should do it. --- Quote Start --- If i want to receive packets, do i need to define callback functions and why? --- Quote End --- Yes. Because the stack runs and gets data at any time so you have to be expected to be told when data is there - at any time. You response to that data (your commands) by sending data out (on the same connection or another if you choose). --- Quote Start --- If YES, how to do it? Somebody can show me on example.I do not need the application,i need a little push,some help. --- Quote End --- Use the code in httpd.c - replace http_recv with your incoming data handler, and send data as is done there - use http_send and use the http_sent callback if one call to send data isn't enough (you cannot control this because of the tcp_sndbuf check so implement sending just as is done in httpd.c). --- Quote Start --- P.S. When i tried to fined the problem, i fount,that in httpd.c file in httpd_init there is some error(maybe it is not an error and it is suppose to be like this,but i think there is an error). In line: pcb = tcp_listen(pcb); tcp_listen function returns NULL and think it is must be different. --- Quote End --- Maybe you need to change LWIPOPTS.h to allow for more TCP connections or PCBs? It is an error to return NULL and you need to debug why but my guess is not enough resources for your call. Bill A - Altera_Forum
Honored Contributor
Actually, when i connect my board(at this stage i use Cyclone III Development Kit board), i do not see it on network sniffer.Even on ARP layer.
- Altera_Forum
Honored Contributor
Do you know the hardware is OK? Can you build simple_socket_server with Interniche and be sure board talks and connects? Several people have reported that this example works as-is, so if it doesn't, I wouldn't be looking into lwIP or this example but deeper into the hardware (PHY, MAC, SGDMA, SOPC configuration, etc...).
Bill - Altera_Forum
Honored Contributor
I am using Altera evaluation board,so I think,that HW is OK.