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 --- Rene, PHY is managed by altera_avalon_tse.c, not by lwip. To enable debug output compile your BSP with -dALT_DEBUG. --- Quote End --- Where do you enable this? When I change -g to -dALT_DEBUG in the debug option, I get this error when I compile:cc1.exe: warning: unrecognized gcc debugging option: _ cc1.exe: warning: unrecognized gcc debugging option: U - Altera_Forum
Honored Contributor
I have this under "NIOS II BSP Properties" - Flags: Defined Symbols.
I use -DALT_DEBUG. I don't know if it's case sensitive -dALT_DEBUG may not work. Bill - Altera_Forum
Honored Contributor
--- Quote Start --- I use -DALT_DEBUG. I don't know if it's case sensitive -dALT_DEBUG may not work. --- Quote End --- Yes, it must be -DALT_DEBUG. Options are case sensitive. - Altera_Forum
Honored Contributor
Thanks. I am running the example on a custom board with 88E1111 PHY and Cyclone III chip. I'm having a problem with the program crashing at the start and haven't been able to track down the problem with debug. I've taken out the timer function and input polling function to try and track down the problem so all the main loop is doing right now is printing a message every 250 ms.
It reaches the main loop, goes through the loop a few times, then the whole thing dies within 5 seconds. Does anyone have any suggestions for tracking down what is causing this problem? I am also turned off DHCP and the BUILD_HTTPD part. I am on an isolated network. My board is connected to a router by itself so no traffic coming or going. Here is the output by the way. The "at 250" is the print I added. There are several more before it crashes.
Edit: I have tracked down to this:Running... INFO : TSE MAC 0 found at address 0x0c000000 INFO : PHY Marvell 88E1111 found at PHY address 0x12 of MAC Group INFO : PHY - Automatically mapped to tse_mac_device INFO : PHY - Restart Auto-Negotiation, checking PHY link... INFO : PHY - Auto-Negotiation PASSED INFO : PHY - Checking link... INFO : PHY - Link established INFO : PHY - Speed = 100, Duplex = Full Waiting for link...OK IP address: 192.168.1.100 at 250
in netif.c. If I comment this out, the program doesn't crash (but doesn't init properly obviously). Edit again: Sorry for the multiple edits but I'm working on this right now in case that isn't obvious :cool: I've traced the problem down to this:if (init(netif) != ERR_OK) { return NULL; }
in lwip_tse_mac.c. So it seems there is a problem with the RX SGDMA but I am at a loss for what that could be. Thanks again for any help that you can offer. I am not very experienced with the ethernet applications for FPGA platforms.tse_sgdma_read_init(&tse); - Altera_Forum
Honored Contributor
Hi guys,
I'm not a software person. I have a custom board with all needed hardware and i'm able to run an example connected with Altera driver and i'm using lwip-1.4.0. I'm connecting my board directly to my PC (no DHCP) and I can see in "Network Connections" in Windows that i'm connected successfully. And I'm getting standard output on Nios 2 IDE console. But I want to do something more. First I would like to ping my board from the windows console. when I do "ping 192.168.1.100" it says that request is timed out. 1. Do i need to add something more to the Altera driver example to be able to ping? I do have contrib-1.4.0 folder and there is a ping application there, i've added 2 files to my altera driver example but the thing is still not working. 2. Do i need to change my main.c file? What should i add there? The third question - i would like to use httpserver_raw application to show the web-page on my PC. What should i do to be able to do this? Best Regards, uilka_b - Altera_Forum
Honored Contributor
How do You guys start all the program if the ethernet cable is unplugged? Seems like lwIP then waits in a while forever...
- Altera_Forum
Honored Contributor
--- Quote Start --- How do You guys start all the program if the ethernet cable is unplugged? Seems like lwIP then waits in a while forever... --- Quote End --- Socrates, I’ve attached snapshots from my working code as a demo. I use standard lwip timer to check ethernet link periodically and call netif_set_link_up() / netif_set_link_down() when appropriate. Other tasks may be scheduled through sys_timeout() or called from the loop in main(). Feel free to ask for clarification. Igor - Altera_Forum
Honored Contributor
For those who uses sys_timeout() as a general purpose timer -
I’ve found that under certain circumstances lwip timeouts become extremely inaccurate. The reason is that sys_timeout() effectively schedules the handler not relative to the current time (result of sys_now()), but relative to the moment, when previous handler was called (stored in timers.c: static u32_t timeouts_last_time) This does not affect internal lwip timers because they always reschedule themselves inside timeout handler routine, i.e. when timeouts_last_time is equal to sys_now(). On the contrary, if one calls sys_timeout() in arbitrary moment in time, say, inside UDP packet handler, difference between sys_now() and timeouts_last_time may be large. In such a case effective timeout value will be shorter by (sys_now() - timeouts_last_time) and all subsequent timeouts will be offset by the same value. This can be fixed at the cost of extra sys_now() call by inserting msecs += sys_now() - timeouts_last_time; in the very beginning of void sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg). Igor - Altera_Forum
Honored Contributor
I removed (all?) the bugs (The 4 byte SGDMA bug is available in code, but I didn't enable it yet, because I haven't seen any problems) and added multiple PHY support. If you are interested in using this BSP you will have to read the README and the lwip_main.h file to see how you can implement it.
Please have a look at : https://github.com/engineeringspirit/freelwip-nios-ii if you're interested in an FreeRTOS with LwIP BSP for in your Nios II IDE (tested with 11.0 till 12.0sp1) - Altera_Forum
Honored Contributor
Hello,
I have a strange problem with Altera TSE driver and example program for lwIP (1.3.2) using Quartus 12 SP1, Cyclone III Development Board with Triple Speed Ethernet Design Example (altera.com/support/examples/nios2/exm-tse-sgdma.html). I don't programm anything to flash, usb blaster is used. An example from BillA does not work in my case, SignalTap shows no activity on RX and TX Avalon Stream. But if I run Altera's example webserver using NicheStack on the MicroC/OS-II RTOS and the example from BillA thereafter everything is fine -lwIP web serwer works. Where is the difference in interniche and lwIP initialization routines?