Dear all:
I use At91sam7x256-ek board to port lwip,
which use Dm9161 PHY, IDE tools is IAR 4.33. If I only initialize the LwIP
stack, I can ping the board. This maybe mean the lwip porting is ok, in this
porting project I only call the lwip functions: sys_init(),
mem_init(), memp_init(), pbuf_init(), netif_init(), tcpip_init(), IP4_ADDR(),
netif_add(), netif_set_default(), netif_set_up().
But when I do more job like writting a HTTP
daemon like belows:
struct netconn *__pstConn,
*__pstNewConn;
struct netbuf *__pstNetbuf;
uprintf("\n\rStart Httpd
Daemon.\r\n");
__pstConn = netconn_new(NETCONN_TCP);
if (NULL
== __pstConn)
{
uprintf("netconn_new NETCONN_TCP
failed\r\n");
OSTaskDel(OS_PRIO_SELF);
return;
}
uprintf("Start
bind to 80 port\r\n");
netconn_bind(__pstConn, NULL,
80);
uprintf("Start
listening\r\n");
netconn_listen(__pstConn);
while(TRUE)
{
__pstNewConn
= netconn_accept(__pstConn);
if(__pstNewConn !=
NULL)
{
__pstNetbuf =
netconn_recv(__pstNewConn);
if(__pstNetbuf !=
NULL)
{
netconn_write(__pstNewConn,
"HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n", 44,
NETCONN_COPY);
netconn_write(__pstNewConn,
"<body><h1>This is LWIP TCP Test!</h1></body>", 40,
NETCONN_COPY);
netbuf_delete(__pstNetbuf);
}
netconn_close(__pstNewConn);
while(netconn_delete(__pstNewConn)
!= ERR_OK)
OSTimeDlyHMSM(0, 0, 1,
0);
}
}
}
after recompiling
and downloading to board, not only ping is not available, but also can not visit
the web page. After adding debug information, I find when I call netconn_new()
function, then turn to function sys_mbox_fetch() function, and then call
sys_arch_timeouts() function which is implemented in sys_arch.c and this time
board never returned.
Who knows why?
Thanks.