Forum Discussion
Altera_Forum
Honored Contributor
16 years agosimple socket server connection established, but cannot ping/telnet
hello guys,
I got a problem with simple socket server problem. I post similiar thread in dev kit forum, but no answer until now. I am thinking maybe I could get help from here. Thank you in advance. My situation is here: hardware: cIII 120 develop board software: QII 9.1 sp2, Nios II 9.1 sp2 What i have done: 1. copy the C:\altera\91\nios2eds\examples\verilog\niosII_cycl oneIII_3c120\triple_speed_ethernet_design to my project fold and open with QII 2. open sopc builder and run generate 3. back to QII and compile to generate sof (time limited version) 4. open nios eclipse ide, create a new project with simple socket server template 5. to avoid troulbe, modife get_mac_addr() as: ****************************************** int get_mac_addr(NET net, unsigned char mac_addr[6]) { mac_addr[0]=0xB7; mac_addr[1]=0xA7; mac_addr[2]=0xED; mac_addr[3]=0xFF; mac_addr[4]=0xFF; mac_addr[5]=0xFF; return 0; // return (get_board_mac_addr(mac_addr)); } ****************************************** 6. I disable DHCP in wizard and I use cross cable to connect board and PC directly. 7. run app as "Nios II hardware" what I got: =============== Software License Reminder ================ This software project uses an unlicensed version of the NicheStack TCP/IP Network Stack - Nios II Edition. If you want to ship resulting object code in your product, you must purchase a license for this software from Altera. For information go to: "http://www.altera.com/nichestack" ================================================== === 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 mctest init called IP address of et1 : 192.168.1.234 Created "Inet main" task (Prio: 2) Created "clock tick" task (Prio: 3) Simple Socket Server starting up [sss_task] Simple Socket Server listening on port 30 Created "simple socket server" task (Prio: 4) Everything looks smooth, but I cannot ping, telnet or whatever else. When I ping, the RX light is flashing, but TX light not.43 Replies
- Altera_Forum
Honored Contributor
Does ping always succeed? Do you miss or get delayed responses sometimes?
- Altera_Forum
Honored Contributor
@Cris72
yes most of the time I am able to ping but sometimes I can't ping - Altera_Forum
Honored Contributor
ping should always succeed.
It seems a problem related to signal integrity on your board or possibly to fpga timing. - Altera_Forum
Honored Contributor
@cRIS72
How can I verify Signal Integrity and FPGA timings? - Altera_Forum
Honored Contributor
--- Quote Start --- How can I verify Signal Integrity and FPGA timings? --- Quote End --- Time Quest for FPGA timings. If you don't know how to use it, you'll have to learn it. Signal integrity depends on how well is designed your pcb. Something can be evaluated with a good oscilloscope but first of all you must check if everything complies with component specifications (i.e. capacitive decoupling, ground/supply layers, board traces routing, ...) In your situation I'll especially focus on PHY signals, both on fpga and wire sides. - Altera_Forum
Honored Contributor
@Cris72
Thanks for your support This is to inform that my design is working now I didn't modified my hardware or software design. I used cross cable, link was established of 1000mbps and full duplex It was working but earlier link established was 100mbps and half duplex and it was not working - Altera_Forum
Honored Contributor
triple_speed_ethernet_design, I used this file. And I was ping for IP address successful.
But at that time, You should note your Ethernet, this mean that in your code you only need to consider some problem including, RX, TX, PHY, MAC address ... you ignore LCD, seg_led... and you remember to include full file. and Here you can see: /* Dinh nghia MicroC/OS-II */ # include "includes.h" # include <stdio.h> # include <errno.h> # include <ctype.h> # include "system.h" # include "altera_avalon_pio_regs.h" # include <unistd.h> /* Dinh nghia Web Server*/ # include "alt_error_handler.h" # include "web_server.h" /* Dinh nghia Nichestack*/ # include "ipport.h" # include "libport.h" # include "osport.h" # include "tcpport.h" # include "net.h" # ifndef ALT_INICHE # error # endif # ifndef __ucosii__ # error # endif # ifndef RO_ZIPFS # error # endif extern int current_flash_block; extern void WSTask(); static void WSCreateTasks(); /* NicheStack*/ extern struct net netstatic[STATIC_NETS]; TK_OBJECT(to_wstask); TK_ENTRY(WSTask); struct inet_taskinfo wstask = { &to_wstask, "web server", WSTask, HTTP_PRIO, APP_STACK_SIZE, }; /* WSInitialTask se khoi tao NichStack TCP/IP stack va ke do khoi tao * nhung phan con lai cua web_server */ void WSInitialTask(void* pdata) { INT8U error_code = OS_NO_ERR; // Bat dau khoi tao alt_iniche_init(); //Cho den khi network san sang de thuc hien netmain(); while (!iniche_net_ready) TK_SLEEP(1); TK_NEWTASK(&wstask); WSCreateTasks(); printf("\nWeb Server Dang duoc bat dau\n"); error_code = OSTaskDel(OS_PRIO_SELF); alt_uCOSIIErrorHandler(error_code, 0); while(1); /*dang cho.*/ } OS_STK WSInitialTaskStk[TASK_STACKSIZE]; OS_STK LEDTaskStk[TASK_STACKSIZE]; OS_STK SSDTaskStk[TASK_STACKSIZE]; OS_STK BCTaskStk[TASK_STACKSIZE]; OS_EVENT *board_control_mbox; int main (int argc, char* argv[], char* envp[]) { /* Khoi tao khoi Flash dang hien hanh*/ current_flash_block = -1; INT8U error_code; /* Xoa RTOS timer */ OSTimeSet(0); error_code = OSTaskCreateExt(WSInitialTask, NULL, (void *)&WSInitialTaskStk[TASK_STACKSIZE-1], WS_INITIAL_TASK_PRIO, WS_INITIAL_TASK_PRIO, WSInitialTaskStk, TASK_STACKSIZE, NULL, 0); alt_uCOSIIErrorHandler(error_code, 0); OSStart(); while(1); /* Cong lap cho. */ return -1; } static void WSCreateTasks() { INT8U error_code = OS_NO_ERR; /* Start LED Task. */ error_code = OSTaskCreateExt(LED_task, NULL, (void *)&LEDTaskStk[TASK_STACKSIZE-1], LED_PRIO, LED_PRIO, LEDTaskStk, TASK_STACKSIZE, NULL, 0); alt_uCOSIIErrorHandler(error_code, 0); /* Bat dau SSD Task. */ # ifdef SEVEN_SEG_PIO_NAME error_code = OSTaskCreateExt(SSD_task, NULL, (void *)&SSDTaskStk[TASK_STACKSIZE-1], SSD_PRIO, SSD_PRIO, SSDTaskStk, TASK_STACKSIZE, NULL, 0); alt_uCOSIIErrorHandler(error_code, 0); # endif error_code = OSTaskCreateExt(board_control_task, NULL, (void *)&BCTaskStk[TASK_STACKSIZE-1], BOARD_PRIO, BOARD_PRIO, BCTaskStk, TASK_STACKSIZE, NULL, 0); alt_uCOSIIErrorHandler(error_code, 0); OSTaskSuspend(LED_PRIO); OSTaskSuspend(SSD_PRIO); } void board_control_task(void *pdata) { INT8U error_code = OS_NO_ERR; board_control_mbox = OSMboxCreate((void *)NULL); struct http_form_data* board_control_mbox_contents; while(1) { board_control_mbox_contents = (void*)OSMboxPend(board_control_mbox, 0, &error_code); if (board_control_mbox_contents->LED_ON) { OSTaskResume(LED_PRIO); } else { OSTaskSuspend(LED_PRIO); IOWR_ALTERA_AVALON_PIO_DATA( LED_PIO_BASE, 0 ); } if (board_control_mbox_contents->SSD_ON) { OSTaskResume(SSD_PRIO); } else { OSTaskSuspend(SSD_PRIO); # ifdef SEVEN_SEG_PIO_NAME sevenseg_set_hex(0); # endif } } } void LED_task(void* pdata) { alt_u8 led = 0x2; alt_u8 dir = 0; while (1) { if (led & 0x81) { dir = (dir ^ 0x1); } if (dir) { led = led >> 1; } else { led = led << 1; } IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, led); OSTimeDlyHMSM(0,0,0,50); } } - Altera_Forum
Honored Contributor
Hi everyone,
In TCP client programming, we use connect() to establish a new TCP connection. connect() returns zero on success or -1 on error. If server is up , connect() returns zero and client connects to server. what if server is down? I placed connect() in while loop with a condition to exit from while loop when it returns ZERO(connects successfully). It doesn't work......... suggest me a solution in client program to connect a server which can come UP and go DOWN at any time. - Altera_Forum
Honored Contributor
--- Quote Start --- If you can ping the board, there's definitely no problem at the mac/phy levels, so I don't think you need to include that. Probably you have a wrong SSS code or made a mistake in tcp configuration: infact ping relies on UDP, while the server-client connection requires TCP which is a bit more complex. Using a network analyzer like Wireshark can easily help you to find out if connection initiates and where it fails before being established. --- Quote End --- Hi,Cris72 The output of NIOS II is: ************************************************** ************* InterNiche Portable TCP/IP, v3.1 Copyright 1996-2008 by InterNiche Technologies. All rights reserved. prep_tse_mac 0 Your Ethernet MAC address is 00:07:ed:ff:61:06 Static IP Address is 192.168.10.234 prepped 1 interface, initializing... [tse_mac_init] INFO : TSE MAC 0 found at address 0x0b442000 INFO : PHY Marvell 88E1111 found at PHY address 0x10 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 MARVELL : Mode changed to RGMII/Modified MII to Copper mode MARVELL : Enable RGMII Timing Control MARVELL : PHY reset INFO : PHY[0.0] - Checking link... INFO : PHY[0.0] - Link not yet established, restart auto-negotiation... INFO : PHY[0.0] - Restart Auto-Negotiation, checking PHY link... INFO : PHY[0.0] - Auto-Negotiation PASSED INFO : PHY[0.0] - Link established INFO : PHY[0.0] - Speed = 1000, Duplex = Full OK, x=0, CMD_CONFIG=0x00000000 MAC post-initialization: CMD_CONFIG=0x0400020b [tse_sgdma_read_init] RX descriptor chain desc (1 depth) created mctest init called IP address of et1 : 192.168.10.234 Created "Inet main" task (Prio: 2) Created "clock tick" task (Prio: 3) Simple Socket Server starting up [sss_task] Simple Socket Server listening on port 30 Created "simple socket server" task (Prio: 4) ************************************************** ****** I can send words or command via Telnet or Ping, when I use a router. However, I always failed when I directly connect the board and PC with a cross-over cable. I am really confused, I hope that you could help me. Have a good day! - Altera_Forum
Honored Contributor
--- Quote Start --- Hi everyone, In TCP client programming, we use connect() to establish a new TCP connection. connect() returns zero on success or -1 on error. If server is up , connect() returns zero and client connects to server. what if server is down? I placed connect() in while loop with a condition to exit from while loop when it returns ZERO(connects successfully). It doesn't work......... suggest me a solution in client program to connect a server which can come UP and go DOWN at any time. --- Quote End --- Hi,rahul Can you still remember how to solve the problem, which is metioned previously.I can send words or command via Telnet or Ping, when I use a router(100M). But, when I I directly connect the board and PC with a cross-over cable or a router(1000M), I failed. I hope you could give me some advice.