When I integrated this code into my code I found a strange error. 0x4000 was being inserted in the same place in random ethernet packets. After a lot of investigation I found my culprit - code I got from the demo code.
static void prvRxHandler( void pvNetIf )
/ This is taken from lwIP example code and therefore does not conform
to the FreeRTOS coding standard. */
struct ethhdr *pxHeader;
struct pbuf *p;
unsigned short usInputLength;
static unsigned char ucBuffer[ 1520 ] attribute((aligned(32)));
extern portBASETYPE xInsideISR;
struct netif *pxNetIf = ( struct netif * ) pvNetIf;
XIntc_AckIntr( XPAR_AXI_ETHERNETLITE_0_BASEADDR, XPAR_AXI_ETHERNETLITE_0_IP2INTC_IRPT_MASK );
/* Ensure the pbuf handling functions don't attempt to use critical
usInputLength = ( long ) XEmacLite_Recv( &xEMACInstance, ucBuffer );
This code is from lwIP/netif/ethernetif.c
XIntc_AckIntr( XPAR_AXI_ETHERNETLITE_0_BASEADDR, XPAR_AXI_ETHERNETLITE_0_IP2INTC_IRPT_MASK ); is designed to acknowledge the interrupt but it writes to the Ethernet peripheral instead of the interrupt controller. The place where it writes is in the middle of the outgoing buffer and the MASK has the value of 0x4000 in my code (it may be different in different systems).
The solution is to remove this line entirely as the interrupt acknowledgement is done in the interrupt controller driver and thus the line was irrelevant anyway.
Hopefully this will stop people getting mystery errors in the future.
Thank you for taking the time to report this issue - but I'm having trouble locating the file you are referring to. Is it a file in the main FreeRTOS zip file download, or a file generated by the Xilinx SDK tools?
I'm looking in FreeRTOSDemoMicroBlazeKintex7EthernetLiteRTOSDemosrclwIPDemolwIPportnetif, where I find the following files:
none of which contain a function prvRxHandler().
Thanks in advance for any additional info you can provide.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.