diff --git a/sdk/software/examples/asm/user-sample.c b/sdk/software/examples/asm/user-sample.c index b9096e8..cfa8e97 100644 --- a/sdk/software/examples/asm/user-sample.c +++ b/sdk/software/examples/asm/user-sample.c @@ -10,11 +10,32 @@ * 4. XOR bank toggle → avoids g%2 recomputation per iteration */ -#include #include #include +/* ─── UART 16550 direct access (bypasses slow printf/picolibc) ──────── */ +#define UART_THR (*(volatile uint8_t *)0xbf000000) +#define UART_LSR (*(volatile uint8_t *)0xbf000005) +#define LSR_THRE 0x20 + +static inline void uart_tx(uint8_t c) { + while (!(UART_LSR & LSR_THRE)) {} + UART_THR = c; +} + +static void uart_puts(const char *s) { + while (*s) uart_tx(*s++); +} + +static void uart_puthex(uint32_t val) { + int i; + for (i = 28; i >= 0; i -= 4) { + uint8_t nibble = (val >> i) & 0xF; + uart_tx(nibble < 10 ? '0' + nibble : 'a' + nibble - 10); + } +} + /* ─── Configurable group count (default 5000) ──────────────────────── */ #ifndef MATMUL_GROUP_NUM #define MATMUL_GROUP_NUM 5000 @@ -80,7 +101,7 @@ int main(void) uint32_t ctrl_start[2] = {CTRL_START_B0, CTRL_START_B1}; /* ── Start marker (must be first output) ──────────────────── */ - printf("MATMUL_START\n"); + uart_puts("MATMUL_START\r\n"); // Reset IP state *mat_status = STATUS_DONE | STATUS_ERROR; @@ -186,8 +207,9 @@ int main(void) /* ── Read hardware CRC32 ──────────────────────────────────── */ crc = *mat_crc; - printf("MATMUL_CRC32=%08lx\n", (unsigned long)crc); - printf("MATMUL_DONE\n"); + uart_puts("MATMUL_CRC32="); + uart_puthex(crc); + uart_puts("\r\nMATMUL_DONE\r\n"); return 0; }