Xilinx / Xilinx/embeddedsw

uartns550: receive interrupt keeps firing (locks up system) if you fail to read all bytes

Open
#37 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
1.2k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

I've modified the uartns550 interrupt example to receive 1 less bytes than sent (and only compare the 99 bytes). Then delay a bit to let the ReceiveTimeout interrupt fire. After you do this, the driver interrupt handler keeps firing and locks up the system. See code below.

https://github.com/Xilinx/embeddedsw/blob/master/XilinxProcessorIPLib/drivers/uartns550/examples/xuartns550_intr_example.c#L284-L319


	/*
	 * Start receiving data before sending it since there is a loopback,
	 * ignoring the number of bytes received as the return value since we
	 * know it will be zero and we are using interrupt mode.
	 */
	XUartNs550_Recv(UartInstancePtr, RecvBuffer, TEST_BUFFER_SIZE-1);

	/*
	 * Send the buffer using the UART and ignore the number of bytes sent
	 * as the return value since we are using it in interrupt mode.
	 */
	XUartNs550_Send(UartInstancePtr, SendBuffer, TEST_BUFFER_SIZE);

	/*
	 * Wait for the entire buffer to be received, letting the interrupt
	 * processing work in the background, this function may get locked
	 * up in this loop if the interrupts are not working correctly.
	 */
	while ((TotalReceivedCount != TEST_BUFFER_SIZE-1) ||
		(TotalSentCount != TEST_BUFFER_SIZE)) {
	}

	/*
	 * Verify the entire receive buffer was successfully received.
	 */
	for (Index = 0; Index < TEST_BUFFER_SIZE-1; Index++) {
		if (RecvBuffer[Index] != SendBuffer[Index]) {
			BadByteCount++;
		}
	}

	/*
	 * Delay a bit (how long? i think the length of 4 character times,
	 * so that the RecieveTimeout interrupt fires, which then gets stuck in a loop.
	 */

	for(Index = 0; Index < 1000000; Index++)
	{
		__asm("or    r0, r0, r0");   /* NOP                     [1 cycle ] */
	}

	/*
	 * Disable the UartNs550 interrupt.
	 */
	UartNs550DisableIntrSystem(IntcInstancePtr, UartIntrId);


	xil_printf("You Will Never Get Here!");

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with XilinxProcessorIPLib/drivers/uartns550/examples/xuartns550_intr_example.c around lines 284-319 and reproduce the case that receives TEST_BUFFER_SIZE-1 bytes, waits for the receive-timeout interrupt, and then spins. Trace the interrupt handling and verify that the example can leave the delay loop, disable the UART interrupt system, and reach the final message without the handler firing indefinitely.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.