lwip-users
[Top][All Lists]
Advanced

[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: Thu, 10 Dec 2009 06:11:27 -0800 (PST)

So instead of using 

"
netif_add( &MACB_if, &xIpAddr, &xNetMask, &xGateway, NULL, ethernetif_init,
tcpip_input ); netif_set_default( &MACB_if );
netif_set_up( &MACB_if ); 
"

I use,

"
do_netifapi_netif_add();

"

That will add netif in tcpip thread context and probably remove one of the
cause of crash?


/**
 * Call netif_add() inside the tcpip_thread context.
 */
void
do_netifapi_netif_add( struct netifapi_msg_msg *msg)
{
  if (!netif_add( msg->netif,
                  msg->msg.add.ipaddr,
                  msg->msg.add.netmask,
                  msg->msg.add.gw,
                  msg->msg.add.state,
                  msg->msg.add.init,
                  msg->msg.add.input)) {
    msg->err = ERR_IF;
  } else {
    msg->err = ERR_OK;
  }
  TCPIP_NETIFAPI_ACK(msg);
}

or

/**
 * Call netif_add() in a thread-safe way by running that function inside the
 * tcpip_thread context.
 *
 * @note for params @see netif_add()
 */
err_t
netifapi_netif_add(struct netif *netif,
                   struct ip_addr *ipaddr,
                   struct ip_addr *netmask,
                   struct ip_addr *gw,
                   void *state,
                   err_t (* init)(struct netif *netif),
                   err_t (* input)(struct pbuf *p, struct netif *netif))
{
  struct netifapi_msg msg;
  msg.function = do_netifapi_netif_add;
  msg.msg.netif = netif;
  msg.msg.msg.add.ipaddr  = ipaddr;
  msg.msg.msg.add.netmask = netmask;
  msg.msg.msg.add.gw      = gw;
  msg.msg.msg.add.state   = state;
  msg.msg.msg.add.init    = init;
  msg.msg.msg.add.input   = input;
  TCPIP_NETIFAPI(&msg);
  return msg.msg.err;
}


Simon Goldschmidt wrote:
> 
> 
> Ehrm, sending this once is enough ;-)
> 
>> >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);
> 
> The above line leads to calling netif_add() from another thread than
> tcpip_thread! This is not supported! Instead, call
> 'prvEthernetConfigureInterface()' from inside 'tcpip_init_done'.
> 
> The rest of the code looks OK. By setting tcpip_input as input function,
> RX packets get queued into the tcpip_thread before actually being
> processed. There is one more chance of an error here:
> 
> Your ethernet driver has to pass RX pbufs to netif->input() (which
> actually is a pointer to tcpip_input). Some lwIP ports/netif drivers do
> this wrong and call ethernet_input() directly. In this case, RX packets
> are processed in the wrong thread.
> 
> To verify this, could you send the part of your ethernet driver that
> passes received pbufs into the stack?
> 
> Simon
> -- 
> GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
> 
> 
> _______________________________________________
> 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-tp26681732p26727873.html
Sent from the lwip-users mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]