Forum Discussion
WORKING: DE2-115 Simple Socket Server
Hi,
It seems difficult to get help on these forums so I want to pass on what i learnt for others. I've struggled to learn FPGAs over the past few weeks and I have finally got a simple socket server working for the DE2-115. I'll quickly post my findings so someone else can take this and learn from it and not have to struggle on their own as i did. procedure I'll make this brief:- I used updated versions for everything as of 4/4/11. 10.1 Sp1.
- Download and install the Knowledge base update to prevent nios from crashing. http://www.altera.com/support/kdb/solutions/rd12222010_317.html
- Take the Quartus DE2_115 webserver example for Enet0 RGMII that comes on the CD and use quartus flash programmer to program.
- Get this PDF and follow its instructions "http://www.altera.com/literature/tt/tt_nios2_tcpip.pdf?gsa_pos=1&wt.oss_r=1&wt.oss=simple socket server example nios edition socket server example nios edition" NOTE it includes the spaces (wierd). do everything the same except the part mentioned in my next step.
- Instead of copying the files from the tutorial.zip; copy the ones that i have attached to this post. (the .c and .h files including the eeprom folder)
- This example will now work as explained in the pdf.
- The original example code in the tutorial does not have the correct method for gettig the MAC address on the DE2-115. I have deleted the majority of the original MAC code and replaced it with code i got from the DE2-115 webserver example. This includes the flashgetoffset function.
- The LED_PIO_BASE in the original is an invalid for the DE2-115. I replaced it with the LEDG (green leds), you could replace it with red if you wished. This has been done by modifying the led.c file.
66 Replies
- Altera_Forum
Honored Contributor
Thanks for posting your design. I cannot get your design running.
When I implement your design, I get the error: undefined reference to 'tse_mac_device' Specifically, the error lies in these two lines of code are indicated in the file altera_avalon_tse.c: if(tse_mac_device.tse_mac_base == p_driver_data->hw_mac_base_addr) {psys_info = &tse_mac_device; Does anyone know how I can handle this error? I can't see how I should build my own socket server, when the examples are not working. I can also use the DE4 board if that is easier. Thanks
- Altera_Forum
Honored Contributor
--- Quote Start --- Thanks for posting your design. I cannot get your design running. When I implement your design, I get the error: undefined reference to 'tse_mac_device' Specifically, the error lies in these two lines of code are indicated in the file altera_avalon_tse.c: if(tse_mac_device.tse_mac_base == p_driver_data->hw_mac_base_addr) {psys_info = &tse_mac_device; Does anyone know how I can handle this error? I can't see how I should build my own socket server, when the examples are not working. I can also use the DE4 board if that is easier. Thanks --- Quote End --- David, I know exactly what you are facing as I spent months trying to get the Simple socket Server to work on my custom design. There are several SSS example versions floating around, non of which have I found to work without extensive modification for my hardware environment. In addition there are numerous versions of the Altera development tools in use. I am using Quartus 11.0 sp1 and my NiosII design is in Qsys rather than SOPC builder. I may be able to help you if your environment is similar. However, I do not find that line of code in the altera_avalon_tse.c file on my system. Two things would help to identify this particular problem your are experiencing:
- What version of Altera tools are you using?
- Could you attach the altera_avalon_tse.c file from your system?
- Altera_Forum
Honored Contributor
Thanks!
I am using Quartus 11.1 (64bit), it says: without service pack. I am more confident with the SOPC builder, but could also build the system with Qsys. I was using "NIOS II IDE for Eclipse" but found that "NIOS II Software build tools for Eclipse" allow more control over the bsp file. Which one of these two are you using? How should I approach building a socket server? I could, for example, start from a hello world program and load one function after another and get confident with the MicroC/OS-II. The error above was actually in the file ins_tse_mac.c, sorry for that. I get errors in both files. - Altera_Forum
Honored Contributor
--- Quote Start --- How should I approach building a socket server? --- Quote End --- Download the example files appropriate to your system from the nios ii ethernet standard design exampleLocated at http://www.altera.com/support/examples/nios2/exm-net-std-de.html (http://www.altera.com/support/examples/nios2/exm-net-std-de.html) Then follow my modified procedure as outlined in the attached PDF file. This is the best example of the Simple Socket Server that I have found. It still requires some tweaking for your specific system, but it does work when all the planets are alined correctly...
- Altera_Forum
Honored Contributor
Thanks, your checklist is great! Still, I got the same error.
I managed to compile the example hardware and software files from the de4 cd when I included the C-file tse_my_system.c from the website http://www.altera.com/support/kdb/solutions/rd11122009_293.html The compiled and loaded telnet server looks as if it works. - Altera_Forum
Honored Contributor
The telnet connection does not work,
even though the board says that the socket server starts up correctly: ...a lot of messages including IP Simple Socket Server starting up [sss_task] Simple Socket Server listening on port 30 Created "simple socket server" task (Prio: 4) Can it be that the telnet connection does not work because of the file from my post before tse_my_system.c ? Thanks! - Altera_Forum
Honored Contributor
--- Quote Start --- The telnet connection does not work, even though the board says that the socket server starts up correctly: ...a lot of messages including IP Simple Socket Server starting up [sss_task] Simple Socket Server listening on port 30 Created "simple socket server" task (Prio: 4) --- Quote End --- That does look like the telnet connection should be working. Do you include the port number when you try to connect to it as in: 'telnet xxx.xxx.xxx.xxx 30' ??? It won't connect without the port number 30 after the IP address. It would help to see the rest of the messages. Also,- Is your ethernet connection through a router?
- Are you using DHCP? If so, is it acquiring an IP address from the router or defaulting to the static IP?
- When it's negotiating with the MAC and PHY, does it succeed or fail? I've seen it fail the negotiation at times, but still fall through to the 'Simple Socket Server listening on port 30' as though everything is working. That's not good, and it won't work that way.
- Altera_Forum
Honored Contributor
Thanks!
Now the telnet server works. I am using a cross over cable and set the ip address, the subnet mask, and the gateway in windows manually. For the subnet mask and gateway, I used the values specified in the file simple_socket_server.h. I also had to turn off enable_dhcp_client as described in the file that you uploaded. So it was, as you said, a connection problem on the cable/computer side. The simple socket server is running on both evaluation boards, DE2 and DE4. Now I can start changing the socket server task to transfer data. - Altera_Forum
Honored Contributor
--- Quote Start --- Thanks! Now the telnet server works. I am using a cross over cable and set the ip address, the subnet mask, and the gateway in windows manually. For the subnet mask and gateway, I used the values specified in the file simple_socket_server.h. I also had to turn off enable_dhcp_client as described in the file that you uploaded. So it was, as you said, a connection problem on the cable/computer side. The simple socket server is running on both evaluation boards, DE2 and DE4. Now I can start changing the socket server task to transfer data. --- Quote End --- CONGRATULATIONS!!! Now you can get down to the fun stuff. :) Thanks for posting your results, and good luck with the rest of your design. BTW - DHCP does work, if you get around to needing it. ALSO - The web server example application also works quite well. If you need to serve up basic HTML pages, it does a nice job. Like the Simple Socket Server app, it uses NicheStack and MicroC/OS-II. Some tweaking will most likely be required to work with your system. - Altera_Forum
Honored Contributor
Hello, I managed to run the web server example and it works! However, I need to ask you if there is any way that I can send from FPGA to the webpage. In fact, using the webpage, I can write on the LCD, or light the leds ... What i need is the other way around, from fpga to the webpage.. And another thing is that the IP address assigned to the board and used to control the board remotely is local and I can only access it if I am within the domain of my router. What are my options if I want someone outside my router to have access to the board other than getting a real IP?
Help!!! Thank you!