From 33fb48584b782bfeb117d2613bae2e0ad8110950 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Boczar?= Date: Mon, 17 May 2021 13:56:31 +0200 Subject: [PATCH] soc/software/libbase: add option for read retries in memtest_data --- litex/soc/software/libbase/memtest.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/litex/soc/software/libbase/memtest.c b/litex/soc/software/libbase/memtest.c index a5c9ef89d..a7d01c6a2 100644 --- a/litex/soc/software/libbase/memtest.c +++ b/litex/soc/software/libbase/memtest.c @@ -15,6 +15,10 @@ #ifndef MEMTEST_DEBUG_MAX_ERRORS #define MEMTEST_DEBUG_MAX_ERRORS 400 #endif +// Retry reading when an error occurs. Allows to spot if errors happen during read or write. +#ifndef MEMTEST_DATA_RETRIES +#define MEMTEST_DATA_RETRIES 0 +#endif #define KIB 1024 #define MIB (KIB*1024) @@ -184,6 +188,7 @@ int memtest_data(unsigned int *addr, unsigned long size, int random, struct memt { volatile unsigned int *array = addr; int i, errors; + int j, ok_at; int progress; unsigned int seed_32; unsigned int rdata; @@ -212,7 +217,18 @@ int memtest_data(unsigned int *addr, unsigned long size, int random, struct memt seed_32 = 1; for(i=0; i 0) + printf("@%p: Redeemed at %d. attempt\n", addr + i, ok_at + 1); + if(rdata != seed_32) { errors++; if (config != NULL && config->on_error != NULL) {