SoC common: rtos_sdk: fix uart tx stuck issue [1/3]
PD#SH-20626
Problem:
AOCPU may stuck due to UART TX FIFO full when competition
for UART TX resource occurs between AOCPU and ARM, because
the UART transmission mode is polling mode both for AOCPU and
ARM, AOCPU UART transmission may stuck when there are mass
print logs transmitted by ARM, this may cause a long time
stuck on AOCPU which leads to exception for some drivers.
Solution:
1. Add TX buffer in UART driver to store characters when UART
TX FIFO is full, and the size of TX buffer can be changed.
2. When TX buffer is full, UART driver will discard the
transmitted characters and print warning logs when the
UART TX FIFO is empty.
Verify:
T6D-BR301
Change-Id: Id7a435b9dc9ffd33b53f79e27ec4d88eccc460d3
Signed-off-by: Yao Jie <jie.yao@amlogic.com>
diff --git a/aml/aml_printf.c b/aml/aml_printf.c
index 96fba9e..fa0f9a4 100644
--- a/aml/aml_printf.c
+++ b/aml/aml_printf.c
@@ -10,6 +10,7 @@
#include "serial.h"
#else
#include "uart.h"
+__attribute__((__weak__)) int iUartBufPuts(const char *s);
#endif
#define MAX_BUFFER_LEN 512
@@ -26,23 +27,31 @@
vsnprintf(p, MAX_BUFFER_LEN, fmt, args);
va_end(args);
+#if (1 == CONFIG_ARM64)
while (*p) {
if ('\n' == *p) {
-#if (1 == CONFIG_ARM64)
vSerialPutChar(ConsoleSerial, '\r');
-#else
- vUartPutc('\r');
-#endif
n++;
}
-#if (1 == CONFIG_ARM64)
vSerialPutChar(ConsoleSerial, *p);
-#else
- vUartPutc(*p);
-#endif
n++;
p++;
}
+#else
+ if (iUartBufPuts) {
+ n = iUartBufPuts(printbuffer);
+ } else {
+ while (*p) {
+ if ('\n' == *p) {
+ vUartPutc('\r');
+ n++;
+ }
+ vUartPutc(*p);
+ n++;
+ p++;
+ }
+ }
+#endif
return n;
}