Skip to contentSkip to conversation

common: Iteration limit for memory test.

PATCH Superseded Dirk Eibach 2 participants 2 messages Dec 15, 2008

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---

- 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(-)
common/cmd_mem.c +25 -4
index d7666c2..f87170c 100644
@@ -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"
 );
 
Signature · 1 line
1.5.6.5
#1 lore raw

PATCH 1/1 common: Iteration limit for memory test.

Dear Dirk Eibach,

Quoted 3 lines · In message <[email protected]> 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.

Quoted 38 lines

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.

---

- 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(-)
common/cmd_mem.c +2 -1
index d7666c2..f87170c 100644
@@ -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 */

common/cmd_mem.c int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) · line 730

Quoted 8 lines
common/cmd_mem.c +5 -0
@@ -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.

common/cmd_mem.c int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) · line 751

Quoted 2 lines
common/cmd_mem.c +0 -0
 		printf("Iteration: %6d\r", iterations);
 		PRINTF("Iteration: %6d\n", iterations);

Seems we have some duplicated code here?

common/cmd_mem.c U_BOOT_CMD( · line 1301

Quoted 5 lines
common/cmd_mem.c +1 -3
 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

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
If God wanted me to touch my toes, he'd have put them on my knees.