From 95fe94063c7a6cf773d4e8afc535138fd1a42c3f Mon Sep 17 00:00:00 2001 From: FallenSigh Date: Fri, 26 Jun 2026 23:53:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20revert=20UART=20FIFO=20batching=20?= =?UTF-8?q?=E2=80=94=20caused=20FIFO=20overflow=20+=20syserr=20on=20board?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit uart_puts(13B) + uart_puthex(8B) = 21 bytes without polling → FIFO overflow. Board UART IP asserts AXI error → CPU syserr exception. Simulation UART model is lenient, so sim passed but board failed. Back to per-byte polling (safe). --- sdk/software/examples/asm/user-sample.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/sdk/software/examples/asm/user-sample.c b/sdk/software/examples/asm/user-sample.c index 40a298c..3653892 100644 --- a/sdk/software/examples/asm/user-sample.c +++ b/sdk/software/examples/asm/user-sample.c @@ -16,31 +16,21 @@ #define UART_THR (*(volatile unsigned char *)0xbf000000) #define UART_LSR (*(volatile unsigned char *)0xbf000005) #define LSR_THRE 0x20 -#define UART_FIFO_DEPTH 16 static inline void uart_tx(unsigned char c) { while (!(UART_LSR & LSR_THRE)) {} UART_THR = c; } -/* Burst-write a null-terminated string — polls only when FIFO may be full */ static void uart_puts(const char *s) { - int n = 0; - while (*s) { - UART_THR = *s++; - if (++n >= UART_FIFO_DEPTH) { - while (!(UART_LSR & LSR_THRE)) {} - n = 0; - } - } + while (*s) uart_tx(*s++); } -/* Write 8 hex digits + suffix in one burst to minimize AXI polls */ static void uart_puthex(unsigned int val) { int i; for (i = 28; i >= 0; i -= 4) { unsigned char nibble = (val >> i) & 0xF; - UART_THR = nibble < 10 ? '0' + nibble : 'a' + nibble - 10; + uart_tx(nibble < 10 ? '0' + nibble : 'a' + nibble - 10); } }