diff --git a/sw/sf2-test/main.c b/sw/sf2-test/main.c index b3e6262079453f70d02503a5e7380122d1126991..9b50cd41efcc772958928e64d13c0fd780835fe8 100644 --- a/sw/sf2-test/main.c +++ b/sw/sf2-test/main.c @@ -20,6 +20,7 @@ static enum t_test { TEST_DRAM_DE, TEST_DRAM_SE, + TEST_DRAM_SCRUB, TEST_IRAM_DE, TEST_IRAM_SE, TEST_IRAM_SCRUB, @@ -182,16 +183,20 @@ main (void) switch (next_test) { case TEST_DRAM_DE: + /* Add double-errors */ SUPERVISOR->dram_ecc_mask = 0x03; ecc[0] = 12; ecc[2] = 23; + /* Add single-errors */ SUPERVISOR->dram_ecc_mask = 0x01; ecc[1] = 56; ecc[3] = 78; + /* Do not add errors anymore! */ SUPERVISOR->dram_ecc_mask = 0x00; next_test = TEST_DRAM_SE; /* Order is important! */ asm volatile (""); + /* Trigger a single error */ v = ecc[0]; unreachable(); break; @@ -199,6 +204,7 @@ main (void) case TEST_DRAM_SE: if (SUPERVISOR->dram_ecc_se != 0) unreachable(); + /* Trigger a single error */ v = ecc[1]; if (SUPERVISOR->dram_ecc_se != 1) unreachable(); @@ -206,12 +212,38 @@ main (void) /* Fallthrough */ case TEST_IRAM_DE: - next_test = TEST_IRAM_SE; + next_test = TEST_DRAM_SCRUB; /* Generate a fatal error */ v = *(volatile unsigned *)0xfffc; unreachable(); break; + case TEST_DRAM_SCRUB: + if (SUPERVISOR->dram_scrub_se != 0 + || SUPERVISOR->dram_scrub_de != 0) + unreachable(); + uart_puts("Start DRAM scrubber"); + SUPERVISOR->scrub_cfg = HYDRA_SUPERVISOR_REGS_SCRUB_CFG_DRAM_EN; + next_test = TEST_IRAM_SE; + do { + v = SUPERVISOR->dram_scrub_de; + SUPERVISOR->wd_key = WD_KEY; + } while (v == 0); + /* Because the scrubber is always running, the counter is always + incrementing. So the original value is kept. */ + uart_putc('\n'); + if (SUPERVISOR->dram_scrub_se != 1 || v > 2) { + uart_puts ("se:"); + uart_put_hex8 (SUPERVISOR->dram_scrub_se); + uart_puts (", de:"); + uart_put_hex8 (v); + unreachable(); + } + /* Remove the errors */ + ecc[0] = 0; + ecc[2] = 0; + /* Fallthrough */ + case TEST_IRAM_SE: /* Generate a single error */ v = *(volatile unsigned *)0xfff8;