From a3625630f54437e38883d275f36f732cbc9346a5 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Fri, 25 Mar 2022 14:50:22 +0000 Subject: [PATCH] loop-test on hyperram read/write which needs carriage-return to activate --- coldboot/coldboot.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/coldboot/coldboot.c b/coldboot/coldboot.c index 8b746d2..16de7a8 100644 --- a/coldboot/coldboot.c +++ b/coldboot/coldboot.c @@ -45,7 +45,7 @@ void memcpy(void *dest, void *src, size_t n) { void uart_writeuint32(uint32_t val) { const char lut[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - uint8_t *val_arr = &val; + uint8_t *val_arr = (uint8_t*)(&val); size_t i; for (i = 0; i < 4; i++) { @@ -62,18 +62,26 @@ int main(void) { const int kNumIterations = 14; int res, failcnt = 0; uint32_t tmp; - volatile uint32_t *ram = DRAM_BASE; + volatile uint32_t *ram = (uint32_t*)DRAM_BASE; console_init(); //puts("Firmware launched...\n"); puts("fw.."); #if 1 - volatile uint32_t *hyperram = 0xa0000000; - // quick write/read - writel(0xDEAF0000, (unsigned long)&(hyperram[0])); - tmp = readl((unsigned long)&(hyperram[0])); - puts("read "); - uart_writeuint32(tmp); + volatile uint32_t *hyperram = (uint32_t*)0xa0000000; + while (1) { + unsigned char c = getchar(); + putchar(c); + if (c == 13) { // if CR send LF + + // quick write/read + writel(0xDEAF0000, (unsigned long)&(hyperram[0])); + tmp = readl((unsigned long)&(hyperram[0])); + puts("read "); + uart_writeuint32(tmp); + putchar(10); + } + } return 0; #endif @@ -164,7 +172,7 @@ int main(void) { for (size_t i = 0; i < kNumIterations; i++) { if (readl((unsigned long)&(ram[i])) != (0xDEAF0000 | i*4)) { puts("fail : *(0x"); - uart_writeuint32(&ram[i]); + uart_writeuint32((unsigned long)(&ram[i])); puts(") = "); uart_writeuint32(ram[i]); puts("\n"); -- 2.30.2