UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Explorer
Explorer
10,758 Views
Registered: ‎11-24-2013

MicroBlaze stops receiving UDP packets with lwIP

Jump to solution

Hi all,

 

I am implementing an echo UDP server wich resends the UDP packets that it receives on a MicroBlaze using lwIPon a Spartan3E, and when I start using it it works fine, but the problem comes when I have received, sometimes 10000, sometimes 35000 packets and it stops working.

 

I have turned on the "debug" mode in lwIP options and this is the only message that I get at this point:

 

pbuf_alloc: allocated pbuf 0x0

pbuf_alloc: allocated pbuf 0x0

pbuf_alloc: allocated pbuf 0x0

[...]

 

I attach my code here. As you can see, it is quite simple. It is based on Xilinx echo example. The only thing that I added was an UDP PCB and the void udp_echo_recv handler for resending the UDP packets.

 

Could anyone help me with this problem?

Thanks you very much.

 

Ignacio Moreno, engineering student.

 

 

CODE:

 

#include <stdio.h>

#include "xparameters.h"

#include "netif/xadapter.h"

#include "platform.h"
#include "platform_config.h"
#ifdef __arm__
#include "xil_printf.h"
#endif

#include "lwip/udp.h"
#include "trigger_prueba.h"

/* missing declaration in lwIP */
void lwip_init();

static struct netif server_netif;
struct netif *echo_netif;

///////My variables
struct udp_pcb *miUdp;
void udp_echo_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port);
//////////////////////




int main()
{
	struct ip_addr ipaddr, netmask, gw;

	/* the mac address of the board. this should be unique per board */
	unsigned char mac_ethernet_address[] =
	{ 0x00, 0x0a, 0x35, 0x00, 0x01, 0x02 };

	echo_netif = &server_netif;

	init_platform();

	/* initliaze IP addresses to be used */
	IP4_ADDR(&ipaddr,  192, 168,   1, 10);
	IP4_ADDR(&netmask, 255, 255, 255,  0);
	IP4_ADDR(&gw,      192, 168,   1,  1);


	lwip_init();

  	/* Add network interface to the netif_list, and set it as default */
	if (!xemac_add(echo_netif, &ipaddr, &netmask,
						&gw, mac_ethernet_address,
						PLATFORM_EMAC_BASEADDR)) {
		xil_printf("Error adding N/W interface\n\r");
		return -1;
	}
	netif_set_default(echo_netif);

	/* now enable interrupts */
	platform_enable_interrupts();

	/* specify that the network if is up */
	netif_set_up(echo_netif);


	//////////////////////////////////////////////MY code
	miUdp = udp_new();
	udp_bind(miUdp, IP_ADDR_ANY,7);

	udp_recv(miUdp, udp_echo_recv, NULL);
	//////////////////////////////////////////////////////////////



	/* receive and process packets */
	while (1) {
		xemacif_input(echo_netif);
	}
  
	/* never reached */
	cleanup_platform();

	return 0;
}


////////////////////////////////////My functions
void udp_echo_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct
	ip_addr *addr, u16_t port)
	{
	    if (p != NULL) {

	        /* send received packet back to sender */
	        udp_sendto(pcb, p, addr, port);
	        /* free the pbuf */
	        pbuf_free(p);

	    }

	    //This lines are for testing a peripheral created by me:
	    TRIGGER_PRUEBA_mWriteReg(XPAR_TRIGGER_PRUEBA_0_BASEADDR, 0, 0xFFFFFFFF);
	    TRIGGER_PRUEBA_mWriteReg(XPAR_TRIGGER_PRUEBA_0_BASEADDR, 0, 0x00000000);

	}
////////////////////////////////////////////////////////////

 

 

0 Kudos
1 Solution

Accepted Solutions
Explorer
Explorer
16,362 Views
Registered: ‎11-24-2013

Re: MicroBlaze stops receiving UDP packets with lwIP

Jump to solution

I finally solved this problem by adding "second receiver buffer" and "second transmitter buffer" on the Ethernet MAc module in Xilinx PLatform Studio.

0 Kudos
10 Replies
Xilinx Employee
Xilinx Employee
10,745 Views
Registered: ‎01-09-2013

Re: MicroBlaze stops receiving UDP packets with lwIP

Jump to solution

Before debugging into the C code, can you make sure that you the Ethenet core license status?

 

If it is an evaluation then the CORE will timeout after certain time.
 

Hope this helps,

 

0 Kudos
Explorer
Explorer
10,730 Views
Registered: ‎11-24-2013

Re: MicroBlaze stops receiving UDP packets with lwIP

Jump to solution

Hi, thanks for your response.

 

I have checked the licenses and everything seems to be ok.

It does not seem to be a timeout issue because the system stops at different times... Sometimes it lasts 7000 packets, sometimes 50000... but it always stops working.

 

Do you know what might cause this problem?

 

Ignacio.

0 Kudos
Explorer
Explorer
16,363 Views
Registered: ‎11-24-2013

Re: MicroBlaze stops receiving UDP packets with lwIP

Jump to solution

I finally solved this problem by adding "second receiver buffer" and "second transmitter buffer" on the Ethernet MAc module in Xilinx PLatform Studio.

0 Kudos
Adventurer
Adventurer
7,435 Views
Registered: ‎10-17-2014

Re: MicroBlaze stops receiving UDP packets with lwIP

Jump to solution
Hi,I also have some problems with the lwIP stack, and i fail to turn into the DEBUG mode.How did you do that?

Thanks
Makon
0 Kudos
Explorer
Explorer
7,351 Views
Registered: ‎11-24-2013

Re: MicroBlaze stops receiving UDP packets with lwIP

Jump to solution

Hi Makon,

 

you have to follow these steps:

 

1) In SDK, double click in "system.mss" under the BSP project.


Unbenannt.PNG

 

2) Then click Modify this BSP's Settings.

 

Unbenannt3.PNG

 

3) Select the tab for the lwip options, go to "debug options" and set to "true" the part of the stack that you want to debug.

 

Unbenannt2.PNG

 

 

4) Rebuild BSP

 

5) Observe the debug output via the system output (generally the UART, serial communication).

 

Regards,

 

Ignacio

Tags (3)
0 Kudos
Observer accord123
Observer
6,882 Views
Registered: ‎07-21-2015

Re: MicroBlaze stops receiving UDP packets with lwIP

Jump to solution

Hello ,

 

I am also facing the same issue with zynq processor.

 

After receiving certain packets, my application is stops receiving the udp packets.

 

You said in the above answers, that  you have added second receive buffer.

 

May i know where you have created and how your using that second receiver buffer for continues receiving.

0 Kudos
Explorer
Explorer
6,870 Views
Registered: ‎11-24-2013

Re: MicroBlaze stops receiving UDP packets with lwIP

Jump to solution

Hello, @accord123,

 

The system I was talking about in this post was designed with XPS. It had a Microblaze and then the peripherals. With XPS you can select the options of the implementation of the periferals, because everything will be in the FPGA, and it happened that there was an option in the peripheral menu to add these buffers.

 

But in your case I'm affraid it's different, because I guess you are using the ethernet module in the Zynq, which is implemented physically in the device and you cannot change its features.

 

Are you using the lwIP library?

 

Regards,

Ignacio

Tags (2)
0 Kudos
Observer accord123
Observer
6,864 Views
Registered: ‎07-21-2015

Re: MicroBlaze stops receiving UDP packets with lwIP

Jump to solution

Hi ,

Thanks for the response.

 Yes, i am using lwip (v2.3) library.

 

0 Kudos
Explorer
Explorer
6,857 Views
Registered: ‎11-24-2013

Re: MicroBlaze stops receiving UDP packets with lwIP

Jump to solution

Hello, @accord123,

 

my suggestion would be to create a simple project in Vivado containing the processing system, then export to SDK, an then modify the BSP to include the lwIP library (by the way, may I ask how you got lwIP 2.3? Here I can just include the 1.4.1). Then, when you create a new SDK project, there's an example project that you can select, the "lwIP Echo Server". You just have to modify the code to set your IP and MAC addresses, and you will get it running in a moment. This should work, and it can help you to compare with your system what wrong is. Also, it's useful to enable the lwIP debug mode in the BSP settings (as explained above).

 

In the XAPP1026 you can find information and explanations about how to use lwIP that maybe you find usefull.

 

Regards,

Ignacio

Tags (2)
0 Kudos
Observer accord123
Observer
1,740 Views
Registered: ‎07-21-2015

Re: MicroBlaze stops receiving UDP packets with lwIP

Jump to solution

Hai imgignacio,

 

Thanks for your suggestion.

 

Actually i did in the same way what you suggested in the above answer.

 

But EMIO based development i have done. The thing is, my application code is processing only 256 packets, after that connection between board and host is getting lost.

 

I have tested code by increasing the buffer size in my own lwip bsp. But there is no improvement in the process.

0 Kudos