loop-test on hyperram read/write which needs carriage-return to activate
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 25 Mar 2022 14:50:22 +0000 (14:50 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 25 Mar 2022 14:50:22 +0000 (14:50 +0000)
coldboot/coldboot.c

index 8b746d22f4a66c07a88c2e19544411c44e23b1ee..16de7a8e5bd2f04ba68aadd87d9f3d2ad4e4cb56 100644 (file)
@@ -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");