[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] Problem with do_writemore() + LWIP for AVR32
From: |
patelbaroda |
Subject: |
Re: [lwip-users] Problem with do_writemore() + LWIP for AVR32 |
Date: |
Wed, 9 Dec 2009 18:16:19 -0800 (PST) |
>From this lwIP init,
/*!
* \brief start lwIP layer.
*/
static void prvlwIPInit( void )
{
sys_sem_t sem;
sem = sys_sem_new(0); // Create a new semaphore.
tcpip_init(tcpip_init_done, &sem);
sys_sem_wait(sem); // Block until the lwIP stack is initialized.
sys_sem_free(sem); // Free the semaphore.
/* Set hw and IP parameters, initialize MACB too */
prvEthernetConfigureInterface(NULL);
}
to prvEthernetConfigureInterface...........
/*!
* \brief set ethernet config
*/
static void prvEthernetConfigureInterface(void * param)
{
struct ip_addr xIpAddr, xNetMask, xGateway;
extern err_t ethernetif_init( struct netif *netif );
unsigned portCHAR MacAddress[6];
portSHORT NbDigits = 0;
unsigned int AddrByte;
portCHAR token[18];
portCHAR * current;
//unsigned char IPAddr[4] = {10, 0, 0, 147};
//unsigned char Gateway[4] = {10,0,0,1};
unsigned char IPAddr[4] = {192, 168, 1, 199};
unsigned char Subnet[4] = {255, 255, 255, 0};
unsigned char Gateway[4] = {192,168,1,1};
GetIPAddress(IPAddr, 0);
GetIPAddress(Subnet, 1);
GetIPAddress(Gateway, 2);
int i = 0;
if (config_file_get_value(ETHERNET_CONFIG_FILE, "macaddr" , token) >= 0)
{
current = token;
while (NbDigits < 6)
{
// get two next bytes and convert as integer
sscanf(current, "%02x", &AddrByte);
MacAddress[NbDigits++] = (portCHAR)AddrByte;
current = strpbrk(current, ":");
if ((current == NULL) && (NbDigits != 6))
{
prv_v_set_default_macaddr( MacAddress );
break;
}
current++;
}
}
else
{
/* can't find field in config file, use default parameters */
prv_v_set_default_macaddr( MacAddress );
}
#if 0
IPAddr[0] = 10;
IPAddr[1] = 0;
IPAddr[2] = 0;
IPAddr[3] = 147;
Gateway[0] = 10;
Gateway[1] = 0;
Gateway[2] = 0;
Gateway[3] = 1;
#endif
//prv_v_set_default_macaddr( MacAddress );
vMACBSetMACAddress( MacAddress );
for (i = 0; i < 6; i++)
MACB_if.hwaddr[i] = MacAddress[i];
if (IsDHCPEnabled())
{
IP4_ADDR( &xIpAddr,0,0,0,0 );
IP4_ADDR( &xNetMask,0,0,0,0 );
IP4_ADDR( &xGateway,0,0,0,0 );
netif_add( &MACB_if, &xIpAddr, &xNetMask, &xGateway, NULL,
ethernetif_init, tcpip_input );
netif_set_default( &MACB_if );
dhcp_start(&MACB_if);
usart_write_line(SHL_USART, "DHCP On\r\n");
}
else
{
IP4_ADDR( &xIpAddr,IPAddr[0],IPAddr[1],IPAddr[2],IPAddr[3] );
IP4_ADDR( &xNetMask,Subnet[0],Subnet[1],Subnet[2],Subnet[3] );
IP4_ADDR( &xGateway,Gateway[0],Gateway[1],Gateway[2],
Gateway[3] );
netif_add( &MACB_if, &xIpAddr, &xNetMask, &xGateway, NULL,
ethernetif_init, tcpip_input );
netif_set_default( &MACB_if );
netif_set_up( &MACB_if );
usart_write_line(SHL_USART, "DHCP Off\r\n");
}
}
DHCP is not enabled and system work with fix IP at present. So netif_add is
called with
ethernetif_init, tcpip_input.
patelbaroda wrote:
>
> I have a web server application on AVR32 with freeRTOS. It has some large
> picture files to transmit with incoming http request. The problem is it
> runs ok some time and crashes many time. The crash points are,
>
> - do_writemore(), it throws LWIP_ASSERT for len <=
> conn->writemsg.msg.w.len
> This function calls tcp_write(). Before calling the len is always =
> conn->writemsg.msg.w.len but after the call conn->writemsg.msg.w.len is
> set to -1 with err = ERR_OK and fires an assert.
>
> - If it doesn't fire assert, it crashes inside tcp_enqueue() at two
> different locations,
> - one at queuelen != 0
> and
> - other is pcb->snd_queuebuf != 0
>
> and fires assert for pcb->unackes != 0 || pcb->unsend != 0
>
> Any hint?
>
> There is only one connection. As I understand, the crash inside
> tcp_enqueue() may be because of two threads (one from incoming request
> through tcp_in.c) and other outgoing request) and needs protection. But as
> newcomer to lwip world, I don't know where to protect.
>
> Still don't understand why it crashes in do_writemore().
>
> I have tcp_wnd set to 24000.
>
> Thanks
>
>
>
>
>
> _______________________________________________
> lwip-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/lwip-users
>
--
View this message in context:
http://old.nabble.com/Problem-with-do_writemore%28%29-%2B-LWIP-for-AVR32-tp26681732p26721145.html
Sent from the lwip-users mailing list archive at Nabble.com.
- [lwip-users] Setting source port number for UDP send, (continued)
- [lwip-users] Setting source port number for UDP send, Marco Jakobs, 2009/12/10
- Re: [lwip-users] Setting source port number for UDP send, David Empson, 2009/12/10
- Re: [lwip-users] Setting source port number for UDP send, Marco Jakobs, 2009/12/11
- Re: [lwip-users] Setting source port number for UDP send, address@hidden, 2009/12/11
- Re: [lwip-users] Setting source port number for UDP send, Marco Jakobs, 2009/12/13
- Re: [lwip-users] Setting source port number for UDP send, Simon Goldschmidt, 2009/12/14
- Re: [lwip-users] Setting source port number for UDP send, Marco Jakobs, 2009/12/15
- [lwip-users] Sending a packet to ETH standard gateway with an active PPP connection, Marco Jakobs, 2009/12/15
- Re: [lwip-users] Sending a packet to ETH standard gateway with an active PPP connection, address@hidden, 2009/12/15
- Re: [lwip-users] Sending a packet to ETH standard gateway with an active PPP connection, Marco Jakobs, 2009/12/15
Re: [lwip-users] Problem with do_writemore() + LWIP for AVR32,
patelbaroda <=