FreeRTOS demo for K60 transmitts ethernet frames twice

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FreeRTOS demo for K60 transmitts ethernet frames twice

1,085 Views
larryc
Contributor II

I've been using the Ethernet code included in the FreeRTOS V8.1 demo for a while in an application, and the outgoing (from the K60) always get sent out twice.  I've tried fixing the obvious things in the driver, and without the "double transmits", it doesn't work.   We don't use the IP stack - we just send out short custom built Ethernet frames to a Linux machine.

Here's the code from the tree.
Thanks

Larry

void vEMACWrite(
void )

{

long x;

        /*
       Wait until the second transmission of the last packet has completed. */

for(x = 0; x < emacTX_WAIT_ATTEMPTS; x++ )

{

if(( xTxDescriptors[ 1 ].status & TX_BD_R ) != 0 )

{

/*
Descriptor is still active. */

vTaskDelay(emacTX_WAIT_DELAY_ms );

}

else

{

break;

}

}

/*
Is the descriptor free after waiting for it? */

if(( xTxDescriptors[ 1 ].status & TX_BD_R ) != 0 )

{

/*
Something has gone wrong. */

prvResetEverything();

}

/*
Setup both descriptors to transmit the frame. */

xTxDescriptors[0 ].data = ( uint8_t * ) __REV( ( unsigned long ) uip_buf );

xTxDescriptors[0 ].length = __REVSH( uip_len );

xTxDescriptors[1 ].data = ( uint8_t * ) __REV( ( unsigned long ) uip_buf );

xTxDescriptors[1 ].length = __REVSH( uip_len );

/*
uip_buf is being sent by the Tx descriptor.
Allocate a new buffer

for
use by the stack. */

uip_buf= prvGetNextBuffer();

/*
Clear previous settings and go. */

xTxDescriptors[0 ].status |= ( TX_BD_R | TX_BD_L );

xTxDescriptors[1 ].status |= ( TX_BD_R | TX_BD_L );

/*
Start the Tx. */

ENET_TDAR= ENET_TDAR_TDAR_MASK;

}

/*-----------------------------------------------------------*/

0 Kudos
3 Replies

745 Views
FreeRTOS_org
Contributor IV

I'm guessing you have based this on a very very old demo that used uIP.  uIP is designed to use the minimum amount of RAM possible (and is very clever at how it achieves that).  That means you can only have one packet outstanding on the network at any one time.  That however makes communication very slow when communicating with a stack that uses delayed acks.  Delayed acks are a standard technique used to minimise network traffic.  The examples provided a basic web server, but when connecting to the web server from Windows, the delayed ack scheme used on Windows meant there is only one packet sent every 200ms - which was painfully slow.  Therefore, each packet was sent twice - that panics Windows into sending its ack immediately - and the web server then appears very fast.

A demo using uIP has not been created in a long time.  FreeRTOS now has its own TCP/IP stack http://www.freertos.org/tcp

0 Kudos

745 Views
larryc
Contributor II

Thanks for your response.  I checked the most recent FreeRTOS demo on the web site (8.2) for K60 and it appears to use the same stack and Ethernet code.  Are there sources of other demos that use other stacks and Ethernet code?  I see other stacks within the EWW project, but the demo that's in there "main-blinky.c" uses the stack with the double transmit code.

Larry

0 Kudos

745 Views
FreeRTOS_org
Contributor IV

Like I said - its a very old demo.  There will be some new Kinetis demos coming along, but probably on different hardware (frdm).  With regards to TCP, our main focus at the moment is our own stack as per the previous link.  We have demos for several hardware platforms (two of which are Cortex-M, one is a Cortex-A) - and will be rolling these out over the coming weeks as and when they are tidied up sufficiently.

0 Kudos