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
--- Quote Start --- Please stop sending the same question multiple times. It won't get you more answers. I rarely use the debugger so I can't be of much help here. For starters is 0xe11fc a valid program address, i.e. an address in your main RAM region? IF the address is complete bogus, it could indicate a memory corruption or a head/stack collision. --- Quote End --- Dear Daixiwen I'm so sorry about it,and I will not do that any more.and sorry about reply lately.first I think i should check the hardware as billa said,and run the sss project to test the board!thank you for your reply,and best wishes to you - Altera_Forum
Honored Contributor
--- Quote Start --- This kind of error typically means the hardware definition is wrong. Something is wrong with memory, clocks, speeds or something. In the past I've told people that have problems with this example to get a standard Altera example running - like Simple Socket Server as-is on your hardware (create app and BSP with that template). If the Simple Socket Server won't run, this lwIP example will never run either. It's pretty hard to test and debug software with unstable hardware. BillA --- Quote End --- Hi Billa thanks for your reply my board can ping it,and my hardware have sth wrong? I will check the hardware with the SSS project. best wishes to you! - Altera_Forum
Honored Contributor
Dear BillA
I'm using niosii 9.0+quartus 9.0 to build the project.when i can ping the board and get the packages using the tool wireshark.and i can send the package by using the function tse_mac_raw_send(&alteraTseNetif,psend);also test the packages.but I can't run the function udp_send(UdpPcbS,psend);so I test step by step.when i arrive to the code of the function ip_output_if(q, src_ip, dst_ip, pcb->ttl, pcb->tos, IP_PROTO_UDP, netif) ,the problem appear.warning " <symbol is not available> 0x877e11ff".maybe I lost something important,could you give me advices.thanks a lot,and best wishes to you! here is the code: IPH_TTL_SET(iphdr, ttl); IPH_PROTO_SET(iphdr, proto); ip_addr_set(&(iphdr->dest), dest); IPH_VHLTOS_SET(iphdr, 4, ip_hlen / 4, tos); IPH_LEN_SET(iphdr, htons(p->tot_len)); IPH_OFFSET_SET(iphdr, 0); IPH_ID_SET(iphdr, htons(ip_id)); ++ip_id; - Altera_Forum
Honored Contributor
Dear daixiwen
I'm using niosii 9.0+quartus 9.0 to build the project.when i can ping the board and get the packages using the tool wireshark.and i can send the package by using the function tse_mac_raw_send(&alteraTseNetif,psend);also test the packages.but I can't run the function udp_send(UdpPcbS,psend);so I test step by step.when i arrive to the code of the function ip_output_if(q, src_ip, dst_ip, pcb->ttl, pcb->tos, IP_PROTO_UDP, netif) ,the problem appear.warning " <symbol is not available> 0x877e11ff".maybe I lost something important,could you give me advices.thanks a lot,and best wishes to you! here is the code: IPH_TTL_SET(iphdr, ttl); IPH_PROTO_SET(iphdr, proto); ip_addr_set(&(iphdr->dest), dest); IPH_VHLTOS_SET(iphdr, 4, ip_hlen / 4, tos); IPH_LEN_SET(iphdr, htons(p->tot_len)); IPH_OFFSET_SET(iphdr, 0); IPH_ID_SET(iphdr, htons(ip_id)); ++ip_id; - Altera_Forum
Honored Contributor
zhangjie,
You did not need to double post - or address an individual because everyone sees these posts and might reply if they can help. Sure, you can address the previous replier to a post of yours but no need for a double entry. The error can be caused by compiler optimization. Also, bit 31 is set of the address (being a non-cached pointer) and that may be causing the symbol lookup to fail. udp_send can fail if ARP responses are not working. Packets cannot be sent until the address is resolved by ARP. However, I think a ping causes ARP to be resolved so UDP should work too. Can you receive UDP and just not send? Wireshark will show you the ARP resolution (Who has?). Also check your firewall - I'm not sure which side of it Wireshark is watching. Regards, BillA - Altera_Forum
Honored Contributor
Can you share reference design of simple socket server(TCP/IP NicheStack program) in which SMSC LAN91c111 is used as the hardware MAC/PHY.
My main requirement is how to drive this SMSC LAN91c111 using MicroC/OS-II from Nios II EDS. - Altera_Forum
Honored Contributor
This thread is about lwIP. Both it and Interniche are based on the Altera TSE. Why use an external MAC?
Anyway, you should create a new thread for your topic as it's mostly off-topic here. BillA - Altera_Forum
Honored Contributor
Just to recap for those not too familiar with networking..
The uIP and it's bigger brother lwIP are TCP/IP stacks originally created by Adam Dunkels that are often used for the bemicro-sdk (EngineeringSpirit FreeLwIP, minsoc.com uses uIP I believe, etc). Altera also used that stack, but dropped it after version 6.1 in favor of the other open source stack , NicheStack. Either way, on the bemicrosdk the low-level physical layer is done by TI's DP83848C chip, and the Data Link / MAC layer is done on the FPGA via Altera's drop-in Triple Speed Ethernet megafunction. Is this correct? http://www.alteraforum.com/forum/showthread.php?t=33812 http://www.alteraforum.com/forum/showthread.php?t=32429 http://www.alteraforum.com/forum/showthread.php?p=93638 - Altera_Forum
Honored Contributor
NO! NOT CORRECT!!!
NicheStack IS NOT OPEN SOURCE! http://www.alterawiki.com/wiki/nichestack BillA - Altera_Forum
Honored Contributor
very very unfortunately,billa and every one,my problem also exists.
so I describe my question again: my fpga is ep3c120f484 and epcs64,have not supply extern sdram by using quartus 9.0+nios 9.0 i do the project as the "readme txt",and the sopc builder system and nios libirary properties will upload in the picture. my ip and mac set: # define STATIC_IP IP4_ADDR(&lwipStaticIp,219,245,66,185) # define STATIC_NM IP4_ADDR(&lwipnetmask,255,255,255,0) # define STATIC_GW IP4_ADDR(&lwipgw,219,245,66,254) # define STATIC_DA IP4_ADDR(&destAddr,219,245,66,112) alteraTseNetif.hwaddr[0] = 0x00; alteraTseNetif.hwaddr[1] = 0x1C; alteraTseNetif.hwaddr[2] = 0x23; alteraTseNetif.hwaddr[3] = 0x17; alteraTseNetif.hwaddr[4] = 0x4A; alteraTseNetif.hwaddr[5] = 0xCB; and the udpsend: char udpdata[] = "UDP has Initialed successfully, begin to transfer!\r\n"; struct pbuf *psend; struct udp_pcb *UdpPcbS; psend = pbuf_alloc(PBUF_RAW, sizeof(udpdata), PBUF_RAM); psend->payload = (void *)udpdata; if (!psend) { printf("Can't allocate buffer.\n"); } UdpPcbS = udp_new(); if (!UdpPcbS) { printf("udp_new() failed.\n"); } udp_bind(UdpPcbS, &lwipStaticIp, 67); if (udp_bind(UdpPcbS, &lwipStaticIp, 67) != ERR_OK) { printf("udp_bind() failed.\n"); } udp_connect(UdpPcbS, &destAddr, 67); if (udp_connect(UdpPcbS, &destAddr, 67) != ERR_OK) { printf("udp_connect() failed.\n"); } while(1) { udp_send(UdpPcbS,psend); mSdelay(1000); mSdelay(1000); mSdelay(1000); } when I debug step by step,the error will be appear in the code in "ip.c" IPH_TTL_SET(iphdr, ttl); if (ip_addr_isany(src)) { ip_addr_copy(iphdr->src, netif->ip_addr); } else { (iphdr->src).addr = (*src).addr; } and return error. and it is not caused by compiler optimization. I can not receive and send any packets. Regards, zhangjie