QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 4157|回复: 6

移植lwip到44b0的问题

[复制链接]
发表于 2005-9-17 16:26:53 | 显示全部楼层 |阅读模式
我想把skyeye中的lwip移到我的44b0板子上,就是那块公板的44b0,应该很多人有见过。不过我却出现了问题。

我以前移植了一个ucos在我的44b0的板子,然后我想把lwip放在上面,lwip移植的代码基本是照搬skyeye的,包括8019的驱动,

我现在的现象是这个样子,当我ping我的网卡的时候,

uCOS-II Running on a SAMSUNG 44b0x board
Initialising target board
Timer init
targetInit() complete
System initialized.

hello

hello2
TCP/IP initialized.
Applications started.
tcpecho created!Starting target
!!!NET_ISR_BreakPoint.
tcpip_thread

tcpip_thread

tcpip_thread

tcpecho_thread

hello

hello2

hello

hello2

hello

hello2
!!!NET_ISR_BreakPoint.got a packet from low_level_receive
ETHTYPE_ARP
arp_arp_input: ARP request
!!!Enter UNDEFINED. !!!Enter break point.!!!Enter UNDEFINED. !!!Enter break point.



从这个log上看好像网卡已经把包给收进来了,而且判断是ARP的包,然后把包发给p = arp_arp_input(netif, rtl8019if->ethaddr, p);
就出问题,可是我看了看arp_arp_input(netif, rtl8019if->ethaddr, p);这个函数,好像没有什么可能会造成我ucos系统崩溃的因素啊,

struct pbuf *
arp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
{
  struct arp_hdr *hdr;
  u8_t i;
  
  if(p->tot_len < sizeof(struct arp_hdr)) {
    DEBUGF(ARP_DEBUG, ("arp_arp_input: packet too short (%d/%d)\n", p->tot_len, sizeof(struct arp_hdr)));
    pbuf_free(p);
    return NULL;
  }

  hdr = p->payload;
  
  switch(htons(hdr->opcode)) {
  case ARP_REQUEST:
    /* ARP request. If it asked for our address, we send out a
       reply. */
    uHALr_Printf("arp_arp_input: ARP request\n ");
    DEBUGF(ARP_DEBUG, ("arp_arp_input: ARP request\n"));
    if(ip_addr_cmp(&(hdr->dipaddr), &(netif->ip_addr))) {
      
//好像就是在这里死掉的,可是这里的任何处理好像都和我的ucos系统没有多大关系啊??
      
      hdr->opcode = htons(ARP_REPLY);

      ip_addr_set(&(hdr->dipaddr), &(hdr->sipaddr));
      ip_addr_set(&(hdr->sipaddr), &(netif->ip_addr));

      for(i = 0; i < 6; ++i) {
        hdr->dhwaddr.addr = hdr->shwaddr.addr;
        hdr->shwaddr.addr = ethaddr->addr;
        hdr->ethhdr.dest.addr = hdr->dhwaddr.addr;
        hdr->ethhdr.src.addr = ethaddr->addr;
      }

      hdr->hwtype = htons(HWTYPE_ETHERNET);
      ARPH_HWLEN_SET(hdr, 6);
      
      hdr->proto = htons(ETHTYPE_IP);
      ARPH_PROTOLEN_SET(hdr, sizeof(struct ip_addr));      
      
      hdr->ethhdr.type = htons(ETHTYPE_ARP);
      uHALr_Printf("return p\n ");
            
      return p;
    }
    break;
  case ARP_REPLY:   
    /* ARP reply. We insert or update the ARP table. */
    DEBUGF(ARP_DEBUG, ("arp_arp_input: ARP reply\n"));
    if(ip_addr_cmp(&(hdr->dipaddr), &(netif->ip_addr))) {
      add_arp_entry(&(hdr->sipaddr), &(hdr->shwaddr));
#if (LWIP_DHCP && DHCP_DOES_ARP_CHECK)
      dhcp_arp_reply(&hdr->sipaddr);
#endif      
    }
    break;
  default:
    DEBUGF(ARP_DEBUG, ("arp_arp_input: unknown type %d\n", htons(hdr->opcode)));
    break;
  }

  pbuf_free(p);
  return NULL;
}


我如果把//arp_arp_input函数屏蔽掉的话,我的ucos好像是正常的啊,l
og如下:

uCOS-II Running on a SAMSUNG 44b0x board
Initialising target board
Timer init
targetInit() complete
System initialized.

hello

hello2
TCP/IP initialized.
Applications started.
tcpecho created!Starting target
!!!NET_ISR_BreakPoint.
tcpip_thread

tcpip_thread

tcpip_thread

tcpecho_thread
!!!NET_ISR_BreakPoint.got a packet from low_level_receive


hello

hello2

hello

hello2

hello

hello2
!!!NET_ISR_BreakPoint.got a packet from low_level_receive
ETHTYPE_ARP
pbuf_free(p)
!!!NET_ISR_BreakPoint.//我很奇怪的是我已经把中断给屏蔽了为什么还有这个网卡中断。
hello

hello2





我本来考虑是不是中断嵌套的因素,可是我已经在void  ne2k_isr(void)中
void  ne2k_isr{

rINTMSK=( BIT_TIMER0 | BIT_GLOBAL|BIT_EINT1);
....

rINTMSK=~( BIT_TIMER0 | BIT_GLOBAL|BIT_EINT1);


}

可是问题还是一样的啊,??

大侠,给点指点吧,我已经在这个上面耗了一个多月,一点进展都没有啊。
 楼主| 发表于 2005-9-17 16:28:53 | 显示全部楼层
补充一下,我曾经有把网卡收的包print出来,包好像收是正确的啊,唉,困惑啊。
回复

使用道具 举报

发表于 2005-9-17 21:36:16 | 显示全部楼层
移植skyeye网卡驱动时 要注意:发送接收数据时 DMA之前要适当延时
回复

使用道具 举报

发表于 2005-9-18 09:51:58 | 显示全部楼层
移植成功了告诉我们!
回复

使用道具 举报

 楼主| 发表于 2005-9-19 11:26:19 | 显示全部楼层
我本来认为是网卡驱动的原因,所以我后来重新写了一个网卡驱动,不是采用send command 的方式,采用remote DMA的方式,可是现象是一样的啊,应该不是网卡驱动的问题。
回复

使用道具 举报

 楼主| 发表于 2005-10-31 17:37:16 | 显示全部楼层
好久没有来了,这次看了一下,居然还有我的帖子。我的问题早已经解决了。
不过还是说一下,要是有人也做这个的话,可以借鉴一下,主要是字节对齐的原因。如果把字节调整好了,就不会有事了,还有那个NE2000的驱动是可以完全移植的,不需要改变。还有最好到网上早最新版本的lwip,会带来很多好处。
我就是用1。10的版本,sky的lwip版本太低了,不是很成熟。
回复

使用道具 举报

发表于 2006-3-24 16:53:55 | 显示全部楼层
你好,我现在也遇到同样的问题了。
在lwip里的netif.c的netif_set_ipaddr函数中在这个语句里
if (ip_addr_cmp(&(pcb->local_ip), &(netif->ip_addr1))) {
程序就停止了。请问怎么解决这个问题啊!!!求救!!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-5-23 11:46 , Processed in 0.101165 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表