# FreeRTOS & lwip & heavy traffic

**URL:** <https://forums.freertos.org/t/freertos-lwip-heavy-traffic/1073>\
**Category:** Kernel\
**Created:** [March 3, 2006, 6:52pm UTC](https://forums.freertos.org/t/freertos-lwip-heavy-traffic/1073 "2006-03-03T18:52:00Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 3, 2006, 6:52pm UTC](https://forums.freertos.org/t/freertos-lwip-heavy-traffic/1073/1 "2006-03-03T18:52:00Z")

</div>

**nobody** wrote on [Friday, March 03, 2006](https://sourceforge.net/p/freertos/discussion/382005/thread/2fa51e04/#1e29):

was anyone able to get the lwip demo running on the SAM7X in a relatively high traffic environment (~1000 broadcast packets/s)

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 3, 2006, 7:04pm UTC](https://forums.freertos.org/t/freertos-lwip-heavy-traffic/1073/2 "2006-03-03T19:04:23Z")

</div>

**nobody** wrote on [Friday, March 03, 2006](https://sourceforge.net/p/freertos/discussion/382005/thread/2fa51e04/#1e29/30f1):

Not answering your question really, but may possibly be significant (or not).&nbsp; Have you checked the MAC address of the SAM7X.&nbsp; The default in the code is treated as a multicast address by some routers.

Try changing the MAC address to something that starts 00.

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [March 3, 2006, 7:11pm UTC](https://forums.freertos.org/t/freertos-lwip-heavy-traffic/1073/3 "2006-03-03T19:11:58Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Friday, March 03, 2006](https://sourceforge.net/p/freertos/discussion/382005/thread/2fa51e04/#1e29/af94):

What is your symptom?&nbsp; If you are missing packets then is an errata about to be produced for the SAM7X which may explain this.&nbsp; FreeRTOS V4.0.0 will have a work around that I can post now if you like.

Other than that, check the MAC address being used as already said.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 3, 2006, 7:38pm UTC](https://forums.freertos.org/t/freertos-lwip-heavy-traffic/1073/4 "2006-03-03T19:38:21Z")

</div>

**nobody** wrote on [Friday, March 03, 2006](https://sourceforge.net/p/freertos/discussion/382005/thread/2fa51e04/#1e29/4925):

actually yeah the sam7x statistics registers show dropped packets because of no room in pbuf (EMAC\_RRE register) but I was getting ~2000 counts between my reads of the register.

there’s an errata for it? i didn’t find it ☹ can you post the workaround? thanks

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [March 3, 2006, 8:15pm UTC](https://forums.freertos.org/t/freertos-lwip-heavy-traffic/1073/5 "2006-03-03T20:15:39Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Friday, March 03, 2006](https://sourceforge.net/p/freertos/discussion/382005/thread/2fa51e04/#1e29/4925/790c):

Thats because it has not been published yet!&nbsp; The information is very new.

void vEMACISR( void )  
{  
\_\_\_\_/\* This ISR can cause a context switch, so the first statement must be a  
\_\_\_\_call to the portENTER\_SWITCHING\_ISR() macro.&nbsp; This must be BEFORE any  
\_\_\_\_variable declarations. \*/  
\_\_\_\_portENTER\_SWITCHING\_ISR();

\_\_\_\_/\* Variable definitions can be made now. \*/  
\_\_\_\_volatile unsigned portLONG ulIntStatus, ulEventStatus;  
\_\_\_\_portBASE\_TYPE xSwitchRequired = pdFALSE;  
\_\_\_\_extern void vClearEMACTxBuffer( void );

\_\_\_\_/\* Find the cause of the interrupt. \*/  
\_\_\_\_ulIntStatus = AT91C\_BASE\_EMAC-\>EMAC\_ISR;  
\_\_\_\_ulEventStatus = AT91C\_BASE\_EMAC-\>EMAC\_RSR;

\_\_\_\_if( ( ulIntStatus & AT91C\_EMAC\_RCOMP ) || ( ulEventStatus & AT91C\_EMAC\_REC ) )  
\_\_\_\_{  
\_\_\_\_\_\_\_\_/\* A frame has been received, signal the lwIP task so it can process  
\_\_\_\_\_\_\_\_the Rx descriptors. \*/  
\_\_\_\_\_\_\_\_xSwitchRequired = xSemaphoreGiveFromISR( xSemaphore, pdFALSE );  
\_\_\_\_\_\_\_\_AT91C\_BASE\_EMAC-\>EMAC\_RSR = AT91C\_EMAC\_REC;  
\_\_\_\_}

\_\_\_\_ulEventStatus = AT91C\_BASE\_EMAC-\>EMAC\_TSR;  
\_\_\_\_if( ( ulIntStatus & AT91C\_EMAC\_TCOMP ) || ( ulEventStatus & AT91C\_EMAC\_COMP ) )  
\_\_\_\_{  
\_\_\_\_\_\_\_\_/\* A frame has been transmitted.&nbsp; Mark all the buffers used by the  
\_\_\_\_\_\_\_\_frame just transmitted as free again. \*/  
\_\_\_\_\_\_\_\_vClearEMACTxBuffer();  
\_\_\_\_\_\_\_\_AT91C\_BASE\_EMAC-\>EMAC\_TSR = AT91C\_EMAC\_COMP;  
\_\_\_\_}

\_\_\_\_/\* Clear the interrupt. \*/  
\_\_\_\_AT91C\_BASE\_AIC-\>AIC\_EOICR = 0;

\_\_\_\_/\* If a task was woken by either a frame being received then we may need to  
\_\_\_\_switch to another task. \*/  
\_\_\_\_portEXIT\_SWITCHING\_ISR( xSwitchRequired );  
}

If you compare this ISR with that in the download you will note the use of the ulEventStatus variable is new.&nbsp; This is required as under \*very\* exceptional circumstances the ISR register may report no events pending when there actually are. Checking the other registers (with the ulEventStatus variable) catches this.

Note this may be barking up the wrong tree for your particular problem but worth trying.

Also, not that this is my interpretation of how to fix the problem with the limited information I have.&nbsp; It might be that Atmel provide a better solution in the Errata.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 3, 2006, 8:34pm UTC](https://forums.freertos.org/t/freertos-lwip-heavy-traffic/1073/6 "2006-03-03T20:34:39Z")

</div>

**[moe\_001](https://sourceforge.net/u/moe_001/)** wrote on [Friday, March 03, 2006](https://sourceforge.net/p/freertos/discussion/382005/thread/2fa51e04/#1e29/c7d1):

sorry I failed to read "about to be produced" part of your post 🙂

will give this a try and post my results.

thanks and have nice weekend.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 20, 2006, 5:42pm UTC](https://forums.freertos.org/t/freertos-lwip-heavy-traffic/1073/7 "2006-04-20T17:42:23Z")

</div>

**nobody** wrote on [Thursday, April 20, 2006](https://sourceforge.net/p/freertos/discussion/382005/thread/2fa51e04/#1e29/30f1/5220):

I’ve got an update on this matter. By default the emac is configured in Promiscuous mode (CAF on) once this flag is removed all went well.

What the CAF bit do is copy all valid packets which includes those that are addressed and not addressed to the Sam7x. I would also remove the NBC bit too.

i.e. remove the call

&nbsp;&nbsp;&nbsp; /\* Enable the copy of data into the buffers, and ignore broadcasts. \*/  
&nbsp;&nbsp;&nbsp; AT91C\_BASE\_EMAC-\>EMAC\_NCFGR |= ( AT91C\_EMAC\_CAF | AT91C\_EMAC\_NBC );

from prvSetupDescriptors() func

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 20, 2006, 5:43pm UTC](https://forums.freertos.org/t/freertos-lwip-heavy-traffic/1073/8 "2006-04-20T17:43:17Z")

</div>

**nobody** wrote on [Thursday, April 20, 2006](https://sourceforge.net/p/freertos/discussion/382005/thread/2fa51e04/#1e29/172f):

By default == What’s configured by default in the lwip project

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 20, 2006, 6:33pm UTC](https://forums.freertos.org/t/freertos-lwip-heavy-traffic/1073/9 "2006-04-20T18:33:08Z")

</div>

**nobody** wrote on [Thursday, April 20, 2006](https://sourceforge.net/p/freertos/discussion/382005/thread/2fa51e04/#1e29/67ca):

Magic!
