Forum Discussion
Altera_Forum
Honored Contributor
16 years agoAltera 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
Hi!
Enyone can explain me how to execute the points 26 - 39 of the lwIP 1.3.2 Altera TSE driver for lwIP 1.3.2 ReadMe in NiosII 9.1 EDS? The points are: 26. Select C/C++ Build 27. Select General 28. Add Include Path ${workspace_loc:/altera.components/Nios II Software Packages/altera_iniche/UCOSII/inc} 29. Add Include Path ${workspace_loc:/lwIP_NIOS_II_Example/lwIP/src/include} 30. Add Include Path ${workspace_loc:/lwIP_NIOS_II_Example/lwIP/src/include/ipv4} 31. Select Configuration Release from the pull-down 32. Select Preprocessor 33. Add Undefined Symbols: LWIP_NOASSERT 34. Add Undefined Symbols: LWIP_ERROR 35. Select General 36. Add Include Path ${workspace_loc:/altera.components/Nios II Software Packages/altera_iniche/UCOSII/inc} 37. Add Include Path ${workspace_loc:/lwIP_NIOS_II_Example/lwIP/src/include} 38. Add Include Path ${workspace_loc:/lwIP_NIOS_II_Example/lwIP/src/include/ipv4} 39. Select Configuration Debug from the pull-down Sorry, but I'm new and thanks for help! - Altera_Forum
Honored Contributor
Well, you need to do step 25 and you'll see "C/C++ Build" mentioned in step 26.
25. right-click project lwip_nios_ii_example and select properties Bill - Altera_Forum
Honored Contributor
Thank you for your reply Bill!
The point 25 is obvious, but after i don't know shere include this paths: 28. Add Include Path ${workspace_loc:/altera.components/Nios II Software Packages/altera_iniche/UCOSII/inc} 29. Add Include Path ${workspace_loc:/lwIP_NIOS_II_Example/lwIP/src/include} 30. Add Include Path ${workspace_loc:/lwIP_NIOS_II_Example/lwIP/src/include/ipv4} Under C/C++ option there are many options, and I think that the correct one is the "Path and Symbols". But there are many tabs, like "Includes", "Library path", "References", ... Which is the correct one?! And then: where I can find the "Configuration Release" form point 31: 31. Select Configuration Release from the pull-down? And why the points 27-30 are egual to points 35-38? Thanks!!! Have a nice day! - Altera_Forum
Honored Contributor
--- Quote Start --- Thank you for your reply Bill! --- Quote End --- You're welcome. --- Quote Start --- The point 25 is obvious, but after i don't know shere include this paths: 28. Add Include Path ${workspace_loc:/altera.components/Nios II Software Packages/altera_iniche/UCOSII/inc} 29. Add Include Path ${workspace_loc:/lwIP_NIOS_II_Example/lwIP/src/include} 30. Add Include Path ${workspace_loc:/lwIP_NIOS_II_Example/lwIP/src/include/ipv4} Under C/C++ option there are many options, and I think that the correct one is the "Path and Symbols". But there are many tabs, like "Includes", "Library path", "References", ... Which is the correct one?! --- Quote End --- Stay on "Tool Settings" tab. Use General for Nios II Compiler You'll see Include paths. Use the Add button. --- Quote Start --- And then: where I can find the "Configuration Release" form point 31: 31. Select Configuration Release from the pull-down? --- Quote End --- Right above the tabs in this same dialog. --- Quote Start --- And why the points 27-30 are egual to points 35-38? --- Quote End --- Because you need the include paths for Debug and Release builds. --- Quote Start --- Thanks!!! Have a nice day! --- Quote End --- Thank you - you do the same. :) Bill - Altera_Forum
Honored Contributor
Hi guys.
I am still trying to use the example, which has been uploaded by BillA (thank you very much), but i am in trouble. Finally,i know the port number to connect.But, as i understand,this example is low-level example.I mean,that the packets, which i catch, i catch them not on Transport layer(TCP, UDP).I catch them on IP layer or even ARP. Is it correctly? Another question. As i understand, i catch the packet in "ethernetif_input" function and i am trying to watch with breakpoints the content of packet, but i do not see nothing. What am i doing not correctly? Thanks,Slava. - Altera_Forum
Honored Contributor
--- Quote Start --- Hi guys. I am still trying to use the example, which has been uploaded by BillA (thank you very much), but i am in trouble. Finally,i know the port number to connect.But, as i understand,this example is low-level example.I mean,that the packets, which i catch, i catch them not on Transport layer(TCP, UDP).I catch them on IP layer or even ARP. Is it correctly? --- Quote End --- You're welcome (for the example). You catch the packets you want by specifying the callback. For example, if you call tcp_recv you will be called back with data as it arrives from the connection on the pcb. There is also udp_recv and raw_recv if you want those callbacks. raw has to be enabled with a# define and only it will allow seeing all packets. I've never had reason to use this. --- Quote Start --- Another question. As i understand, i catch the packet in "ethernetif_input" function and i am trying to watch with breakpoints the content of packet, but i do not see nothing. What am i doing not correctly? --- Quote End --- If you put breakpoint on: ethhdr = p->payload; and it doesn't stop here, then you are not receiving packets. Run in Debug build and look at the PHY output messages to be sure the PHY initializes OK. If you get through that, I would expect the TSE to be OK but if it won't breakpoint you're not getting any packets. You should see broadcast packets at all times so if you're on a network you should see packets without doing anything. If you are direct to a PC I still think you see a few broadcasts. BillA - Altera_Forum
Honored Contributor
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. Without any modifications the example runs on DBM3C40 devboard (Cyclone III + Marvell 88E1119R PHY) at 100Mbit. It gets address via DHCP and serves nice html page from port 80. Unfortunately the board hangs at DHCP stage if I plug it into 1000M network. The output is following: INFO : TSE MAC 0 found at address 0x00002000 INFO : Multi Channel = No INFO : MDIO Shared = No INFO : MAC Type = 10/100/1000 Ethernet MAC INFO : MAC Address = 0x00002000 INFO : MAC Device = tse_mac_device[0] ERROR : MAC Group[0] - No PHY connected! ERROR : PHY[0.0] - No PHY connected! Speed = 100, Duplex = Full Waiting for link...OK Waiting for DHCP IP address... I suspect that 1000M operation or autonegotiation must be configured somehow, but I have zero experience in Ethernet development and don't know how to move on. Any help will be appreciated. Thank you in advance, Igor - Altera_Forum
Honored Contributor
Thank you for your reply.regarding to second question: it works exactly as you have described.
--- Quote Start --- You're welcome (for the example). You catch the packets you want by specifying the callback. For example, if you call tcp_recv you will be called back with data as it arrives from the connection on the pcb. There is also udp_recv and raw_recv if you want those callbacks. raw has to be enabled with a# define and only it will allow seeing all packets. I've never had reason to use this. --- Quote End --- Regarding to the first question: As i understand, i must to specify the callback function. At which stage do i must to do it? In your code(example),as i uns=derstand, i must to insert reading function where i put stars.Is it correct? // Process lwIP timer dependent code if(lwipProcessTimerFlag) lwipProcessTimers(); // Poll lwIP for incoming packets. ethernetif_input(&alteraTseNetif); *************************** Where i puted the stars, do i must to specify the callback function? - Altera_Forum
Honored Contributor
--- Quote Start --- Hi! Unfortunately the board hangs at DHCP stage if I plug it into 1000M network. The output is following: INFO : TSE MAC 0 found at address 0x00002000 INFO : Multi Channel = No INFO : MDIO Shared = No INFO : MAC Type = 10/100/1000 Ethernet MAC INFO : MAC Address = 0x00002000 INFO : MAC Device = tse_mac_device[0] ERROR : MAC Group[0] - No PHY connected! ERROR : PHY[0.0] - No PHY connected! Speed = 100, Duplex = Full Waiting for link...OK Waiting for DHCP IP address... --- Quote End --- In altera_avalon_tse.h try changing the# define for ALTERA_CHECKLINK_TIMEOUT_THRESHOLD to 5000000 --- Quote Start --- I suspect that 1000M operation or autonegotiation must be configured somehow, but I have zero experience in Ethernet development and don't know how to move on. Any help will be appreciated. --- Quote End --- I think perhaps it's timing out before it negotiates? You can also try increasing the other timeouts in this header file (in the same location of the file). Bill - Altera_Forum
Honored Contributor
--- Quote Start --- Thank you for your reply.regarding to second question: it works exactly as you have described. Regarding to the first question: As i understand, i must to specify the callback function. At which stage do i must to do it? In your code(example),as i uns=derstand, i must to insert reading function where i put stars.Is it correct? // Process lwIP timer dependent code if(lwipProcessTimerFlag) lwipProcessTimers(); // Poll lwIP for incoming packets. ethernetif_input(&alteraTseNetif); *************************** Where i puted the stars, do i must to specify the callback function? --- Quote End --- This http code in this example is also an example that shows how to handle the callback from accept and how to set the tcp_recv. It also shows how to process received data. You should model any code that will make a connection and send and receive data like this one does. Bill