cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor
Contributor
3,131 Views
Registered: ‎01-22-2009

Problem UDP

Hi,

 

 I am using is Spartan3A  with XPS 10.1 and lwip 3.0.

 

I am trying to use lwip with UDP in RAW mode.  For the moment, I can receive UDP packets.

 

But I've problem to send packets, in fact when I want to send data to my PC, I can see with Wireshark two  ARP frames.

 

My board send ARP request and my PC reply with ARP frame. After this nothing happen, the function udp_sendto() call again, but nothing. 

 

My code

int main() { struct netif *netif, server_netif; struct udp_pcb *pcb; struct ip_addr ipaddr, netmask, gw,ipdest; int i; err_t err; /* the mac address of the board. this should be unique per board */ unsigned char mac_ethernet_address[] = { 0x00, 0x0a, 0x35, 0x00, 0x01, 0x02 }; xil_printf("Enterring Main --\r\n"); /* Initialize ICache */ microblaze_disable_icache (); microblaze_init_icache_range(0, ICACHE_SIZE); microblaze_enable_icache (); /* Initialize DCache */ microblaze_disable_dcache (); microblaze_init_dcache_range(0, DCACHE_SIZE); microblaze_enable_dcache (); /* initliaze IP addresses to be used */ IP4_ADDR(&ipaddr, 192, 168, 1, 10); IP4_ADDR(&netmask, 255, 255, 255, 0); IP4_ADDR(&gw, 192, 168, 1, 1); //print_app_header(); print_ip_settings(&ipaddr, &netmask, &gw); print_app_header(); lwip_init(); if (!xemac_add(netif, &ipaddr, &netmask, &gw, mac_ethernet_address, EMAC_BASEADDR)) { xil_printf("Error adding N/W interface\n\r"); return -1;} netif_set_default(netif); /* now enable interrupts */ platform_setup_interrupts(); netif_set_up(netif); start_application(); /* receive and process packets */ while(1) { xemacif_input(netif); transfer_data(); usleep(1000); } microblaze_init_dcache_range(0, XPAR_MICROBLAZE_0_DCACHE_BYTE_SIZE); microblaze_init_icache_range(0, XPAR_MICROBLAZE_0_CACHE_BYTE_SIZE); return 0; } int transfer_data() { xil_printf("Enter to data transfer\n\r"); int i; err_t err; char data[SEND_BUFSIZE]; struct udp_pcb *pcb = connected_pcb; static int id; int *payload; u16_t port; if (!connected_pcb) {xil_printf("!connect_pcb"); return -1;} pbuf_to_be_sent = pbuf_alloc(PBUF_RAW, SEND_BUFSIZE, PBUF_POOL); if (!pbuf_to_be_sent) { xil_printf("error allocating pbuf to send\n\r"); return -1; } else { for(i=0;i<SEND_BUFSIZE;i++) send_buf[i]=data[i]; memcpy(pbuf_to_be_sent->payload, send_buf, 1024); pbuf_to_be_sent->len = SEND_BUFSIZE; } if (!pbuf_to_be_sent) { xil_printf("!pbuf_to_be_sent\n\r"); return -1;} port=5001; IP4_ADDR(&ipaddr2,192,168,1,11); err = udp_sendto(pcb,pbuf_to_be_sent,&ipaddr2,port); if (err != ERR_OK) { xil_printf("Error on udp_send: %d\n\r", err); return -1;} pbuf_free(pbuf_to_be_sent); return 0; }

 

 

 

Regards

 

0 Kudos
1 Reply
Highlighted
Explorer
Explorer
1,698 Views
Registered: ‎04-16-2009

Re: Problem UDP

Right now, I have got the same problem, in the previously working design. Actually, the case was preceded by SDK crash and start in a similar but different project. Once I reconfigured the desigh with the new bitstream, that corresponds to the C program, the problem was resolved. Now, the ARP response is recognized again and UDP sent. Thanks.

http://forums.xilinx.com/t5/Embedded-Development-Tools/send-UDP-packets-with-LwIP/m-p/280914#M25434

0 Kudos