lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Help- TCP connection does not work after a some number


From: Mark Lakata
Subject: Re: [lwip-users] Help- TCP connection does not work after a some number of packets are received
Date: Fri, 14 Sep 2012 09:04:58 -0700
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120907 Thunderbird/15.0.1

Jelena,
   sorry, I don't think I can help with your code. It looks very different from the STM32F4xx sample code. You might try downloading that sample code from ST and porting it to your project. I think the ETH interface is similar.  (AP note 3966, Doc ID 022105 Rev 1, stm32f4x7_eth_lwip.zip download).  Then apply my change to that. The fact that your low_level_input uses an xRxSemaphore to make it thread safe worries me, since I don't think more than one thread should be calling it in the first place.  The F4xx stack uses a counting semaphore in the ISR to signal the input thread.

hth,
-Mark

On 9/14/2012 1:26 AM, Jelena Frtunik wrote:
Hi Mar,

Thank you very much for your answer. I am using STM32F107VC. And the ethernetif.c code for me looks like this.

/**
 * Should allocate a pbuf and transfer the bytes of the incoming
 * packet from the interface into the pbuf.
 *
 * @param netif the lwip network interface structure for this ethernetif
 * @return a pbuf filled with the received packet (including MAC header)
 *         NULL on memory error
 */
static struct pbuf *
low_level_input(struct netif *netif)
{
 static xSemaphoreHandle xRxSemaphore = NULL;


  struct pbuf *p, *q;
  u16_t len;
  int l =0;
  FrameTypeDef frame;
  u8 *buffer;
  
  p = NULL;

 if( xRxSemaphore ==NULL)
  {
  vSemaphoreCreateBinary(xRxSemaphore);
  }
 /* access to emac is guarded using a semphore */

 if (xSemaphoreTake(xRxSemaphore, netifGUARD_BLOCK_TIME))
  {
          
          
          
 
  frame = ETH_RxPkt_ChainMode();
  /* Obtain the size of the packet and put it into the "len"
     variable. */
  len = frame.length;
  
  if (len)
  {
  buffer = (u8 *)frame.buffer;

  /* We allocate a pbuf chain of pbufs from the pool. */
  p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
 
  if (p != NULL)
  {
    for (q = p; q != NULL; q = q->next)
    {
 memcpy((u8_t*)q->payload, (u8_t*)&buffer[l], q->len);
      l = l + q->len;
    }    
  
  



  /* Set Own bit of the Rx descriptor Status: gives the buffer back to ETHERNET DMA */
  frame.descriptor->Status = ETH_DMARxDesc_OWN; 
 
  /* When Rx Buffer unavailable flag is set: clear it and resume reception */
  if ((ETH->DMASR & ETH_DMASR_RBUS) != (u32)RESET)  
  {
    /* Clear RBUS ETHERNET DMA flag */
    ETH->DMASR = ETH_DMASR_RBUS;
    /* Resume DMA reception */
    ETH->DMARPDR = 0;
  }
  }
  }
 }
 xSemaphoreGive(xRxSemaphore);
  return p;
}


/**
 * This function should be called when a packet is ready to be read
 * from the interface. It uses the function low_level_input() that
 * should handle the actual reception of bytes from the network
 * interface. Then the type of the received packet is determined and
 * the appropriate input function is called.
 *
 * @param netif the lwip network interface structure for this ethernetif
 */
static void ethernetif_input( void * pvParameters )
{
  struct ethernetif *ethernetif;
  struct eth_hdr *ethhdr;
  struct pbuf *p;

// for( ;; )
{
do
{
ethernetif = s_pxNetIf->state;
/* move received packet into a new pbuf */
p = low_level_input( s_pxNetIf );
if( p == NULL )
{
/* No packet could be read.  Wait a for an interrupt to tell us
there is more data available. */
vEMACWaitForInput();
}
} while( p == NULL );

/* points to packet payload, which starts with an Ethernet header */
ethhdr = p->payload;

#if LINK_STATS
lwip_stats.link.recv++;
#endif /* LINK_STATS */

ethhdr = p->payload;

switch (htons(ethhdr->type))
{
/* IP packet? */
case 256:
case ETHTYPE_IP:
                          /* full packet send to tcpip_thread to process */
if (s_pxNetIf->input(p, s_pxNetIf) != ERR_OK)
{
LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
pbuf_free(p);
p = NULL;
}
break;
      
      case ETHTYPE_ARP:                    
 /* pass p to ARP module  */
       ethernet_input(p, s_pxNetIf);
 break;
default:
 pbuf_free(p);
 p = NULL;
 break;
}
}
}


Could you please help me to try ur approach(I also think that might be the problem)? I could not uinderstand from which variable DMARxFRAME_infos is?

Thank you very veryy much.

Cheers,
Anna

 
Von: Mark Lakata <address@hidden>
An: address@hidden
Gesendet: 19:33 Donnerstag, 13.September 2012
Betreff: Re: [lwip-users] Help- TCP connection does not work after a some number of packets are received

Hi Anna,

You might look at my previous posting from a few minutes ago, where I found a bug in the
STM32F4x7 ethernetif.c drive code. This might cause the code to stop responding, because all of the RX buffers are full but not being emptied.

-Mar

On 9/13/2012 9:42 AM, Jelena Frtunik wrote:
Hi everyone,

I have a system like this: STM32 Board with FreeRTOS and LWip on it (192.168.17.48). On the other side I have a QT GUI (running on Windows address 192.168.17.48) which sends TCP commands to the Board.
After the communication is etsablished and some random number of packets are sent the communication between the two parties does not work. In the attachment I am sending you the obsereved packets via Wireshark.
I am not an expert in LWIP at all, but from the things observed I guess either it is a timing problem (packets are send to fast and no ACK is received) or the reconnection is not successfuly established. Reseting the board helps the problem. 
However in the use case that I am having this should not be done.

Has anyone experianced similar problem? Do I have to change some LWIP options in the lwipopts.h file? Can someone give me tips where to look for the problem?

Thank you very much in advance.

Anna


_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users


_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users



_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users


reply via email to

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