[PATCH] zynq-uart: Added support to conditionally flush UART before reset.

Lou Woods irnhorse4 at gmail.com
Tue Jan 28 21:41:33 UTC 2020


From: Lou Woods <Lou.Woods at OARCorp.com>

Added support to flush the UART's transmit hardware buffer before
resetting the UART if the transmit enable bit is set initially.

This flush allows for delivery of remaining characters left
behind by the bootloader before the RTEMS init.

It was found that when booting with TFTP from the latest U-Boot for
the Zynq (U-Boot git hash 6cb87cbb1475f668689f95911d1521ee6ba7f55c)
on the Zedboard, the system truncated the TFTP boot messages and
printed invalid characters to the terminal.  This serial corruption
interfered with the RTEMS testsuite output indicating the start
of a test.  Flushing out the TX buffer before resetting the UART
restored the missing TFTP boot messages and stopped the invalid
characters from being printed.
---
 bsps/arm/shared/serial/zynq-uart.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/bsps/arm/shared/serial/zynq-uart.c b/bsps/arm/shared/serial/zynq-uart.c
index 92a8c86..10b32a5 100644
--- a/bsps/arm/shared/serial/zynq-uart.c
+++ b/bsps/arm/shared/serial/zynq-uart.c
@@ -123,6 +123,11 @@ void zynq_uart_initialize(rtems_termios_device_context *base)
   uint32_t brgr = 0x3e;
   uint32_t bauddiv = 0x6;
 
+  if ((regs->control & ZYNQ_UART_CONTROL_TXEN) > 0) {
+    /* Empty the TX buffer in case data is left from the bootloader */
+    zynq_uart_reset_tx_flush(ctx);
+  }
+
   zynq_cal_baud_rate(ZYNQ_UART_DEFAULT_BAUD, &brgr, &bauddiv, regs->mode);
 
   regs->control &= ~(ZYNQ_UART_CONTROL_RXEN | ZYNQ_UART_CONTROL_TXEN);
-- 
1.8.3.1



More information about the devel mailing list