2013-09-25 5 views
1

현재 이더넷을 통한 간단한 전송 프로토콜을 만들기 위해 노력하고 있습니다. 우리 프로젝트의 이더넷 부분을 디버깅하는 데 사용할 SP605 자일링스 평가 보드가있다. 나는 그 예를 식인하려고 시도했지만 지금까지 실패했다. 현재, 통신은 오직 한 가지 방법 일 필요가 있습니다. 현재 netcat과 함께 전송되는 데이터를 확인하려고합니다. 나는 또한 Wireshark를 열고을 가지고 요구를 반복 시스템이 박히면서보고 있어요 :lwip ARP에서 RAW UDP 연결 만들기 ARP

2217 1323.697811000 Xilinx_00 : 01 : 192.168.1.11을 가지고 02 방송
ARP (60)? 192.168.1.10

에게 내가 가진 호스트 컴퓨터의 응답을 볼 수

2217 1323.697811000 Xilinx_00 : 01 : 192.168.1.11을 가지고 02 방송
ARP (60)? Tell 192.168.1.10

구성과 관련된 몇 가지 문제가 있지만 그것이 무엇인지 파악할 수없는 것 같습니다. 나는 그것이 recv 핸들러를 가지고 있지 않은 것과 관련이 있을지 모르지만 나는 확실하지 않다.

아래 코드는 제가 사용하고있는 코드입니다. lwip_init()는 자일링스가 제공 한 예제에서 호출을 모방 한 것입니다.

/* 
* main.c 
* 
* Created on: Sep 24, 2013 
*  Author: Ian 
*/ 
#include <stdio.h> 
#include <string.h> 

#include <stdio.h> 
#include "lwip/init.h" 
#include "xparameters.h" 
#include "netif/xadapter.h" 
#include "xenv_standalone.h" 
#include "platform_config.h" 
#include "xparameters.h" 
#include "xintc.h" 
#include "xil_exception.h" 
#include "mb_interface.h" 
#include "xtmrctr_l.h" 
#include "lwip/udp.h" 
#include "lwipopts.h" 

#include "xil_printf.h" 

struct ip_addr ipaddr, ipaddr_remote, netmask, gw; 
void udp_test(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port); 


void print_ip(char *msg, struct ip_addr *ip) 
{ 
    print(msg); 
    xil_printf("%d.%d.%d.%d\r\n", ip4_addr1(ip), ip4_addr2(ip), 
      ip4_addr3(ip), ip4_addr4(ip)); 
} 

void print_ip_settings(struct ip_addr *ip, struct ip_addr *mask, struct ip_addr *gw) 
{ 
    print_ip("Board IP:  ", ip); 
    print_ip("Netmask :  ", mask); 
    print_ip("Gateway :  ", gw); 
} 

int main() 
{ 

    err_t error; 
    struct netif *netif, server_netif; 
    struct udp_pcb *udp_1; 
    struct pbuf *p; 
    char data[8] = ""; 
    u16_t Port; 
    Port = 69; 
    int count = 0; 
    int n = 0; 
    int buflen = 8; 

    /* the mac address of the board. this should be unique per board */ 
    unsigned char mac_ethernet_address[] = { 0x00, 0x0a, 0x35, 0x00, 0x01, 0x02 }; 

    netif = &server_netif; 

    xil_printf("\r\n\r\n"); 
    xil_printf("-----lwIP RAW Application ------\r\n"); 
    /* initliaze IP addresses to be used */ 

    IP4_ADDR(&ipaddr_remote, 192, 168, 1, 11); 
    IP4_ADDR(&ipaddr, 192, 168, 1, 10); 
    IP4_ADDR(&netmask, 255, 255, 255, 0); 
    IP4_ADDR(&gw,  192, 168, 1, 1); 
    print_ip_settings(&ipaddr, &netmask, &gw); 

    lwip_init(); 

    if (!xemac_add(netif, &ipaddr, &netmask, &gw, mac_ethernet_address, PLATFORM_EMAC_BASEADDR)) { 
     xil_printf("Error adding N/W interface\r\n"); 
     return -1; 
    } 
    netif_set_default(netif); 

    netif_set_up(netif); 

    Xil_ExceptionEnable(); //Setup complete start interrupts 


    udp_1 = udp_new(); 

    error = udp_bind(udp_1, IP_ADDR_ANY, Port); 

    if (error != 0) 
    { 
     xil_printf("Failed %d\r\n", error); 
    } 
    else if (error == 0) 
    { 
     xil_printf("Success\r\n"); 
    } 
    error = udp_connect(udp_1, &ipaddr_remote, Port); 
    if (error != 0) 
    { 
     xil_printf("Failed %d\r\n", error); 
    } 
    else if (error == 0) 
    { 
     xil_printf("Success\r\n"); 
    } 


while(1) 
    { 
    count++; 
    xemacif_input(netif); 
    if (count == 100000) 
    { 
     p = pbuf_alloc(PBUF_TRANSPORT, buflen, PBUF_POOL); 
     if (!p) { 
      xil_printf("error allocating pbuf\r\n"); 
      return ERR_MEM; 
     } 
     memcpy(p->payload, data, buflen); 
     udp_send(udp_1, p); 
     xil_printf("SEND\r\n"); 
     count = 0; 
     pbuf_free(p); 
    } 
    } 
    data[1] = '2'; 
} 
+0

UDP가 연결 지향적이지 않습니까? 따라서 UDP 연결이 없습니다. 그리고 전송 프로토콜은 이더넷을 통하지 않고 UDP를 넘는 것 같습니다 (심지어 UDP는 이더넷을 통해 전송됩니다). 어쨌든 당신의 플랫폼을 모르겠습니다. –

+0

나는 전송 프로토콜이 UDP를 통해되어야한다는 것을 알고 있지만, 내 문제는 그것이 핸드셋이나 초기화의 일종을 놓치고있는 것 같아서 내 보드가 누가 내 터미널의 위치에 있는지 계속 묻는다. –

+0

전송 프로토콜은 UDP를 초과하지만 반드시 그렇게 할 필요는 없습니다. 또한 코드를 읽지 않지만 대상 IP MAC을 검색하려고합니다. http://ask.wireshark.org/questions/9892/60-who-has-1692542531 –

답변

3

좋아, 기본적으로 여기에 내가 무엇을 발견합니다.

자일링스 xapp1026은 sp605_AxiEth_32kb_Cache 프로젝트를 사용할 때 문제가있었습니다. 그것은 시작 인터럽트에 매달려 있었다. 프로젝트를 진단 할 수 없었지만 sp605_EthernetLite_32kb_Cache 예제 프로젝트로 전환했습니다. MicroBlaze 인터럽트가 초기화되지 않아 ARP가 추가되지 않아 시스템이 반복적으로 루프에 들어가게된다고 가정 할 수 있습니다. AxiEth 예제에서 인터럽트가 초기화되지 않은 이유는 여전히 명확하지 않습니다. 당신이 알고 그래서

----

/* 
* Copyright (c) 2007 Xilinx, Inc. All rights reserved. 
* 
* Xilinx, Inc. 
* XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A 
* COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS 
* ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR 
* STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION 
* IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE 
* FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION. 
* XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO 
* THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO 
* ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE 
* FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY 
* AND FITNESS FOR A PARTICULAR PURPOSE. 
* 
*/ 

#include <stdio.h> 
#include <string.h> 
#include "lwip/udp.h" 
#include "xparameters.h" 
#include "netif/xadapter.h" 
#include "platform.h" 
#include "platform_config.h" 
#include "lwipopts.h" 
#ifndef __PPC__ 
#include "xil_printf.h" 
#endif 

void print_headers(); 
int start_applications(); 
int transfer_data(); 
void platform_enable_interrupts(); 
void lwip_init(void); 
void tcp_fasttmr(void); 
void tcp_slowtmr(void); 

#if LWIP_DHCP==1 
extern volatile int dhcp_timoutcntr; 
err_t dhcp_start(struct netif *netif); 
#endif 
extern volatile int TxPerfConnMonCntr; 
extern volatile int TcpFastTmrFlag; 
extern volatile int TcpSlowTmrFlag; 

void print_ip(char *msg, struct ip_addr *ip) 
{ 
    print(msg); 
    xil_printf("%d.%d.%d.%d\r\n", ip4_addr1(ip), ip4_addr2(ip), 
      ip4_addr3(ip), ip4_addr4(ip)); 
} 

void print_ip_settings(struct ip_addr *ip, struct ip_addr *mask, struct ip_addr *gw) 
{ 
    print_ip("Board IP:  ", ip); 
    print_ip("Netmask :  ", mask); 
    print_ip("Gateway :  ", gw); 
} 

int main() 
{ 
    struct netif *netif, server_netif; 
    struct ip_addr ipaddr, netmask, gw; 

    // Added stuff for the creation of a basic UDP 
    err_t error; 
    struct ip_addr ip_remote; 
    struct udp_pcb *udp_1; 
    struct pbuf *p; 
    char data[8] = ""; 
    u16_t Port = 12; 
    int buflen = 8; 
    int count = 0; 

    /* the mac address of the board. this should be unique per board */ 
    unsigned char mac_ethernet_address[] = { 0x00, 0x0a, 0x35, 0x00, 0x01, 0x02 }; 

    netif = &server_netif; 

    if (init_platform() < 0) { 
     xil_printf("ERROR initializing platform.\r\n"); 
     return -1; 
    } 

    xil_printf("\r\n\r\n"); 
    xil_printf("-----lwIP RAW Mode Demo Application ------\r\n"); 
    /* initliaze IP addresses to be used */ 
#if (LWIP_DHCP==0) 
    IP4_ADDR(&ipaddr, 192, 168, 1, 10); 
    IP4_ADDR(&netmask, 255, 255, 255, 0); 
    IP4_ADDR(&gw,  192, 168, 1, 1); 
    print_ip_settings(&ipaddr, &netmask, &gw); 
#endif 
    lwip_init(); 

#if (LWIP_DHCP==1) 
    ipaddr.addr = 0; 
    gw.addr = 0; 
    netmask.addr = 0; 
#endif 

    /* Add network interface to the netif_list, and set it as default */ 
    if (!xemac_add(netif, &ipaddr, &netmask, &gw, mac_ethernet_address, PLATFORM_EMAC_BASEADDR)) { 
     xil_printf("Error adding N/W interface\r\n"); 
     return -1; 
    } 
    netif_set_default(netif); 

    /* specify that the network if is up */ 
    netif_set_up(netif); 

    /* now enable interrupts */ 
    platform_enable_interrupts(); 

#if (LWIP_DHCP==1) 
    /* Create a new DHCP client for this interface. 
    * Note: you must call dhcp_fine_tmr() and dhcp_coarse_tmr() at 
    * the predefined regular intervals after starting the client. 
    */ 
    dhcp_start(netif); 
    dhcp_timoutcntr = 24; 
    TxPerfConnMonCntr = 0; 
    while(((netif->ip_addr.addr) == 0) && (dhcp_timoutcntr > 0)) { 
     xemacif_input(netif); 
     if (TcpFastTmrFlag) { 
      tcp_fasttmr(); 
      TcpFastTmrFlag = 0; 
     } 
     if (TcpSlowTmrFlag) { 
      tcp_slowtmr(); 
      TcpSlowTmrFlag = 0; 
     } 
    } 
    if (dhcp_timoutcntr <= 0) { 
     if ((netif->ip_addr.addr) == 0) { 
      xil_printf("DHCP Timeout\r\n"); 
      xil_printf("Configuring default IP of 192.168.1.10\r\n"); 
      IP4_ADDR(&(netif->ip_addr), 192, 168, 1, 10); 
      IP4_ADDR(&(netif->netmask), 255, 255, 255, 0); 
      IP4_ADDR(&(netif->gw),  192, 168, 1, 1); 
     } 
    } 
    /* receive and process packets */ 
    print_ip_settings(&(netif->ip_addr), &(netif->netmask), &(netif->gw)); 
#endif 

    /* start the application (web server, rxtest, txtest, etc..) */ 
    xil_printf("Setup Done"); 
    IP4_ADDR(&ip_remote, 192, 168, 1, 11); 

    udp_1 = udp_new(); 

    error = udp_bind(udp_1, IP_ADDR_ANY, Port); 

    if (error != 0) 
    { 
     xil_printf("Failed %d\r\n", error); 
    } 
    else if (error == 0) 
    { 
     xil_printf("Success\r\n"); 
    } 
    error = udp_connect(udp_1, &ip_remote, Port); 
    if (error != 0) 
    { 
     xil_printf("Failed %d\r\n", error); 
    } 
    else if (error == 0) 
    { 
     xil_printf("Success\r\n"); 
    } 


    while (1) 
    { 
     xemacif_input(netif); 
     count++; 
     if (count == 80000) 
     { 
      p = pbuf_alloc(PBUF_TRANSPORT, buflen, PBUF_POOL); 
      if (!p) { 
       xil_printf("error allocating pbuf\r\n"); 
       return ERR_MEM; 
      } 
      memcpy(p->payload, data, buflen); 
      udp_send(udp_1, p); 
      xil_printf("SEND\r\n"); 
      count = 0; 
      pbuf_free(p); 
     } 

    } 

    /* never reached */ 
    cleanup_platform(); 

    return 0; 
} 

---- 편집 :

일단 나는 여기 제공된 시스템을 제거하고 다음 코드를 사용하여 작동하도록 프로그램을 얻을 수 있었다 사람들이 어떻게 그걸 알아 내는지에 대한 답을 남기지 마십시오. 그럼 여기 원어민 코드 (내 생각 엔 ..) 내 문제는 코드 줄 xemacif_input (netif); 이더넷이 arp 호출을 처리 할 수있는 기능을 제공합니다. FPGA는 ARP를 보내고 ARP를 보내지 않으면 ARP 호출을 반복적으로 요청합니다.

이전 코드에 올바른 코드 줄이있는 것으로 보입니다. 따라서 인터럽트가 어떻게 구성되었는지는 실수 일 수 있습니다.

이 예제를 사용하여 프로젝트에서 구현했습니다. 이 점에 관해 궁금한 점이 있으시면 최선을 다해 답변 해 드리겠습니다.