cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Observer
Observer
1,315 Views
Registered: ‎01-03-2013

uartlite interrupt + lwip problems on baremetal zynq

Jump to solution

I have a baremetal (no-OS) server application I have been using for some time now without issues.

 

I am now trying to integrate some external peripherals that have a UART communication interface. I initially attempted to use the uartlite driver in polling mode, but then realized I needed to use interrupts since the messages were longer than 16 characters and I was dropping parts of the message.

 

However, now that I instrumented the interrupt mechanism, as soon as that initializes, my network interface dies. I can't even ping the IP address of the server.

 

I created a preprocessor directive to toggle between enabling uart interrupts and bypass. When the interrupt setup stuff is bypassed, I can ping and talk to the server just fine. I'm basing my implementation on the uartlite driver example uartlite_intr_tapp_example.c.

 

I also confimed that I can transmit valid characters using the uartlite in interrupt mode.

 

Any ideas are much appreciated.

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Observer
Observer
1,394 Views
Registered: ‎01-03-2013

Re: uartlite interrupt + lwip problems on baremetal zynq

Jump to solution

I fixed my problem after much trial and error.

 

Originally I was setting up the LWIP before I initialized my xuartlite devices and assigned interrupt handlers. As soon as I moved this LWIP setup code after the xuartlite initialization to support interrupts, things worked fine. Again this was taken from the echo server example. Hopefully this helps someone down the road...

 

        /* initialize LWIP modules */
	lwip_init();

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

	/* now enable interrupts */
	platform_enable_interrupts();

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

View solution in original post

4 Replies
Highlighted
Mentor
Mentor
1,313 Views
Registered: ‎02-24-2014

Re: uartlite interrupt + lwip problems on baremetal zynq

Jump to solution

You haven't said if your network interface has an interrupt as well.   If it's simply polled only, then perhaps your ISR for the UART is not completely re-entrant.      If your network uses interrupts, then almost certainly the UART setup on the interrupt controller is overwriting the network interrupt configuration.    You'll have to make sure that setup code doesn't do any damage.  

Don't forget to close a thread when possible by accepting a post as a solution.
0 Kudos
Highlighted
Observer
Observer
1,292 Views
Registered: ‎01-03-2013

Re: uartlite interrupt + lwip problems on baremetal zynq

Jump to solution

My application was based on the Echo Server application, which is single threaded. It has a polling loop and utilizes callbacks to handle the data. I'm not aware of what else lwip does under the hood:

 

	/* receive and process packets */
	while (1) {
		if (TcpFastTmrFlag) {
			tcp_fasttmr();
			TcpFastTmrFlag = 0;
		}
		if (TcpSlowTmrFlag) {
			tcp_slowtmr();
			TcpSlowTmrFlag = 0;
		}
		xemacif_input(echo_netif);
		transfer_data();
	}

Interestingly if I put a print statement in this loop after transfer_data() it executes continually, so the application still runs - just won't handle new data.

 

I'm using the Zynq's native network interface ETH0. I assume there is some sort of interrupt internally? Also, the only peripherals using the zynq PL-PS interrupt are ones I instantiated.

 

What are you implying you mean the ISR isn't re-entrant? At the moment my interrupt handlers are more or less empty. FWIW, I'm experiencing this issue w/o any uartlite interrupts firing (I see this issue immediately after setting up for interrupt mode). To be safe, I put some print statements in the send/recv callbacks and disconnected the physical uart pins. Nothing.

 

Fundamentally how does the driver work in this single threaded use case? Does the interrupt fire and immediately the program stops where it is and executes the uartlite callback? I'm new to using interrupts at this low level.

 

0 Kudos
Highlighted
Mentor
Mentor
1,274 Views
Registered: ‎02-24-2014

Re: uartlite interrupt + lwip problems on baremetal zynq

Jump to solution

I guess you need to dig deeper into the echo server code, and look for anything related to interrupts, especially initialization of the interrupt controller.   I'm not familiar with the echo server, so I am really on the edge of my experience here.   Looking at XAPP1026,  they mention interrupts multiple times, so I'm betting that you are hosing the ethernet interrupts when you setup the UART interrupts..    You'll have to dig into that setup routine, and make sure it's compatible with the ethernet interrupts.

Don't forget to close a thread when possible by accepting a post as a solution.
0 Kudos
Highlighted
Observer
Observer
1,395 Views
Registered: ‎01-03-2013

Re: uartlite interrupt + lwip problems on baremetal zynq

Jump to solution

I fixed my problem after much trial and error.

 

Originally I was setting up the LWIP before I initialized my xuartlite devices and assigned interrupt handlers. As soon as I moved this LWIP setup code after the xuartlite initialization to support interrupts, things worked fine. Again this was taken from the echo server example. Hopefully this helps someone down the road...

 

        /* initialize LWIP modules */
	lwip_init();

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

	/* now enable interrupts */
	platform_enable_interrupts();

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

View solution in original post