Issue with Microblaze LWIP Example code

timelmg wrote on Thursday, November 19, 2015:

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 eth_hdr *pxHeader;
struct pbuf *p;
unsigned short usInputLength;
static unsigned char ucBuffer[ 1520 ] __attribute__((aligned(32)));
extern portBASE_TYPE 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
	sections. */
	xInsideISR++;

	usInputLength = ( long ) XEmacLite_Recv( &xEMACInstance, ucBuffer );
 ...
 
 

This code is from lwIP/netif/ethernetif.c

The line 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.

Thanks,

Tim

rtel wrote on Thursday, November 19, 2015:

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 \FreeRTOS\Demo\MicroBlaze_Kintex7_EthernetLite\RTOSDemo\src\lwIP_Demo\lwIP_port\netif, where I find the following files:

xadapter.c
xemacliteif.c
xpqueue.c
xtopology_g.c

none of which contain a function prvRxHandler().

Thanks in advance for any additional info you can provide.