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
- Altera_Forum
Honored Contributor
--- Quote Start --- NO! NOT CORRECT!!! NicheStack IS NOT OPEN SOURCE! http://www.alterawiki.com/wiki/nichestack BillA --- Quote End --- Oops, yes, the FreeRTOS home page links to the InterNiche stack.. I didn't notice it was a "Buy Now"! Perhaps their webserver example using FreeTCPIP (on a Actel A2F-EVAL-KIT fpga) is a better start for porting to Altera. I imagine any FPGA port (like fNET) is a closer than starting with EtherSex/uhttpd-avr/NutOS-NutNet, or something else originally targeting a microcontroller. - Altera_Forum
Honored Contributor
Billa,
Bit 31 is set of the address (being a non-cached pointer) and that may be causing the symbol lookup to fail. can you describe the details? thank you! - Altera_Forum
Honored Contributor
--- Quote Start --- The following optimization can be applied to lwip_tse_mac.c: In function tse_sgdmaRx_isr: Replace the init_tset_descriptor function call (spans 6 or 7 lines) just after label _dump: with the following: IOWR_32DIRECT(&tse_ptr->desc[ALTERA_TSE_FIRST_RX_SGDMA_DESC_OFST].write_addr, 0, (u32_t) ethernetif->lwip_rx_pbuf[ethernetif->lwipRxIndexIsr]->payload); IOWR_8DIRECT(&tse_ptr->desc[ALTERA_TSE_FIRST_RX_SGDMA_DESC_OFST].control, 0, ALTERA_AVALON_SGDMA_DESCRIPTOR_CONTROL_OWNED_BY_HW_MSK); I don't claim credit for this - I see they did this in the NIOS 12.1 TSE driver and it makes a lot of sense. Bill A --- Quote End --- Bill, There is no init_tset_descriptor function in the driver. Should it be the alt_avalon_sgdma_construct_stream_to_mem_desc function call in tse_mac_rcv? Igor - Altera_Forum
Honored Contributor
--- Quote Start --- 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) --- Quote End --- Is there an off-the-shelf development kit (altera, terasic, etc) that this will work out of the box with? I understand a TSE must be instantiated, but what kind of PHY chip? I think BillA used the Marvell 88E1119R in the lwip port, but I believe it was a custom cyclone3 board. If no COTS, is there any tips on the thought process involved in porting the design to different phys? - Altera_Forum
Honored Contributor
Igor,
It's (init_tse_descriptor) is in lwip_tse_mac.c. Happy, You can add a custom or non-default PHY using the run-time add function alt_tse_phy_add_profile. I use this now and use a common lwIP/TSE driver in 4 products so they can all share the same code. I also deleted the defaults in the Altera code - I won't be switching and don't use any of them. The individual NIOS II projects each include the BSP for the board but they reference the same common code. Fortunately, 12.x fixes the bug in 10.x that prevented referencing common code. Yes, we used the 88E119R. I've also moved 3 of the 4 Cyclone III projects to NIOS 12.x and have had no trouble with the TSE or with lwIP, which was also upgraded to 4.1. Fortunately lwIP is very portable. BillA - Altera_Forum
Honored Contributor
--- Quote Start --- Igor, It's (init_tse_descriptor) is in lwip_tse_mac.c. Happy, You can add a custom or non-default PHY using the run-time add function alt_tse_phy_add_profile. I use this now and use a common lwIP/TSE driver in 4 products so they can all share the same code. I also deleted the defaults in the Altera code - I won't be switching and don't use any of them. The individual NIOS II projects each include the BSP for the board but they reference the same common code. Fortunately, 12.x fixes the bug in 10.x that prevented referencing common code. Yes, we used the 88E119R. I've also moved 3 of the 4 Cyclone II projects to NIOS 12.x and have had no trouble with the TSE or with lwIP, which was also upgraded to 4.1. Fortunately lwIP is very portable. BillA --- Quote End --- BillA, is there an updated set of instructions for the example project in 12.x? I need to leverage a solution that is royalty free, hooray lwIP, but am having trouble following the instructions found in post# 1 for Nios IDE 8.1. Any help? - Altera_Forum
Honored Contributor
What is the trouble? The concepts in the original instructions still apply: Create a NIOS II library, base it on your BSP, add lwIP and the ethernet driver. Also, make the changes that fix the bugs mentioned many posts back.
I agree and admit that this original post and ZIP is really stale. I'll see what I can do, but in the meantime, let me know where you're stuck (if you still are). BillA - Altera_Forum
Honored Contributor
Hi BillA,
May I know how much throughput the 1000M Ethernet can achieve for RX and TX on your Cyclone III board? Thanks. Twenty - Altera_Forum
Honored Contributor
--- Quote Start --- Hi BillA, May I know how much throughput the 1000M Ethernet can achieve for RX and TX on your Cyclone III board? Thanks. Twenty --- Quote End --- This is tough to answer because it's application dependent and very dependent on available memory. I can say for our products that send a lot of data (images) we used a custom UDP protocol because TCP was under 100MBS while UDP can get upwards of 500MBS. (these are bits per second) For our product that receives a lot of data and sends very little, we set the MAC for 100MBS because at 1000MBS the packet rate is so fast the Cyclone III cannot keep up with the interrupt rate. So it drops packets and actually slows down the link. We found at 100MBS there are no dropped packets and we can run the product at its max speed. It was probably faster at 1000MBS but I prefer an error-free transport and 100MBS is enough. It also spread out the receive over more time which I thought was better. Take care, Bill