做这个vivi的时候,遇到两个问题,不知道是什么原因:
void NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, int sport, int len) { volatile IP_t *ip = (IP_t *)xip;
/* * If the data is an odd number of bytes, zero the * byte after the last byte so that the checksum * will work. */ if (len & 1) xip[IP_HDR_SIZE + len] = 0;
/* * Construct an IP and UDP header. * (need to set no fragment bit - XXX) */ ip->ip_hl_v = 0x45; /* IP_HDR_SIZE / 4 (not including UDP) */ ip->ip_tos = 0; ip->ip_len = htons(IP_HDR_SIZE + len); ip->ip_id = htons(NetIPID++); ip->ip_off = htons(0x4000); /* No fragmentation */ ip->ip_ttl = 255; ip->ip_p = 17; /* UDP */ ip->ip_sum = 0; NetCopyIP((void*)&ip->ip_src, &NetOurIP); /* already in network byte order */ NetCopyIP((void*)&ip->ip_dst, &dest); /* - "" - */ ip->udp_src = htons(sport); ip->udp_dst = htons(dport); ip->udp_len = htons(8 + len); ip->udp_xsum = 0; ip->ip_sum = ~NetCksum((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2); }
|
如果这里定义为volatile IP_t *ip = (IP_t *)xip;则运行的时候会卡在这里。去掉volatile限定词即可。。
二:
static __inline__ void store_block (unsigned block, uchar * src, size_t len) { ulong offset = block * TftpBlkSize + TftpBlockWrapOffset; ulong newsize = offset + len; int rc=0; rc=write_to_flash(write_addr+offset,len,src,flag); if(rc!=0){ printk("error when write to flash\n"); NetState = NETLOOP_FAIL; return; ...
} }
|
传递给write_to_flash的参数len的值为512.而当程序进入write_to_flash执行后,len值却不是512,变成了一个很大的数。后来改为:
int to=write_addr+offset;
write_to_flash(to,len,src,flag);
后问题解决..
阅读(1635) | 评论(0) | 转发(0) |