From 19e271a7574b1b35a2df53c81e4f6b4b85db1c96 Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Sat, 22 Feb 2014 20:21:12 +0100 Subject: [PATCH] Fix RAM test (end address was wrong, now it depends on actual RAM size) --- u-boot/common/cmd_mem.c | 22 +++++++++++++++++++++- u-boot/include/configs/ar7240.h | 20 ++++++++++---------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/u-boot/common/cmd_mem.c b/u-boot/common/cmd_mem.c index 487b3bb..46896b9 100755 --- a/u-boot/common/cmd_mem.c +++ b/u-boot/common/cmd_mem.c @@ -37,6 +37,9 @@ CFG_CMD_ITEST | \ CFG_CMD_PCI | \ CMD_CMD_PORTIO) ) + +DECLARE_GLOBAL_DATA_PTR; + /* * Check for a size specification .b, .w or .l. */ @@ -325,6 +328,7 @@ int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){ * interrupted by ctrl-c or by a failure of one of the sub-tests. */ int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){ + bd_t *bd = gd->bd; vu_long *addr, *start, *end; ulong val; ulong readback; @@ -370,14 +374,26 @@ int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){ if(argc > 2){ end = (ulong *)simple_strtoul(argv[2], NULL, 16); } else { - end = (ulong *)(CFG_MEMTEST_END); + end = (ulong *)CFG_MEMTEST_END; + } + + if((uint)start >= (uint)end){ + puts("## Error: end address must be bigger than start address!\n"); + return(1); + } + + if(((uint)start < (uint)CFG_MEMTEST_START) || ((uint)end > (uint)CFG_MEMTEST_END)){ + printf("## Error: start and end addresses should be in 0x%08X...0x%08X range!\n", (uint)CFG_MEMTEST_START, (uint)CFG_MEMTEST_END); + return(1); } +#if !defined(CFG_ALT_MEMTEST) if(argc > 3){ pattern = (ulong)simple_strtoul(argv[3], NULL, 16); } else { pattern = 0; } +#endif #if defined(CFG_ALT_MEMTEST) printf("Testing RAM 0x%08X...0x%08X:\n", (uint)start, (uint)end); @@ -709,7 +725,11 @@ U_BOOT_CMD(md, 3, 1, do_mem_md, "memory display\n", "[.b, .w, .l] address [# of U_BOOT_CMD(mm, 2, 1, do_mem_mm, "memory modify (auto-incrementing)\n", "[.b, .w, .l] address\n\t- memory modify, auto increment address\n"); U_BOOT_CMD(nm, 2, 1, do_mem_nm, "memory modify (constant address)\n", "[.b, .w, .l] address\n\t- memory modify, read and keep address\n"); U_BOOT_CMD(mw, 4, 1, do_mem_mw, "memory write (fill)\n", "[.b, .w, .l] address value [count]\n\t- write memory\n"); +#if defined(CFG_ALT_MEMTEST) +U_BOOT_CMD(mtest, 3, 1, do_mem_mtest, "RAM test\n", "[start [end]]\n\t- complete, alternative RAM test\n"); +#else U_BOOT_CMD(mtest, 4, 1, do_mem_mtest, "simple RAM test\n", "[start [end [pattern]]]\n\t- simple RAM read/write test\n"); +#endif U_BOOT_CMD(cp, 4, 1, do_mem_cp, "memory copy\n", "[.b, .w, .l] source target count\n\t- copy memory\n"); #endif /* CFG_CMD_MEMORY */ diff --git a/u-boot/include/configs/ar7240.h b/u-boot/include/configs/ar7240.h index 23fb89a..ac4af5d 100755 --- a/u-boot/include/configs/ar7240.h +++ b/u-boot/include/configs/ar7240.h @@ -21,16 +21,16 @@ * Miscellaneous configurable options */ #define CFG_ALT_MEMTEST -#define CFG_LONGHELP /* undef to save memory */ -#define CFG_PROMPT "uboot> " /* Monitor Command Prompt */ -#define CFG_CBSIZE 1024 /* Console I/O Buffer Size */ -#define CFG_PBSIZE (CFG_CBSIZE+sizeof(CFG_PROMPT)+16) /* Print Buffer Size, was: def + 16 */ -#define CFG_MAXARGS 16 /* max number of command */ -#define CFG_MALLOC_LEN 512*1024 // def: 128*1024 -#define CFG_BOOTPARAMS_LEN 512*1024 // def: 128 -#define CFG_SDRAM_BASE 0x80000000 /* Cached addr */ -#define CFG_MEMTEST_START 0x80200000 -#define CFG_MEMTEST_END 0x83800000 +#define CFG_LONGHELP /* undef to save memory */ +#define CFG_PROMPT "uboot> " /* Monitor Command Prompt */ +#define CFG_CBSIZE 1024 /* Console I/O Buffer Size */ +#define CFG_PBSIZE (CFG_CBSIZE+sizeof(CFG_PROMPT)+16) /* Print Buffer Size, was: def + 16 */ +#define CFG_MAXARGS 16 /* max number of command */ +#define CFG_MALLOC_LEN 512*1024 /* def: 128*1024 */ +#define CFG_BOOTPARAMS_LEN 512*1024 /* def: 128 */ +#define CFG_SDRAM_BASE 0x80000000 /* Cached addr */ +#define CFG_MEMTEST_START (CFG_SDRAM_BASE + 0x200000) /* RAM test start = CFG_SDRAM_BASE + 2 MB */ +#define CFG_MEMTEST_END (CFG_SDRAM_BASE + bd->bi_memsize - 0x200001) /* RAM test end = CFG_SDRAM_BASE + RAM size - 2 MB - 1 Byte */ #define CFG_RX_ETH_BUFFER 16 #if defined(CONFIG_SILENT_CONSOLE) -- 2.25.1