Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
5,018 Views

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:
  1. I used updated versions for everything as of 4/4/11. 10.1 Sp1. 

  2. Download and install the Knowledge base update to prevent nios from crashing. 

    http://www.altera.com/support/kdb/solutions/rd12222010_317.html 

  3. Take the Quartus DE2_115 webserver example for Enet0 RGMII that comes on the CD and use quartus flash programmer to program. 

  4. 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. 

  5. 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) 

  6. This example will now work as explained in the pdf. 

explanation 

  • 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. 

Sorry for the quick rush post, but i truly hope this helps someone. We should all try to help each other and I hope over the coming months that someone does the same for me with any problems i get in the future. 

 

Any questions just ask
0 Kudos
66 Replies
Altera_Forum
Honored Contributor I
276 Views

Hi Sir, 

 

In my run i couldnt see the [tse_mac_init]. Do you know why? 

 

I able to reach where Simple Socket Server starting up 

[sss_task] Simple Socket Server listening on port 30 

Created "simple socket server" task (Prio: 4) 

 

But my telnet doesnt work. Thanks. 

 

 

InterNiche Portable TCP/IP, v3.1  

Copyright 1996-2008 by InterNiche Technologies. All rights reserved.  

prep_tse_mac 0 

Static IP Address is 192.168.1.234 

prepped 1 interface, initializing... 

[tse_mac_init] 

INFO : TSE MAC 0 found at address 0x08004000 

INFO : PHY Marvell 88E1111 found at PHY address 0x12 of MAC Group[0] 

INFO : PHY[0.0] - Automatically mapped to tse_mac_device[0] 

INFO : PHY[0.0] - Restart Auto-Negotiation, checking PHY link... 

INFO : PHY[0.0] - Auto-Negotiation PASSED 

INFO : PHY[0.0] - Checking link... 

INFO : PHY[0.0] - Link established 

INFO : PHY[0.0] - Speed = 100, Duplex = Full 

OK, x=1, CMD_CONFIG=0x00000000 

MAC post-initialization: CMD_CONFIG=0x04000203 

[tse_sgdma_read_init] RX descriptor chain desc (1 depth) created
Altera_Forum
Honored Contributor I
276 Views

Only issue I had that I could help with is, the MAC address. 

If you've done other examples on your board, you've likely erased the flash. You need to hard code your MAC, there is a place for that in the code. 

See the attached code on the 1st post.
Altera_Forum
Honored Contributor I
276 Views

Im in the phone posting so I can't see code. There are some# define constants called hc_Mac or something like that. Pretty sure they are in iniche. So track there use and ensure they get used to make the Mac. Just trim away all the other junk

Altera_Forum
Honored Contributor I
276 Views

thanks, i did successfully, but i want to move the nios program to sram instead of sdram and i coudnt it. The error happens when i try to run the program in the FPGA: 

 

"Hardware configuration' has encountered a problem. 

Downloading ELF Process failed" 

 

i have changed reset vector, exception vector(SOPC) and the linker region(BSP editor)) 

 

any idea? 

 

thanks
Altera_Forum
Honored Contributor I
276 Views

Do you have other error messages in the console, such as a verify fail? Did you run a memory test program on the SRAM?

Altera_Forum
Honored Contributor I
276 Views

 

--- Quote Start ---  

 

"Hardware configuration' has encountered a problem. 

Downloading ELF Process failed" 

 

--- Quote End ---  

 

 

Hi PeFarina, 

 

Another thing to check is that the folder for your software project has sharing permissions. Part of the process of downloading the ELF file involves changing file attributes which cannot be accomplished if Eclipse does not have sharing privileges with the project folder. 

 

On my Windows 7 system I right-click on the project folder and select Share with > Homegroup (Read/Write). Your procedure may vary slightly depending on your system. 

 

 

Good luck!
Altera_Forum
Honored Contributor I
276 Views

 

--- Quote Start ---  

Do you have other error messages in the console, such as a verify fail? Did you run a memory test program on the SRAM? 

--- Quote End ---  

 

 

After that the download is completed (it gets 100%) 

i have a window saying "Hardware configuration' has encountered a problem. 

Downloading ELF Process failed" 

but in the warnings tab are two errors: 

 

 

Error launching external scanner info generator (sh -c 'g++ -E -P -v -dD C:/Users/Anónimo/workspace/.metadata/.plugins/org.eclipse.cdt.make.core/specs.cpp ')  

 

Error launching external scanner info generator (sh -c 'gcc -E -P -v -dD C:/Users/Anónimo/workspace/.metadata/.plugins/org.eclipse.cdt.make.core/specs.c ')  

 

 

both files, specs.cpp and specs.c, seem empty 

 

i didnt run a memory test program on the SRAM. i dont know how i can do it. could you show a example? 

 

thanks
Altera_Forum
Honored Contributor I
276 Views

 

--- Quote Start ---  

After that the download is completed (it gets 100%) 

i have a window saying "Hardware configuration' has encountered a problem. 

Downloading ELF Process failed" 

but in the warnings tab are two errors: 

 

 

Error launching external scanner info generator (sh -c 'g++ -E -P -v -dD C:/Users/Anónimo/workspace/.metadata/.plugins/org.eclipse.cdt.make.core/specs.cpp ')  

 

Error launching external scanner info generator (sh -c 'gcc -E -P -v -dD C:/Users/Anónimo/workspace/.metadata/.plugins/org.eclipse.cdt.make.core/specs.c ')  

 

 

both files, specs.cpp and specs.c, seem empty 

 

i didnt run a memory test program on the SRAM. i dont know how i can do it. could you show a example? 

 

thanks 

--- Quote End ---  

 

 

 

Based on this and your previous post it appears that your primary problem is with the SRAM and the warning messages are a separate issue. I would check the SRAM first to be sure it is connected and working properly. 

 

The Memory Test program that Daixiwen refers to is an example app in the Nios II Software Build Tools for Eclipse that runs on the Nios II processor. You must create, build, and run this app in Eclipse, and it must be downloaded to different memory than you are trying to test. If you have enough on-chip memory you can put it there, but in my case I did not. In fact in my custom system I don't have enough memory anywhere except the SRAM I want to test, so this test is ineffective. 

 

A better way to see if your SRAM is working is to use the System Console. This tests memory at a very fundamental level that does not require the Nios II processor to be running. You still need a Nios II in the Qsys design to have access to the JTAG Debug Module. 

 

I attached a text file that provides a step-by-step procedure for test SRAM in this manner. 

 

I would like to know your results, so please post again.
Altera_Forum
Honored Contributor I
276 Views

thanks fheineman, i cant see your attached text file.Could you post again? 

 

im using Quartus II 11.0sp1 Web Edition (32-Bit)
Altera_Forum
Honored Contributor I
276 Views

 

--- Quote Start ---  

thanks fheineman, i cant see your attached text file.Could you post again? 

 

im using Quartus II 11.0sp1 Web Edition (32-Bit) 

--- Quote End ---  

 

 

 

Sorry, not sure what happened there. I'll just put the text below. Good luck... 

 

 

1. Launch your FPGA design in Quartus II 11.0 sp1 

 

2. Open the Quartus II Programmer and program your FPGA with the current .sof file. 

 

3. Open Qsys and load your Qsys design 

 

4. Under Tools menu select System Console 

 

5. Expand the Tcl Console window as this is the only window you will need. 

 

6. At the % prompt type (or cut and paste this):
 "set mypath [ lindex [ get_service_paths master ] 0 ]"  

 



You should get a path statement something like this:
 "/connections/USB-Blaster on localhost [USB-0]/EP3C25|EP4CE22@1/[MFG:70 ID:34 INST:0 VER:3]/cpu" 

  

 

This establishes the JTAG UART connection path to the Nios II processor. If you don't see this then the JTAG UART connection is broken. That is another can of worms not addressed by this document. You must fix that before proceeding. This is often due to timing issues in your Quartus design. TimeQuest is the tool for that...
 

 

7. At the % prompt type (or cut and paste this): "
open_service master $mypath" 



  

This opens the connection to the Nios II processor.
 

 

8. At the % prompt type (or cut and paste this): "
processor_stop $mypath

"  

 

This stops the Nios II processor so it is now out of the picture.
 

 

9. At the % prompt type (or cut and paste this): "
master_write_memory $mypath 0x01000000 [ list 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x40 0x41 0x42 0x43 0x44 0x45 0x46 0x47 0x48 0x49 0x50 0x51 0x52 0x53 0x54 0x55 0x56 0x57 0x58 0x59 0x60 0x61 0x62 0x63 0x64 0x65 0x66 0x67 0x68 0x69 0x70 0x71 0x72 0x73 0x74 0x75 0x76 0x77 0x78 0x79 0x80 0x81 0x82 0x83 0x84 0x85 0x86 0x87 0x88 0x89 ]" 

 

 

This writes 80 bytes of 8-bit Hex data to the address specified. this example uses 0x01000000 as the SRAM address. You MUST set this to an address within the range of the memory in your system that you want to test. 
 

 

10. At the % prompt type (or cut and paste this): "
master_read_memory $mypath 0x01000000 80

"  

 

This reads back the data that you wrote to memory in the previous step. Don't forget to change the address to the same as the previous step.
 

 

11. You should see this:
 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x40 0x41 0x42 0x43 0x44 0x45 0x46 0x47 0x48 0x49 0x50 0x51 0x52 0x53 0x54 0x55 0x56 0x57 0x58 0x59 0x60 0x61 0x62 0x63 0x64 0x65 0x66 0x67 0x68 0x69 0x70 0x71 0x72 0x73 0x74 0x75 0x76 0x77 0x78 0x79 0x80 0x81 0x82 0x83 0x84 0x85 0x86 0x87 0x88 0x89  

 

 

There are many other commands that you can use with the System Console to test the memory and other hardware functions in your system such as master_write_16 and master_write_32. At the % prompt type: "help help" to get a list of all the commands. For more information of any command type "help <command name>" at the % prompt. 

 

Happy Testing !!!
Altera_Forum
Honored Contributor I
276 Views

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 I
276 Views

 

--- 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: 

  1. What version of Altera tools are you using? 

  2. Could you attach the altera_avalon_tse.c file from your system? 

Altera_Forum
Honored Contributor I
276 Views

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 I
276 Views

 

--- 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 example 

 

Located 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 I
276 Views

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 I
276 Views

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 I
276 Views

 

--- 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. 

 

 

 

--- Quote Start ---  

Can it be that the telnet connection does not work because of the file from my post before tse_my_system.c ? 

 

--- Quote End ---  

 

 

It's possible. Did you add '-dtse_my_system' to the defined symbols in the nios ii bsp properties sections of the BSP properties as indicated in my list? 

 

I'm not using RGMII, so I can't help you much with that.
Altera_Forum
Honored Contributor I
276 Views

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 I
276 Views

 

--- 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 I
133 Views

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!
Reply