微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 综合技术问答 > EDA使用问答 > FPGA,xilinx,edk利用lwip协议实现以太网数据传输,xemac_add()处停止,没有报错

FPGA,xilinx,edk利用lwip协议实现以太网数据传输,xemac_add()处停止,没有报错

时间:03-15 整理:3721RD 点击:

运行时老是停在xemac_add(echo_netif, &ipaddr, &netmask,&gw, mac_ethernet_address,PLATFORM_EMAC_BASEADDR)部分,在debug下调试,没有报错,也没有现象,求大神解救




  1. #include <stdio.h>

  2. #include "xparameters.h"

  3. #include "netif/xadapter.h"

  4. #include "platform.h"
  5. #include "platform_config.h"
  6. #ifdef __arm__
  7. #include "xil_printf.h"
  8. #endif

  9. /* defined by each RAW mode application */
  10. void print_app_header();
  11. int start_application();
  12. int transfer_data();

  13. /* missing declaration in lwIP */
  14. void lwip_init();

  15. static struct netif server_netif;
  16. struct netif *echo_netif;

  17. void
  18. print_ip(char *msg, struct ip_addr *ip)
  19. {
  20. print(msg);
  21. xil_printf("%d.%d.%d.%d\n\r", ip4_addr1(ip), ip4_addr2(ip),
  22. ip4_addr3(ip), ip4_addr4(ip));
  23. }

  24. void
  25. print_ip_settings(struct ip_addr *ip, struct ip_addr *mask, struct ip_addr *gw)
  26. {

  27. print_ip("Board IP: ", ip);
  28. print_ip("Netmask : ", mask);
  29. print_ip("Gateway : ", gw);
  30. }

  31. int mAIn()
  32. {
  33. struct ip_addr ipaddr, netmask, gw;

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

  37. echo_netif = &server_netif;

  38. init_platform();

  39. /* initliaze IP addresses to be used */
  40. IP4_ADDR(&ipaddr,192, 168,1, 10);
  41. IP4_ADDR(&netmask, 255, 255, 255,0);
  42. IP4_ADDR(&gw,192, 168,1,1);

  43. print_app_header();
  44. print_ip_settings(&ipaddr, &netmask, &gw);

  45. lwip_init();

  46. /* Add network interface to the netif_list, and set it as default */
  47. if (!xemac_add(echo_netif, &ipaddr, &netmask,
  48. &gw, mac_ethernet_address,
  49. PLATFORM_EMAC_BASEADDR)) {
  50. xil_printf("Error adding N/W interface\n\r");
  51. return -1;
  52. }
  53. netif_set_default(echo_netif);

  54. /* Create a new DHCP client for this interface.
  55. * Note: you must call dhcp_fine_tmr() and dhcp_coarse_tmr() at
  56. * the predefined regular intervals after starting the client.
  57. */
  58. /* dhcp_start(echo_netif); */

  59. /* now enable interrupts */
  60. platform_enable_interrupts();

  61. /* specify that the network if is up */
  62. netif_set_up(echo_netif);

  63. /* start the application (web server, rxtest, txtest, etc..) */
  64. start_application();

  65. /* receive and process packets */
  66. while (1) {
  67. xemacif_input(echo_netif);
  68. transfer_data();
  69. }

  70. /* never reached */
  71. cleanup_platform();

  72. return 0;
  73. }



复制代码

最近正在做这个,不知道你的问题解决了吗?

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top