Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training


Problem with TxDescriptors on at91sam7x512

Posted by jean-luc on October 3, 2008

With a configuration where ethernet transmissions are fast enough (rom data sent with NETCONN_NOCOPY option) I have sometimes a problem of Txdescriptors not available, and all the transmit process is blocked when calling lEMACSend.

After having set several breakpoints, I found that the EMAC TBQP register, which must point on the next free tx descriptor entry after a transmission has been completed, and should correspond to the value of uxNextBufferToClear in function vClearEMACTxBuffer, was sometimes 2 descriptors entries forward, and when vClearEMACTxBuffer is called, the 'buffused' bit of descriptor pointed by uxNextBufferToClear is clear (thus the descriptors are not cleared if they were chained)

where can be the problem ? is it possible that the EMAC has a problem ? or maybe the is a synchronization problem between tx interrupt and tx preparation in lEMACSend ?

thanks for helping...

RE: Problem with TxDescriptors on at91sam7x512

Posted by Richard on October 3, 2008
Its been a while since I looked at that driver. From memory I don't think it handles things like overflow events. Check the ISR that handles the Ethernet to see which interrupts are enabled and which not. You will probably have to enabled the over/underflow interrupts and handle the errors accordingly.


RE: Problem with TxDescriptors on at91sam7x512

Posted by jean-luc on October 3, 2008
thanks for the reply.
I'm working on it with the debugger right now, trying to find a new way of handling end of buffers transmission. the behavior of DMA is not so simple.
I'm wondering why underruns can happen on transmissions .... lazy DMA or silicium problem ?


RE: Problem with TxDescriptors on at91sam7x512

Posted by jean-luc on October 5, 2008
Hi Richard,

I have found the problem, and the solution too, for the trouble with txDescriptors.
Underrun error normally never should happen, but they do because the send function (lEMACSend) has not been optimized for that.

I take a simple example : a buffer is transmitting, and during this time lEMACSend is called for another transmission of 2 consecutive buffers.
the 'BuffUsed' bit of the first buffer is cleared, then, before the second buffer and descriptor has been setup ('Lastbuf' may still be cleared and buffused may be set) the preceeding transmissions finishes, and the DMA picks up the first buffer of the second transmission, then the second, but this one is not complete. at that time we get an underrun error because the DMA has not found a correct second buffer.

To avoid this, the solution is to keep the 'buffUsed' bit of the first buffer to transmit set, and clear it only after having filled all the descriptors, just before setting AT91C_EMAC_TSTART.
I have modified SAM7_EMAC.C file and SAM7_EMAC_ISR.C accordingly, and after several tests, it appears to work perfectly.

I think that it would be important to make these modifications in the next release of FreeRTOS, since if such a problem occurs, further transmissions may be blocked, with txdescriptors busy.

In case of a transmit error, the descriptor pointer is reset to the beginning of table, however uxTxBufferIndex and uxNextBufferToClear are pointing on invalid descriptors. There is an action to take to reset all the descriptors and indexes in case of such error. This is made in lEMACSend too, with a flag set in interrupt routine.

I would be happy to share these modifications, where can I send my files ?


RE: Problem with TxDescriptors on at91sam7x512

Posted by Richard on October 5, 2008
Thanks for taking the time to provide this information. I would be grateful if you could send the changes to r (dot) barry [at] freertos.org.


RE: Problem with TxDescriptors on at91sam7x512

Posted by jean-luc on October 5, 2008
ok, done.

RE: Problem with TxDescriptors on at91sam7x512

Posted by Luca Da Re on May 5, 2011
I have the same problem in my project.
Someone is kind enough to share these changes?

Thanks a lot, Luca

RE: Problem with TxDescriptors on at91sam7x512

Posted by Richard on May 5, 2011
I have various driver updates that have been sent to me over time. If you contact me directly I can send them to you, but I cannot vouch for them in any way as I have not tried them myself. You can find contact details here:


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists