[U-Boot] [PATCH] common: Iteration limit for memory test.

We want to use mtest for production memory test (though I know it is not recommended). I implemented an iteration limit, so expect can parse the results.
The iteration limit is passed to mtest as a fourth parameter: [start [end [pattern [iterations]]]] If no fourth parameter is supplied, there is no iteration limit and the test will loop forever.
Signed-off-by: Dirk Eibach eibach@gdsys.de ---
- Modified original patch title "Added optional iteration limit for alternative memory test." - Iteration limit is now implemented for both original and alternative memory test.
common/cmd_mem.c | 29 +++++++++++++++++++++++++---- 1 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/common/cmd_mem.c b/common/cmd_mem.c index d7666c2..f87170c 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -672,6 +672,8 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) ulong val; ulong readback; int rcode = 0; + int iterations = 1; + int iteration_limit;
#if defined(CONFIG_SYS_ALT_MEMTEST) vu_long len; @@ -687,7 +689,6 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) vu_long *dummy = 0; /* yes, this is address 0x0, not NULL */ #endif int j; - int iterations = 1;
static const ulong bitpattern[] = { 0x00000001, /* single bit */ @@ -722,6 +723,12 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) pattern = 0; }
+ if (argc > 4) { + iteration_limit = (ulong)simple_strtoul(argv[4], NULL, 16); + } else { + iteration_limit = 0; + } + #if defined(CONFIG_SYS_ALT_MEMTEST) printf ("Testing %08x ... %08x:\n", (uint)start, (uint)end); PRINTF("%s:%d: start 0x%p end 0x%p\n", @@ -733,6 +740,13 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 1; }
+ + if (iteration_limit && iterations > iteration_limit) { + printf ("Tested %d iteration(s) without errors.\n", + iterations-1); + return 0; + } + printf("Iteration: %6d\r", iterations); PRINTF("Iteration: %6d\n", iterations); iterations++; @@ -926,6 +940,13 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 1; }
+ if (iteration_limit && iterations > iteration_limit) { + printf ("Tested %d iteration(s) without errors.\n", + iterations-1); + return 0; + } + ++iterations; + printf ("\rPattern %08lX Writing..." "%12s" "\b\b\b\b\b\b\b\b\b\b", @@ -1277,9 +1298,9 @@ U_BOOT_CMD( #endif /* CONFIG_LOOPW */
U_BOOT_CMD( - mtest, 4, 1, do_mem_mtest, - "mtest - simple RAM test\n", - "[start [end [pattern]]]\n" + mtest, 5, 1, do_mem_mtest, + "mtest - simple RAM test\n", + "[start [end [pattern [iterations]]]]\n" " - simple RAM read/write test\n" );

Dear Dirk Eibach,
In message 1229338818-4209-1-git-send-email-eibach@gdsys.de you wrote:
We want to use mtest for production memory test (though I know it is not recommended). I implemented an iteration limit, so expect can parse the results.
Do you really want to use this text as part of the commit message? Maybe not.
The iteration limit is passed to mtest as a fourth parameter: [start [end [pattern [iterations]]]] If no fourth parameter is supplied, there is no iteration limit and the test will loop forever.
Signed-off-by: Dirk Eibach eibach@gdsys.de
- Modified original patch title "Added optional iteration limit for alternative memory test."
- Iteration limit is now implemented for both original and alternative memory test.
common/cmd_mem.c | 29 +++++++++++++++++++++++++---- 1 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/common/cmd_mem.c b/common/cmd_mem.c index d7666c2..f87170c 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -672,6 +672,8 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) ulong val; ulong readback; int rcode = 0;
- int iterations = 1;
- int iteration_limit;
#if defined(CONFIG_SYS_ALT_MEMTEST) vu_long len; @@ -687,7 +689,6 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) vu_long *dummy = 0; /* yes, this is address 0x0, not NULL */ #endif int j;
int iterations = 1;
static const ulong bitpattern[] = { 0x00000001, /* single bit */
@@ -722,6 +723,12 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) pattern = 0; }
- if (argc > 4) {
iteration_limit = (ulong)simple_strtoul(argv[4], NULL, 16);
- } else {
iteration_limit = 0;
- }
No braces for one-line commands, please.
printf("Iteration: %6d\r", iterations); PRINTF("Iteration: %6d\n", iterations);
Seems we have some duplicated code here?
U_BOOT_CMD(
- mtest, 4, 1, do_mem_mtest,
- "mtest - simple RAM test\n",
- "[start [end [pattern]]]\n"
- mtest, 5, 1, do_mem_mtest,
Please use here TABs for indentation, as in the original code.
Best regards,
Wolfgang Denk
participants (2)
-
Dirk Eibach
-
Wolfgang Denk