Browse Source

fw: more detailed error messages for downloader

On my system, exactly one single bit error:

0x400003f8 : 0x3a2bea9f expected 0x3a2bea9e

This is the second-to-last halfword in the first SDRAM page, could
have something to do with it...
H. Peter Anvin 3 years ago
parent
commit
a6e8bd9b0e
11 changed files with 2880 additions and 2855 deletions
  1. 1687 1685
      fpga/output_files/max80.jam
  2. BIN
      fpga/output_files/max80.jbc
  3. BIN
      fpga/output_files/max80.jic
  4. 1 1
      fpga/output_files/max80.map
  5. BIN
      fpga/output_files/max80.pof
  6. BIN
      fpga/output_files/max80.sof
  7. 1129 1129
      fw/boot.mif
  8. 3 2
      fw/console.c
  9. 54 36
      fw/hello.c
  10. 6 1
      fw/io.h
  11. 0 1
      fw/iodev.h

File diff suppressed because it is too large
+ 1687 - 1685
fpga/output_files/max80.jam


BIN
fpga/output_files/max80.jbc


BIN
fpga/output_files/max80.jic


+ 1 - 1
fpga/output_files/max80.map

@@ -11,7 +11,7 @@ Quad-Serial configuration device dummy clock cycle: 8
 
 Notes:
 
-- Data checksum for this conversion is 0xF385CAC4
+- Data checksum for this conversion is 0xF385C9C6
 
 - All the addresses in this file are byte addresses
 

BIN
fpga/output_files/max80.pof


BIN
fpga/output_files/max80.sof


File diff suppressed because it is too large
+ 1129 - 1129
fw/boot.mif


+ 3 - 2
fw/console.c

@@ -26,9 +26,10 @@ void con_set_baudrate(uint32_t b)
 
 void con_putc(char c)
 {
+    /* Wait for FIFO space */
     while (CON_STATUS & (1 << 4))
-	/* wait for FIFO to drain some */
-	;
+	pause();
+
     if (c == '\n')
 	CONSOLE = '\r';
     CONSOLE = c;

+ 54 - 36
fw/hello.c

@@ -18,7 +18,7 @@ static void data_check(volatile uint32_t *p, uint32_t expect)
 
     if (readback != expect) {
 	if (rate_limit) {
-	    con_printf("\r\n%p : read %08x expected %08x\r\n",
+	    con_printf("\n%p : read %08x expected %08x\n",
 		       p, readback, expect);
 	    rate_limit--;
 	}
@@ -46,7 +46,7 @@ static void test_sdram(void)
     uint32_t w = 0;
     uint32_t n;
 
-    con_printf("Testing SDRAM from 0x%08x to 0x%08x, stride 0x%08x...\r\n",
+    con_printf("Testing SDRAM from 0x%08x to 0x%08x, stride 0x%08x...\n",
 	       SDRAM_ADDR, SDRAM_END, stride);
 
     err_char = '-';
@@ -69,7 +69,7 @@ static void test_sdram(void)
 	w = (w + stride) & SDRAM_MASK;
     }
 
-    con_puts("\r\nReading back to check for aliases...\r\n");
+    con_puts("\nReading back to check for aliases...\n");
 
     rate_limit = ERROR_RATELIMIT;
     for (n = 1, w = 0; n <= sdram_words; n++) {
@@ -86,7 +86,7 @@ static void test_sdram(void)
 	w = (w - stride) & SDRAM_MASK;
     }
 
-    con_printf("\rSDRAM test complete, time = %u ms\r\n",
+    con_printf("\nSDRAM test complete, time = %u ms\n",
 	       (rdtime() - start_time)/(CPU_HZ/1000));
 
     stride *= 3;
@@ -94,40 +94,24 @@ static void test_sdram(void)
     stride = (stride & ~3) | 4;
 }
 
-#define SDRAM_DONE IODEVRL(2,0)
-
-void main(void)
+static void test_download(void)
 {
-    static const char hello[] = /* "\f\033[2J\033[H" */
-	"\r\n\n*** Hello, World! ***\r\n"
-	"Firmware compiled on: " __DATE__ " " __TIME__ "\r\n\n";
-
-    /* The data section is not reinitialized on reset */
-    static unsigned int loops = 1;
-
-    uint8_t led = 0;
-    uint32_t done;
-
-    con_set_baudrate(115200);
-    set_led(led = 0);
-
-    while (!SDRAM_DONE)
-	/* wait */;
-
-    done = rdtime();
-
-    con_puts(hello);
-
-    con_printf("This is loop: %u\n", loops++);
-    con_printf("SDRAM download took %u us\n", done/(CPU_HZ/1000000));
-
     volatile uint32_t *p = (uint32_t *)SDRAM_ADDR;
     const unsigned int words = 128*1024;
     unsigned int ok = words;
     uint32_t val = 0x00001111;
+    unsigned int ratelimit = ERROR_RATELIMIT;
+
     for (unsigned int w = 0; w < words; w++) {
-	if (*p++ != val)
+	uint32_t ram = *p;
+	if (ram != val) {
 	    ok--;
+	    if (ratelimit) {
+		ratelimit--;
+		con_printf("%p : 0x%08x expected 0x%08x\n", p, ram, val);
+	    }
+	}
+	p++;
 	val = (val * 0x89abcdef) +
 	    (uint32_t)((val * 0x89abcdefULL) >> 32) +
 	    (w * 0x76543210);
@@ -144,15 +128,49 @@ void main(void)
 	}
 	con_putc('\n');
     }
+}
+
+/* Make sure we don't leave anything in SDRAM that could be a false negative */
+static void scrub_sdram(void)
+{
+    volatile uint32_t *p;
+
+    for (p = (uint32_t *)SDRAM_ADDR; p < (uint32_t *)SDRAM_END; p++)
+	*p = 0xdeadbeef;
+}
+
+void main(void)
+{
+    static const char hello[] =
+	"\n*** Hello, World! ***\n"
+	"Firmware compiled on: " __DATE__ " " __TIME__ "\n\n";
+
+    /* The data section is not reinitialized on reset */
+    static unsigned int loops = 1;
+
+    uint8_t led = 0;
+    uint32_t done;
+
+    con_set_baudrate(115200);
+    set_led(led = 0);
+
+    while (!ROMCOPY_DONE)
+	pause();
+
+    done = rdtime();
+
+    con_puts(hello);
+
+    con_printf("This is loop: %u\n", loops++);
+    con_printf("SDRAM download took %u us\n", done/(CPU_HZ/1000000));
 
+    test_download();
     test_sdram();
 
-    p = (uint32_t *)SDRAM_ADDR;
-    for (unsigned int w = 0; w < words; w++)
-	*p++ = 0xdeadbeef;
+    scrub_sdram();
 
-    udelay(4000000);
-    con_puts("*** Doing reset ***\r\n\n");
+    udelay(2000000);
+    con_puts("*** Doing reset ***\n");
     con_flush();
     while ( 1 )
       RESET_CMD = 1;

+ 6 - 1
fw/io.h

@@ -3,6 +3,11 @@
 
 #include "iodev.h"
 
+static inline void pause(void)
+{
+    /* Placeholder for anything that might want to be done while waiting */
+}
+
 static inline void set_led(uint8_t leds)
 {
     LED = leds;
@@ -32,7 +37,7 @@ static inline void udelay(uint32_t us)
     uint32_t start = rdtime();
 
     while (rdtime() - start < cycles)
-	/* wait */;
+	pause();
 }
 
 #endif /* IO_H */

+ 0 - 1
fw/iodev.h

@@ -50,4 +50,3 @@
 #define CON_IRQEN	IODEVL(3,3)
 
 #endif /* IODEV_H */
-

Some files were not shown because too many files changed in this diff