wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | /* |
| 9 | * Memory Functions |
| 10 | * |
| 11 | * Copied from FADS ROM, Dan Malek (dmalek@jlc.net) |
| 12 | */ |
| 13 | |
| 14 | #include <common.h> |
| 15 | #include <command.h> |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 16 | #ifdef CONFIG_HAS_DATAFLASH |
| 17 | #include <dataflash.h> |
| 18 | #endif |
Simon Glass | 0bbd76f | 2013-02-24 20:30:22 +0000 | [diff] [blame] | 19 | #include <hash.h> |
Sergei Poselenov | 474dbb8 | 2008-04-09 16:09:41 +0200 | [diff] [blame] | 20 | #include <watchdog.h> |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 21 | #include <asm/io.h> |
Simon Glass | eacd14f | 2012-11-30 13:01:20 +0000 | [diff] [blame] | 22 | #include <linux/compiler.h> |
| 23 | |
| 24 | DECLARE_GLOBAL_DATA_PTR; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 25 | |
Simon Glass | 1c6c725 | 2013-02-24 17:33:29 +0000 | [diff] [blame] | 26 | #ifndef CONFIG_SYS_MEMTEST_SCRATCH |
| 27 | #define CONFIG_SYS_MEMTEST_SCRATCH 0 |
| 28 | #endif |
| 29 | |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 30 | static int mod_mem(cmd_tbl_t *, int, int, int, char * const []); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 31 | |
| 32 | /* Display values from last command. |
| 33 | * Memory modify remembered values are different from display memory. |
| 34 | */ |
Mike Frysinger | 1a4af8c | 2010-12-22 09:40:29 -0500 | [diff] [blame] | 35 | static uint dp_last_addr, dp_last_size; |
| 36 | static uint dp_last_length = 0x40; |
| 37 | static uint mm_last_addr, mm_last_size; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 38 | |
| 39 | static ulong base_address = 0; |
| 40 | |
| 41 | /* Memory Display |
| 42 | * |
| 43 | * Syntax: |
| 44 | * md{.b, .w, .l} {addr} {len} |
| 45 | */ |
| 46 | #define DISP_LINE_LEN 16 |
Kim Phillips | dc00a68 | 2012-10-29 13:34:31 +0000 | [diff] [blame] | 47 | static int do_mem_md(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 48 | { |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 49 | ulong addr, length; |
Grant Likely | 02a0078 | 2007-02-20 09:05:00 +0100 | [diff] [blame] | 50 | #if defined(CONFIG_HAS_DATAFLASH) |
| 51 | ulong nbytes, linebytes; |
| 52 | #endif |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 53 | int size; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 54 | int rc = 0; |
| 55 | |
| 56 | /* We use the last specified parameters, unless new ones are |
| 57 | * entered. |
| 58 | */ |
| 59 | addr = dp_last_addr; |
| 60 | size = dp_last_size; |
| 61 | length = dp_last_length; |
| 62 | |
Wolfgang Denk | 3b68311 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 63 | if (argc < 2) |
Simon Glass | a06dfc7 | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 64 | return CMD_RET_USAGE; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 65 | |
| 66 | if ((flag & CMD_FLAG_REPEAT) == 0) { |
| 67 | /* New command specified. Check for a size specification. |
| 68 | * Defaults to long if no or incorrect specification. |
| 69 | */ |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 70 | if ((size = cmd_get_data_size(argv[0], 4)) < 0) |
| 71 | return 1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 72 | |
| 73 | /* Address is specified since argc > 1 |
| 74 | */ |
| 75 | addr = simple_strtoul(argv[1], NULL, 16); |
| 76 | addr += base_address; |
| 77 | |
| 78 | /* If another parameter, it is the length to display. |
| 79 | * Length is the number of objects, not number of bytes. |
| 80 | */ |
| 81 | if (argc > 2) |
| 82 | length = simple_strtoul(argv[2], NULL, 16); |
| 83 | } |
| 84 | |
Grant Likely | 02a0078 | 2007-02-20 09:05:00 +0100 | [diff] [blame] | 85 | #if defined(CONFIG_HAS_DATAFLASH) |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 86 | /* Print the lines. |
| 87 | * |
| 88 | * We buffer all read data, so we can make sure data is read only |
| 89 | * once, and all accesses are with the specified bus width. |
| 90 | */ |
| 91 | nbytes = length * size; |
| 92 | do { |
| 93 | char linebuf[DISP_LINE_LEN]; |
Grant Likely | 02a0078 | 2007-02-20 09:05:00 +0100 | [diff] [blame] | 94 | void* p; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 95 | linebytes = (nbytes>DISP_LINE_LEN)?DISP_LINE_LEN:nbytes; |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 96 | |
Grant Likely | 02a0078 | 2007-02-20 09:05:00 +0100 | [diff] [blame] | 97 | rc = read_dataflash(addr, (linebytes/size)*size, linebuf); |
| 98 | p = (rc == DATAFLASH_OK) ? linebuf : (void*)addr; |
| 99 | print_buffer(addr, p, size, linebytes/size, DISP_LINE_LEN/size); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 100 | |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 101 | nbytes -= linebytes; |
Grant Likely | 02a0078 | 2007-02-20 09:05:00 +0100 | [diff] [blame] | 102 | addr += linebytes; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 103 | if (ctrlc()) { |
| 104 | rc = 1; |
| 105 | break; |
| 106 | } |
| 107 | } while (nbytes > 0); |
Grant Likely | 02a0078 | 2007-02-20 09:05:00 +0100 | [diff] [blame] | 108 | #else |
Mike Frysinger | e578d68 | 2008-02-04 19:26:56 -0500 | [diff] [blame] | 109 | |
| 110 | # if defined(CONFIG_BLACKFIN) |
| 111 | /* See if we're trying to display L1 inst */ |
| 112 | if (addr_bfin_on_chip_mem(addr)) { |
| 113 | char linebuf[DISP_LINE_LEN]; |
| 114 | ulong linebytes, nbytes = length * size; |
| 115 | do { |
| 116 | linebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes; |
| 117 | memcpy(linebuf, (void *)addr, linebytes); |
| 118 | print_buffer(addr, linebuf, size, linebytes/size, DISP_LINE_LEN/size); |
| 119 | |
| 120 | nbytes -= linebytes; |
| 121 | addr += linebytes; |
| 122 | if (ctrlc()) { |
| 123 | rc = 1; |
| 124 | break; |
| 125 | } |
| 126 | } while (nbytes > 0); |
| 127 | } else |
| 128 | # endif |
| 129 | |
| 130 | { |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 131 | ulong bytes = size * length; |
| 132 | const void *buf = map_sysmem(addr, bytes); |
| 133 | |
Mike Frysinger | e578d68 | 2008-02-04 19:26:56 -0500 | [diff] [blame] | 134 | /* Print the lines. */ |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 135 | print_buffer(addr, buf, size, length, DISP_LINE_LEN / size); |
| 136 | addr += bytes; |
| 137 | unmap_sysmem(buf); |
Mike Frysinger | e578d68 | 2008-02-04 19:26:56 -0500 | [diff] [blame] | 138 | } |
Grant Likely | 02a0078 | 2007-02-20 09:05:00 +0100 | [diff] [blame] | 139 | #endif |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 140 | |
| 141 | dp_last_addr = addr; |
| 142 | dp_last_length = length; |
| 143 | dp_last_size = size; |
| 144 | return (rc); |
| 145 | } |
| 146 | |
Kim Phillips | dc00a68 | 2012-10-29 13:34:31 +0000 | [diff] [blame] | 147 | static int do_mem_mm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 148 | { |
| 149 | return mod_mem (cmdtp, 1, flag, argc, argv); |
| 150 | } |
Kim Phillips | dc00a68 | 2012-10-29 13:34:31 +0000 | [diff] [blame] | 151 | static int do_mem_nm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 152 | { |
| 153 | return mod_mem (cmdtp, 0, flag, argc, argv); |
| 154 | } |
| 155 | |
Kim Phillips | dc00a68 | 2012-10-29 13:34:31 +0000 | [diff] [blame] | 156 | static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 157 | { |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 158 | ulong addr, writeval, count; |
| 159 | int size; |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 160 | void *buf; |
| 161 | ulong bytes; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 162 | |
Wolfgang Denk | 3b68311 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 163 | if ((argc < 3) || (argc > 4)) |
Simon Glass | a06dfc7 | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 164 | return CMD_RET_USAGE; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 165 | |
| 166 | /* Check for size specification. |
| 167 | */ |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 168 | if ((size = cmd_get_data_size(argv[0], 4)) < 1) |
| 169 | return 1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 170 | |
| 171 | /* Address is specified since argc > 1 |
| 172 | */ |
| 173 | addr = simple_strtoul(argv[1], NULL, 16); |
| 174 | addr += base_address; |
| 175 | |
| 176 | /* Get the value to write. |
| 177 | */ |
| 178 | writeval = simple_strtoul(argv[2], NULL, 16); |
| 179 | |
| 180 | /* Count ? */ |
| 181 | if (argc == 4) { |
| 182 | count = simple_strtoul(argv[3], NULL, 16); |
| 183 | } else { |
| 184 | count = 1; |
| 185 | } |
| 186 | |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 187 | bytes = size * count; |
| 188 | buf = map_sysmem(addr, bytes); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 189 | while (count-- > 0) { |
| 190 | if (size == 4) |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 191 | *((ulong *)buf) = (ulong)writeval; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 192 | else if (size == 2) |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 193 | *((ushort *)buf) = (ushort)writeval; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 194 | else |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 195 | *((u_char *)buf) = (u_char)writeval; |
| 196 | buf += size; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 197 | } |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 198 | unmap_sysmem(buf); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 199 | return 0; |
| 200 | } |
| 201 | |
stroese | fb5e0ac | 2004-12-16 17:42:39 +0000 | [diff] [blame] | 202 | #ifdef CONFIG_MX_CYCLIC |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 203 | int do_mem_mdc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
stroese | fb5e0ac | 2004-12-16 17:42:39 +0000 | [diff] [blame] | 204 | { |
| 205 | int i; |
| 206 | ulong count; |
| 207 | |
Wolfgang Denk | 3b68311 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 208 | if (argc < 4) |
Simon Glass | a06dfc7 | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 209 | return CMD_RET_USAGE; |
stroese | fb5e0ac | 2004-12-16 17:42:39 +0000 | [diff] [blame] | 210 | |
| 211 | count = simple_strtoul(argv[3], NULL, 10); |
| 212 | |
| 213 | for (;;) { |
| 214 | do_mem_md (NULL, 0, 3, argv); |
| 215 | |
| 216 | /* delay for <count> ms... */ |
| 217 | for (i=0; i<count; i++) |
| 218 | udelay (1000); |
| 219 | |
| 220 | /* check for ctrl-c to abort... */ |
| 221 | if (ctrlc()) { |
| 222 | puts("Abort\n"); |
| 223 | return 0; |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | return 0; |
| 228 | } |
| 229 | |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 230 | int do_mem_mwc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
stroese | fb5e0ac | 2004-12-16 17:42:39 +0000 | [diff] [blame] | 231 | { |
| 232 | int i; |
| 233 | ulong count; |
| 234 | |
Wolfgang Denk | 3b68311 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 235 | if (argc < 4) |
Simon Glass | a06dfc7 | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 236 | return CMD_RET_USAGE; |
stroese | fb5e0ac | 2004-12-16 17:42:39 +0000 | [diff] [blame] | 237 | |
| 238 | count = simple_strtoul(argv[3], NULL, 10); |
| 239 | |
| 240 | for (;;) { |
| 241 | do_mem_mw (NULL, 0, 3, argv); |
| 242 | |
| 243 | /* delay for <count> ms... */ |
| 244 | for (i=0; i<count; i++) |
| 245 | udelay (1000); |
| 246 | |
| 247 | /* check for ctrl-c to abort... */ |
| 248 | if (ctrlc()) { |
| 249 | puts("Abort\n"); |
| 250 | return 0; |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | return 0; |
| 255 | } |
| 256 | #endif /* CONFIG_MX_CYCLIC */ |
| 257 | |
Kim Phillips | dc00a68 | 2012-10-29 13:34:31 +0000 | [diff] [blame] | 258 | static int do_mem_cmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 259 | { |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 260 | ulong addr1, addr2, count, ngood, bytes; |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 261 | int size; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 262 | int rcode = 0; |
Mike Frysinger | 62a7ea7 | 2012-01-20 09:07:21 +0000 | [diff] [blame] | 263 | const char *type; |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 264 | const void *buf1, *buf2, *base; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 265 | |
Wolfgang Denk | 3b68311 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 266 | if (argc != 4) |
Simon Glass | a06dfc7 | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 267 | return CMD_RET_USAGE; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 268 | |
| 269 | /* Check for size specification. |
| 270 | */ |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 271 | if ((size = cmd_get_data_size(argv[0], 4)) < 0) |
| 272 | return 1; |
Mike Frysinger | 62a7ea7 | 2012-01-20 09:07:21 +0000 | [diff] [blame] | 273 | type = size == 4 ? "word" : size == 2 ? "halfword" : "byte"; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 274 | |
| 275 | addr1 = simple_strtoul(argv[1], NULL, 16); |
| 276 | addr1 += base_address; |
| 277 | |
| 278 | addr2 = simple_strtoul(argv[2], NULL, 16); |
| 279 | addr2 += base_address; |
| 280 | |
| 281 | count = simple_strtoul(argv[3], NULL, 16); |
| 282 | |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 283 | #ifdef CONFIG_HAS_DATAFLASH |
| 284 | if (addr_dataflash(addr1) | addr_dataflash(addr2)){ |
wdenk | 42c0547 | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 285 | puts ("Comparison with DataFlash space not supported.\n\r"); |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 286 | return 0; |
| 287 | } |
| 288 | #endif |
| 289 | |
Mike Frysinger | e578d68 | 2008-02-04 19:26:56 -0500 | [diff] [blame] | 290 | #ifdef CONFIG_BLACKFIN |
| 291 | if (addr_bfin_on_chip_mem(addr1) || addr_bfin_on_chip_mem(addr2)) { |
| 292 | puts ("Comparison with L1 instruction memory not supported.\n\r"); |
| 293 | return 0; |
| 294 | } |
| 295 | #endif |
| 296 | |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 297 | bytes = size * count; |
| 298 | base = buf1 = map_sysmem(addr1, bytes); |
| 299 | buf2 = map_sysmem(addr2, bytes); |
Mike Frysinger | a66afbd | 2012-01-20 09:07:22 +0000 | [diff] [blame] | 300 | for (ngood = 0; ngood < count; ++ngood) { |
Mike Frysinger | 62a7ea7 | 2012-01-20 09:07:21 +0000 | [diff] [blame] | 301 | ulong word1, word2; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 302 | if (size == 4) { |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 303 | word1 = *(ulong *)buf1; |
| 304 | word2 = *(ulong *)buf2; |
Mike Frysinger | 62a7ea7 | 2012-01-20 09:07:21 +0000 | [diff] [blame] | 305 | } else if (size == 2) { |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 306 | word1 = *(ushort *)buf1; |
| 307 | word2 = *(ushort *)buf2; |
Mike Frysinger | 62a7ea7 | 2012-01-20 09:07:21 +0000 | [diff] [blame] | 308 | } else { |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 309 | word1 = *(u_char *)buf1; |
| 310 | word2 = *(u_char *)buf2; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 311 | } |
Mike Frysinger | 62a7ea7 | 2012-01-20 09:07:21 +0000 | [diff] [blame] | 312 | if (word1 != word2) { |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 313 | ulong offset = buf1 - base; |
| 314 | |
Mike Frysinger | 62a7ea7 | 2012-01-20 09:07:21 +0000 | [diff] [blame] | 315 | printf("%s at 0x%08lx (%#0*lx) != %s at 0x%08lx (%#0*lx)\n", |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 316 | type, (ulong)(addr1 + offset), size, word1, |
| 317 | type, (ulong)(addr2 + offset), size, word2); |
Mike Frysinger | 62a7ea7 | 2012-01-20 09:07:21 +0000 | [diff] [blame] | 318 | rcode = 1; |
| 319 | break; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 320 | } |
Mike Frysinger | 62a7ea7 | 2012-01-20 09:07:21 +0000 | [diff] [blame] | 321 | |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 322 | buf1 += size; |
| 323 | buf2 += size; |
Stefan Roese | d4ef82b | 2010-09-13 11:10:34 +0200 | [diff] [blame] | 324 | |
| 325 | /* reset watchdog from time to time */ |
Mike Frysinger | a66afbd | 2012-01-20 09:07:22 +0000 | [diff] [blame] | 326 | if ((ngood % (64 << 10)) == 0) |
Stefan Roese | d4ef82b | 2010-09-13 11:10:34 +0200 | [diff] [blame] | 327 | WATCHDOG_RESET(); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 328 | } |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 329 | unmap_sysmem(buf1); |
| 330 | unmap_sysmem(buf2); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 331 | |
Mike Frysinger | 62a7ea7 | 2012-01-20 09:07:21 +0000 | [diff] [blame] | 332 | printf("Total of %ld %s(s) were the same\n", ngood, type); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 333 | return rcode; |
| 334 | } |
| 335 | |
Kim Phillips | dc00a68 | 2012-10-29 13:34:31 +0000 | [diff] [blame] | 336 | static int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 337 | { |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 338 | ulong addr, dest, count, bytes; |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 339 | int size; |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 340 | const void *src; |
| 341 | void *buf; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 342 | |
Wolfgang Denk | 3b68311 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 343 | if (argc != 4) |
Simon Glass | a06dfc7 | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 344 | return CMD_RET_USAGE; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 345 | |
| 346 | /* Check for size specification. |
| 347 | */ |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 348 | if ((size = cmd_get_data_size(argv[0], 4)) < 0) |
| 349 | return 1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 350 | |
| 351 | addr = simple_strtoul(argv[1], NULL, 16); |
| 352 | addr += base_address; |
| 353 | |
| 354 | dest = simple_strtoul(argv[2], NULL, 16); |
| 355 | dest += base_address; |
| 356 | |
| 357 | count = simple_strtoul(argv[3], NULL, 16); |
| 358 | |
| 359 | if (count == 0) { |
| 360 | puts ("Zero length ???\n"); |
| 361 | return 1; |
| 362 | } |
| 363 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 364 | #ifndef CONFIG_SYS_NO_FLASH |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 365 | /* check if we are copying to Flash */ |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 366 | if ( (addr2info(dest) != NULL) |
| 367 | #ifdef CONFIG_HAS_DATAFLASH |
Kim B. Heino | 1eb0fd5 | 2008-03-03 10:39:13 +0200 | [diff] [blame] | 368 | && (!addr_dataflash(dest)) |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 369 | #endif |
| 370 | ) { |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 371 | int rc; |
| 372 | |
wdenk | 42c0547 | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 373 | puts ("Copy to Flash... "); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 374 | |
Wolfgang Denk | 7fb5266 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 375 | rc = flash_write ((char *)addr, dest, count*size); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 376 | if (rc != 0) { |
| 377 | flash_perror (rc); |
| 378 | return (1); |
| 379 | } |
| 380 | puts ("done\n"); |
| 381 | return 0; |
| 382 | } |
| 383 | #endif |
| 384 | |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 385 | #ifdef CONFIG_HAS_DATAFLASH |
| 386 | /* Check if we are copying from RAM or Flash to DataFlash */ |
| 387 | if (addr_dataflash(dest) && !addr_dataflash(addr)){ |
| 388 | int rc; |
| 389 | |
wdenk | 42c0547 | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 390 | puts ("Copy to DataFlash... "); |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 391 | |
| 392 | rc = write_dataflash (dest, addr, count*size); |
| 393 | |
| 394 | if (rc != 1) { |
| 395 | dataflash_perror (rc); |
| 396 | return (1); |
| 397 | } |
| 398 | puts ("done\n"); |
| 399 | return 0; |
| 400 | } |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 401 | |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 402 | /* Check if we are copying from DataFlash to RAM */ |
Stelian Pop | a63d2eb | 2008-03-26 22:52:35 +0100 | [diff] [blame] | 403 | if (addr_dataflash(addr) && !addr_dataflash(dest) |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 404 | #ifndef CONFIG_SYS_NO_FLASH |
Stelian Pop | a63d2eb | 2008-03-26 22:52:35 +0100 | [diff] [blame] | 405 | && (addr2info(dest) == NULL) |
| 406 | #endif |
| 407 | ){ |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 408 | int rc; |
| 409 | rc = read_dataflash(addr, count * size, (char *) dest); |
| 410 | if (rc != 1) { |
wdenk | 1ebf41e | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 411 | dataflash_perror (rc); |
| 412 | return (1); |
| 413 | } |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 414 | return 0; |
| 415 | } |
| 416 | |
| 417 | if (addr_dataflash(addr) && addr_dataflash(dest)){ |
wdenk | 42c0547 | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 418 | puts ("Unsupported combination of source/destination.\n\r"); |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 419 | return 1; |
| 420 | } |
wdenk | 7a428cc | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 421 | #endif |
| 422 | |
Mike Frysinger | e578d68 | 2008-02-04 19:26:56 -0500 | [diff] [blame] | 423 | #ifdef CONFIG_BLACKFIN |
| 424 | /* See if we're copying to/from L1 inst */ |
| 425 | if (addr_bfin_on_chip_mem(dest) || addr_bfin_on_chip_mem(addr)) { |
| 426 | memcpy((void *)dest, (void *)addr, count * size); |
| 427 | return 0; |
| 428 | } |
| 429 | #endif |
| 430 | |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 431 | bytes = size * count; |
Masahiro Yamada | 4ad7dd5 | 2013-05-20 21:08:08 +0000 | [diff] [blame] | 432 | buf = map_sysmem(dest, bytes); |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 433 | src = map_sysmem(addr, bytes); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 434 | while (count-- > 0) { |
| 435 | if (size == 4) |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 436 | *((ulong *)buf) = *((ulong *)src); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 437 | else if (size == 2) |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 438 | *((ushort *)buf) = *((ushort *)src); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 439 | else |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 440 | *((u_char *)buf) = *((u_char *)src); |
| 441 | src += size; |
| 442 | buf += size; |
Stefan Roese | d4ef82b | 2010-09-13 11:10:34 +0200 | [diff] [blame] | 443 | |
| 444 | /* reset watchdog from time to time */ |
| 445 | if ((count % (64 << 10)) == 0) |
| 446 | WATCHDOG_RESET(); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 447 | } |
| 448 | return 0; |
| 449 | } |
| 450 | |
Kim Phillips | dc00a68 | 2012-10-29 13:34:31 +0000 | [diff] [blame] | 451 | static int do_mem_base(cmd_tbl_t *cmdtp, int flag, int argc, |
| 452 | char * const argv[]) |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 453 | { |
| 454 | if (argc > 1) { |
| 455 | /* Set new base address. |
| 456 | */ |
| 457 | base_address = simple_strtoul(argv[1], NULL, 16); |
| 458 | } |
| 459 | /* Print the current base address. |
| 460 | */ |
| 461 | printf("Base Address: 0x%08lx\n", base_address); |
| 462 | return 0; |
| 463 | } |
| 464 | |
Kim Phillips | dc00a68 | 2012-10-29 13:34:31 +0000 | [diff] [blame] | 465 | static int do_mem_loop(cmd_tbl_t *cmdtp, int flag, int argc, |
| 466 | char * const argv[]) |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 467 | { |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 468 | ulong addr, length, i, bytes; |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 469 | int size; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 470 | volatile uint *longp; |
| 471 | volatile ushort *shortp; |
| 472 | volatile u_char *cp; |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 473 | const void *buf; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 474 | |
Wolfgang Denk | 3b68311 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 475 | if (argc < 3) |
Simon Glass | a06dfc7 | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 476 | return CMD_RET_USAGE; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 477 | |
Robert P. J. Day | 21c9b78 | 2013-02-03 02:29:54 +0000 | [diff] [blame] | 478 | /* |
| 479 | * Check for a size specification. |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 480 | * Defaults to long if no or incorrect specification. |
| 481 | */ |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 482 | if ((size = cmd_get_data_size(argv[0], 4)) < 0) |
| 483 | return 1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 484 | |
| 485 | /* Address is always specified. |
| 486 | */ |
| 487 | addr = simple_strtoul(argv[1], NULL, 16); |
| 488 | |
| 489 | /* Length is the number of objects, not number of bytes. |
| 490 | */ |
| 491 | length = simple_strtoul(argv[2], NULL, 16); |
| 492 | |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 493 | bytes = size * length; |
| 494 | buf = map_sysmem(addr, bytes); |
| 495 | |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 496 | /* We want to optimize the loops to run as fast as possible. |
| 497 | * If we have only one object, just run infinite loops. |
| 498 | */ |
| 499 | if (length == 1) { |
| 500 | if (size == 4) { |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 501 | longp = (uint *)buf; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 502 | for (;;) |
| 503 | i = *longp; |
| 504 | } |
| 505 | if (size == 2) { |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 506 | shortp = (ushort *)buf; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 507 | for (;;) |
| 508 | i = *shortp; |
| 509 | } |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 510 | cp = (u_char *)buf; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 511 | for (;;) |
| 512 | i = *cp; |
| 513 | } |
| 514 | |
| 515 | if (size == 4) { |
| 516 | for (;;) { |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 517 | longp = (uint *)buf; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 518 | i = length; |
| 519 | while (i-- > 0) |
Marek Vasut | 7d33582 | 2011-09-26 02:26:06 +0200 | [diff] [blame] | 520 | *longp++; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 521 | } |
| 522 | } |
| 523 | if (size == 2) { |
| 524 | for (;;) { |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 525 | shortp = (ushort *)buf; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 526 | i = length; |
| 527 | while (i-- > 0) |
Marek Vasut | 7d33582 | 2011-09-26 02:26:06 +0200 | [diff] [blame] | 528 | *shortp++; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 529 | } |
| 530 | } |
| 531 | for (;;) { |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 532 | cp = (u_char *)buf; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 533 | i = length; |
| 534 | while (i-- > 0) |
Marek Vasut | 7d33582 | 2011-09-26 02:26:06 +0200 | [diff] [blame] | 535 | *cp++; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 536 | } |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 537 | unmap_sysmem(buf); |
Simon Glass | 50d9eb9 | 2013-06-11 11:14:35 -0700 | [diff] [blame] | 538 | |
| 539 | return 0; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 540 | } |
| 541 | |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 542 | #ifdef CONFIG_LOOPW |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 543 | int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 544 | { |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 545 | ulong addr, length, i, data, bytes; |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 546 | int size; |
| 547 | volatile uint *longp; |
| 548 | volatile ushort *shortp; |
| 549 | volatile u_char *cp; |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 550 | void *buf; |
wdenk | 7dd1329 | 2004-07-11 20:04:51 +0000 | [diff] [blame] | 551 | |
Wolfgang Denk | 3b68311 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 552 | if (argc < 4) |
Simon Glass | a06dfc7 | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 553 | return CMD_RET_USAGE; |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 554 | |
Robert P. J. Day | 21c9b78 | 2013-02-03 02:29:54 +0000 | [diff] [blame] | 555 | /* |
| 556 | * Check for a size specification. |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 557 | * Defaults to long if no or incorrect specification. |
| 558 | */ |
| 559 | if ((size = cmd_get_data_size(argv[0], 4)) < 0) |
| 560 | return 1; |
| 561 | |
| 562 | /* Address is always specified. |
| 563 | */ |
| 564 | addr = simple_strtoul(argv[1], NULL, 16); |
| 565 | |
| 566 | /* Length is the number of objects, not number of bytes. |
| 567 | */ |
| 568 | length = simple_strtoul(argv[2], NULL, 16); |
| 569 | |
| 570 | /* data to write */ |
| 571 | data = simple_strtoul(argv[3], NULL, 16); |
wdenk | 7dd1329 | 2004-07-11 20:04:51 +0000 | [diff] [blame] | 572 | |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 573 | bytes = size * length; |
| 574 | buf = map_sysmem(addr, bytes); |
| 575 | |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 576 | /* We want to optimize the loops to run as fast as possible. |
| 577 | * If we have only one object, just run infinite loops. |
| 578 | */ |
| 579 | if (length == 1) { |
| 580 | if (size == 4) { |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 581 | longp = (uint *)buf; |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 582 | for (;;) |
| 583 | *longp = data; |
| 584 | } |
| 585 | if (size == 2) { |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 586 | shortp = (ushort *)buf; |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 587 | for (;;) |
| 588 | *shortp = data; |
| 589 | } |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 590 | cp = (u_char *)buf; |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 591 | for (;;) |
| 592 | *cp = data; |
| 593 | } |
| 594 | |
| 595 | if (size == 4) { |
| 596 | for (;;) { |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 597 | longp = (uint *)buf; |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 598 | i = length; |
| 599 | while (i-- > 0) |
| 600 | *longp++ = data; |
| 601 | } |
| 602 | } |
| 603 | if (size == 2) { |
| 604 | for (;;) { |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 605 | shortp = (ushort *)buf; |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 606 | i = length; |
| 607 | while (i-- > 0) |
| 608 | *shortp++ = data; |
| 609 | } |
| 610 | } |
| 611 | for (;;) { |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 612 | cp = (u_char *)buf; |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 613 | i = length; |
| 614 | while (i-- > 0) |
| 615 | *cp++ = data; |
| 616 | } |
| 617 | } |
| 618 | #endif /* CONFIG_LOOPW */ |
| 619 | |
Tom Rini | a5f0270 | 2013-03-12 10:07:19 -0400 | [diff] [blame] | 620 | #ifdef CONFIG_CMD_MEMTEST |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 621 | static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr, |
| 622 | vu_long *dummy) |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 623 | { |
Simon Glass | 8f2c758 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 624 | vu_long *addr; |
Simon Glass | 8f2c758 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 625 | ulong errs = 0; |
| 626 | ulong val, readback; |
| 627 | int j; |
Simon Glass | 8f2c758 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 628 | vu_long offset; |
| 629 | vu_long test_offset; |
| 630 | vu_long pattern; |
| 631 | vu_long temp; |
| 632 | vu_long anti_pattern; |
| 633 | vu_long num_words; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 634 | static const ulong bitpattern[] = { |
| 635 | 0x00000001, /* single bit */ |
| 636 | 0x00000003, /* two adjacent bits */ |
| 637 | 0x00000007, /* three adjacent bits */ |
| 638 | 0x0000000F, /* four adjacent bits */ |
| 639 | 0x00000005, /* two non-adjacent bits */ |
| 640 | 0x00000015, /* three non-adjacent bits */ |
| 641 | 0x00000055, /* four non-adjacent bits */ |
| 642 | 0xaaaaaaaa, /* alternating 1/0 */ |
| 643 | }; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 644 | |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 645 | num_words = (end_addr - start_addr) / sizeof(vu_long); |
Simon Glass | 5107525 | 2013-02-24 17:33:20 +0000 | [diff] [blame] | 646 | |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 647 | /* |
| 648 | * Data line test: write a pattern to the first |
| 649 | * location, write the 1's complement to a 'parking' |
| 650 | * address (changes the state of the data bus so a |
| 651 | * floating bus doesn't give a false OK), and then |
| 652 | * read the value back. Note that we read it back |
| 653 | * into a variable because the next time we read it, |
| 654 | * it might be right (been there, tough to explain to |
| 655 | * the quality guys why it prints a failure when the |
| 656 | * "is" and "should be" are obviously the same in the |
| 657 | * error message). |
| 658 | * |
| 659 | * Rather than exhaustively testing, we test some |
| 660 | * patterns by shifting '1' bits through a field of |
| 661 | * '0's and '0' bits through a field of '1's (i.e. |
| 662 | * pattern and ~pattern). |
| 663 | */ |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 664 | addr = buf; |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 665 | for (j = 0; j < sizeof(bitpattern) / sizeof(bitpattern[0]); j++) { |
| 666 | val = bitpattern[j]; |
| 667 | for (; val != 0; val <<= 1) { |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 668 | *addr = val; |
Simon Glass | 8f2c758 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 669 | *dummy = ~val; /* clear the test data off the bus */ |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 670 | readback = *addr; |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 671 | if (readback != val) { |
Simon Glass | 8f2c758 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 672 | printf("FAILURE (data line): " |
| 673 | "expected %08lx, actual %08lx\n", |
| 674 | val, readback); |
| 675 | errs++; |
Simon Glass | eb4598b | 2013-02-24 17:33:19 +0000 | [diff] [blame] | 676 | if (ctrlc()) |
Simon Glass | 57ee443 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 677 | return -1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 678 | } |
| 679 | *addr = ~val; |
| 680 | *dummy = val; |
| 681 | readback = *addr; |
Simon Glass | 8f2c758 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 682 | if (readback != ~val) { |
| 683 | printf("FAILURE (data line): " |
| 684 | "Is %08lx, should be %08lx\n", |
| 685 | readback, ~val); |
| 686 | errs++; |
Simon Glass | eb4598b | 2013-02-24 17:33:19 +0000 | [diff] [blame] | 687 | if (ctrlc()) |
Simon Glass | 57ee443 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 688 | return -1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 689 | } |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 690 | } |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 691 | } |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 692 | |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 693 | /* |
| 694 | * Based on code whose Original Author and Copyright |
| 695 | * information follows: Copyright (c) 1998 by Michael |
| 696 | * Barr. This software is placed into the public |
| 697 | * domain and may be used for any purpose. However, |
| 698 | * this notice must not be changed or removed and no |
| 699 | * warranty is either expressed or implied by its |
| 700 | * publication or distribution. |
| 701 | */ |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 702 | |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 703 | /* |
| 704 | * Address line test |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 705 | |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 706 | * Description: Test the address bus wiring in a |
| 707 | * memory region by performing a walking |
| 708 | * 1's test on the relevant bits of the |
| 709 | * address and checking for aliasing. |
| 710 | * This test will find single-bit |
| 711 | * address failures such as stuck-high, |
| 712 | * stuck-low, and shorted pins. The base |
| 713 | * address and size of the region are |
| 714 | * selected by the caller. |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 715 | |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 716 | * Notes: For best results, the selected base |
| 717 | * address should have enough LSB 0's to |
| 718 | * guarantee single address bit changes. |
| 719 | * For example, to test a 64-Kbyte |
| 720 | * region, select a base address on a |
| 721 | * 64-Kbyte boundary. Also, select the |
| 722 | * region size as a power-of-two if at |
| 723 | * all possible. |
| 724 | * |
| 725 | * Returns: 0 if the test succeeds, 1 if the test fails. |
| 726 | */ |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 727 | pattern = (vu_long) 0xaaaaaaaa; |
| 728 | anti_pattern = (vu_long) 0x55555555; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 729 | |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 730 | debug("%s:%d: length = 0x%.8lx\n", __func__, __LINE__, num_words); |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 731 | /* |
| 732 | * Write the default pattern at each of the |
| 733 | * power-of-two offsets. |
| 734 | */ |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 735 | for (offset = 1; offset < num_words; offset <<= 1) |
| 736 | addr[offset] = pattern; |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 737 | |
| 738 | /* |
| 739 | * Check for address bits stuck high. |
| 740 | */ |
| 741 | test_offset = 0; |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 742 | addr[test_offset] = anti_pattern; |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 743 | |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 744 | for (offset = 1; offset < num_words; offset <<= 1) { |
| 745 | temp = addr[offset]; |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 746 | if (temp != pattern) { |
Simon Glass | 8f2c758 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 747 | printf("\nFAILURE: Address bit stuck high @ 0x%.8lx:" |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 748 | " expected 0x%.8lx, actual 0x%.8lx\n", |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 749 | start_addr + offset, pattern, temp); |
Paul Gortmaker | cb47b4f | 2009-10-02 18:18:33 -0400 | [diff] [blame] | 750 | errs++; |
Simon Glass | eb4598b | 2013-02-24 17:33:19 +0000 | [diff] [blame] | 751 | if (ctrlc()) |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 752 | return -1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 753 | } |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 754 | } |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 755 | addr[test_offset] = pattern; |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 756 | WATCHDOG_RESET(); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 757 | |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 758 | /* |
| 759 | * Check for addr bits stuck low or shorted. |
| 760 | */ |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 761 | for (test_offset = 1; test_offset < num_words; test_offset <<= 1) { |
| 762 | addr[test_offset] = anti_pattern; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 763 | |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 764 | for (offset = 1; offset < num_words; offset <<= 1) { |
| 765 | temp = addr[offset]; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 766 | if ((temp != pattern) && (offset != test_offset)) { |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 767 | printf("\nFAILURE: Address bit stuck low or" |
| 768 | " shorted @ 0x%.8lx: expected 0x%.8lx," |
| 769 | " actual 0x%.8lx\n", |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 770 | start_addr + offset, pattern, temp); |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 771 | errs++; |
Simon Glass | eb4598b | 2013-02-24 17:33:19 +0000 | [diff] [blame] | 772 | if (ctrlc()) |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 773 | return -1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 774 | } |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 775 | } |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 776 | addr[test_offset] = pattern; |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 777 | } |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 778 | |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 779 | /* |
| 780 | * Description: Test the integrity of a physical |
| 781 | * memory device by performing an |
| 782 | * increment/decrement test over the |
| 783 | * entire region. In the process every |
| 784 | * storage bit in the device is tested |
| 785 | * as a zero and a one. The base address |
| 786 | * and the size of the region are |
| 787 | * selected by the caller. |
| 788 | * |
| 789 | * Returns: 0 if the test succeeds, 1 if the test fails. |
| 790 | */ |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 791 | num_words++; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 792 | |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 793 | /* |
| 794 | * Fill memory with a known pattern. |
| 795 | */ |
| 796 | for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) { |
| 797 | WATCHDOG_RESET(); |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 798 | addr[offset] = pattern; |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 799 | } |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 800 | |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 801 | /* |
| 802 | * Check each location and invert it for the second pass. |
| 803 | */ |
| 804 | for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) { |
| 805 | WATCHDOG_RESET(); |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 806 | temp = addr[offset]; |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 807 | if (temp != pattern) { |
Simon Glass | 8f2c758 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 808 | printf("\nFAILURE (read/write) @ 0x%.8lx:" |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 809 | " expected 0x%.8lx, actual 0x%.8lx)\n", |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 810 | start_addr + offset, pattern, temp); |
Paul Gortmaker | cb47b4f | 2009-10-02 18:18:33 -0400 | [diff] [blame] | 811 | errs++; |
Simon Glass | eb4598b | 2013-02-24 17:33:19 +0000 | [diff] [blame] | 812 | if (ctrlc()) |
Simon Glass | 57ee443 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 813 | return -1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 814 | } |
| 815 | |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 816 | anti_pattern = ~pattern; |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 817 | addr[offset] = anti_pattern; |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 818 | } |
| 819 | |
| 820 | /* |
| 821 | * Check each location for the inverted pattern and zero it. |
| 822 | */ |
| 823 | for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) { |
| 824 | WATCHDOG_RESET(); |
| 825 | anti_pattern = ~pattern; |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 826 | temp = addr[offset]; |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 827 | if (temp != anti_pattern) { |
Simon Glass | 8f2c758 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 828 | printf("\nFAILURE (read/write): @ 0x%.8lx:" |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 829 | " expected 0x%.8lx, actual 0x%.8lx)\n", |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 830 | start_addr + offset, anti_pattern, temp); |
Paul Gortmaker | cb47b4f | 2009-10-02 18:18:33 -0400 | [diff] [blame] | 831 | errs++; |
Simon Glass | eb4598b | 2013-02-24 17:33:19 +0000 | [diff] [blame] | 832 | if (ctrlc()) |
Simon Glass | 57ee443 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 833 | return -1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 834 | } |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 835 | addr[offset] = 0; |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 836 | } |
Simon Glass | 57ee443 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 837 | |
| 838 | return 0; |
Simon Glass | 8f2c758 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 839 | } |
| 840 | |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 841 | static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr, |
| 842 | vu_long pattern, int iteration) |
Simon Glass | 8f2c758 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 843 | { |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 844 | vu_long *end; |
Simon Glass | 8f2c758 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 845 | vu_long *addr; |
Simon Glass | 8f2c758 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 846 | ulong errs = 0; |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 847 | ulong incr, length; |
Simon Glass | 8f2c758 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 848 | ulong val, readback; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 849 | |
Simon Glass | 57ee443 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 850 | /* Alternate the pattern */ |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 851 | incr = 1; |
Simon Glass | 57ee443 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 852 | if (iteration & 1) { |
| 853 | incr = -incr; |
| 854 | /* |
| 855 | * Flip the pattern each time to make lots of zeros and |
| 856 | * then, the next time, lots of ones. We decrement |
| 857 | * the "negative" patterns and increment the "positive" |
| 858 | * patterns to preserve this feature. |
| 859 | */ |
| 860 | if (pattern & 0x80000000) |
| 861 | pattern = -pattern; /* complement & increment */ |
| 862 | else |
| 863 | pattern = ~pattern; |
| 864 | } |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 865 | length = (end_addr - start_addr) / sizeof(ulong); |
| 866 | end = buf + length; |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 867 | printf("\rPattern %08lX Writing..." |
| 868 | "%12s" |
| 869 | "\b\b\b\b\b\b\b\b\b\b", |
| 870 | pattern, ""); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 871 | |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 872 | for (addr = buf, val = pattern; addr < end; addr++) { |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 873 | WATCHDOG_RESET(); |
| 874 | *addr = val; |
| 875 | val += incr; |
| 876 | } |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 877 | |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 878 | puts("Reading..."); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 879 | |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 880 | for (addr = buf, val = pattern; addr < end; addr++) { |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 881 | WATCHDOG_RESET(); |
| 882 | readback = *addr; |
| 883 | if (readback != val) { |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 884 | ulong offset = addr - buf; |
| 885 | |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 886 | printf("\nMem error @ 0x%08X: " |
| 887 | "found %08lX, expected %08lX\n", |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 888 | (uint)(uintptr_t)(start_addr + offset), |
| 889 | readback, val); |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 890 | errs++; |
Simon Glass | eb4598b | 2013-02-24 17:33:19 +0000 | [diff] [blame] | 891 | if (ctrlc()) |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 892 | return -1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 893 | } |
Simon Glass | 130103e | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 894 | val += incr; |
| 895 | } |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 896 | |
Simon Glass | 57ee443 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 897 | return 0; |
Simon Glass | 8f2c758 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 898 | } |
| 899 | |
| 900 | /* |
| 901 | * Perform a memory test. A more complete alternative test can be |
| 902 | * configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until |
| 903 | * interrupted by ctrl-c or by a failure of one of the sub-tests. |
| 904 | */ |
| 905 | static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, |
| 906 | char * const argv[]) |
| 907 | { |
Simon Glass | 5107525 | 2013-02-24 17:33:20 +0000 | [diff] [blame] | 908 | ulong start, end; |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 909 | vu_long *buf, *dummy; |
Simon Glass | 8f2c758 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 910 | int iteration_limit; |
| 911 | int ret; |
Simon Glass | 57ee443 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 912 | ulong errs = 0; /* number of errors, or -1 if interrupted */ |
Simon Glass | 8f2c758 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 913 | ulong pattern; |
Simon Glass | 57ee443 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 914 | int iteration; |
Simon Glass | 8f2c758 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 915 | #if defined(CONFIG_SYS_ALT_MEMTEST) |
| 916 | const int alt_test = 1; |
| 917 | #else |
| 918 | const int alt_test = 0; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 919 | #endif |
Simon Glass | 8f2c758 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 920 | |
| 921 | if (argc > 1) |
Simon Glass | 5107525 | 2013-02-24 17:33:20 +0000 | [diff] [blame] | 922 | start = simple_strtoul(argv[1], NULL, 16); |
Simon Glass | 8f2c758 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 923 | else |
Simon Glass | 5107525 | 2013-02-24 17:33:20 +0000 | [diff] [blame] | 924 | start = CONFIG_SYS_MEMTEST_START; |
Simon Glass | 8f2c758 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 925 | |
| 926 | if (argc > 2) |
Simon Glass | 5107525 | 2013-02-24 17:33:20 +0000 | [diff] [blame] | 927 | end = simple_strtoul(argv[2], NULL, 16); |
Simon Glass | 8f2c758 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 928 | else |
Simon Glass | 5107525 | 2013-02-24 17:33:20 +0000 | [diff] [blame] | 929 | end = CONFIG_SYS_MEMTEST_END; |
Simon Glass | 8f2c758 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 930 | |
| 931 | if (argc > 3) |
| 932 | pattern = (ulong)simple_strtoul(argv[3], NULL, 16); |
| 933 | else |
| 934 | pattern = 0; |
| 935 | |
| 936 | if (argc > 4) |
| 937 | iteration_limit = (ulong)simple_strtoul(argv[4], NULL, 16); |
| 938 | else |
| 939 | iteration_limit = 0; |
| 940 | |
Simon Glass | 5107525 | 2013-02-24 17:33:20 +0000 | [diff] [blame] | 941 | printf("Testing %08x ... %08x:\n", (uint)start, (uint)end); |
| 942 | debug("%s:%d: start %#08lx end %#08lx\n", __func__, __LINE__, |
| 943 | start, end); |
Simon Glass | 57ee443 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 944 | |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 945 | buf = map_sysmem(start, end - start); |
| 946 | dummy = map_sysmem(CONFIG_SYS_MEMTEST_SCRATCH, sizeof(vu_long)); |
Simon Glass | 57ee443 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 947 | for (iteration = 0; |
| 948 | !iteration_limit || iteration < iteration_limit; |
| 949 | iteration++) { |
| 950 | if (ctrlc()) { |
Simon Glass | 57ee443 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 951 | errs = -1UL; |
| 952 | break; |
| 953 | } |
| 954 | |
| 955 | printf("Iteration: %6d\r", iteration + 1); |
| 956 | debug("\n"); |
Simon Glass | ad02a01 | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 957 | if (alt_test) { |
| 958 | errs = mem_test_alt(buf, start, end, dummy); |
| 959 | } else { |
| 960 | errs = mem_test_quick(buf, start, end, pattern, |
| 961 | iteration); |
| 962 | } |
| 963 | if (errs == -1UL) |
| 964 | break; |
| 965 | } |
| 966 | |
| 967 | /* |
| 968 | * Work-around for eldk-4.2 which gives this warning if we try to |
| 969 | * case in the unmap_sysmem() call: |
| 970 | * warning: initialization discards qualifiers from pointer target type |
| 971 | */ |
| 972 | { |
| 973 | void *vbuf = (void *)buf; |
| 974 | void *vdummy = (void *)dummy; |
| 975 | |
| 976 | unmap_sysmem(vbuf); |
| 977 | unmap_sysmem(vdummy); |
Simon Glass | 57ee443 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 978 | } |
| 979 | |
| 980 | if (errs == -1UL) { |
Simon Glass | eb4598b | 2013-02-24 17:33:19 +0000 | [diff] [blame] | 981 | /* Memory test was aborted - write a newline to finish off */ |
| 982 | putc('\n'); |
Simon Glass | 57ee443 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 983 | ret = 1; |
| 984 | } else { |
| 985 | printf("Tested %d iteration(s) with %lu errors.\n", |
| 986 | iteration, errs); |
| 987 | ret = errs != 0; |
| 988 | } |
Simon Glass | 8f2c758 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 989 | |
| 990 | return ret; /* not reached */ |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 991 | } |
Wolfgang Denk | 9d00928 | 2013-03-08 10:51:32 +0000 | [diff] [blame] | 992 | #endif /* CONFIG_CMD_MEMTEST */ |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 993 | |
| 994 | /* Modify memory. |
| 995 | * |
| 996 | * Syntax: |
| 997 | * mm{.b, .w, .l} {addr} |
| 998 | * nm{.b, .w, .l} {addr} |
| 999 | */ |
| 1000 | static int |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 1001 | mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[]) |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1002 | { |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 1003 | ulong addr, i; |
| 1004 | int nbytes, size; |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 1005 | void *ptr = NULL; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1006 | |
Wolfgang Denk | 3b68311 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 1007 | if (argc != 2) |
Simon Glass | a06dfc7 | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 1008 | return CMD_RET_USAGE; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1009 | |
| 1010 | #ifdef CONFIG_BOOT_RETRY_TIME |
| 1011 | reset_cmd_timeout(); /* got a good command to get here */ |
| 1012 | #endif |
| 1013 | /* We use the last specified parameters, unless new ones are |
| 1014 | * entered. |
| 1015 | */ |
| 1016 | addr = mm_last_addr; |
| 1017 | size = mm_last_size; |
| 1018 | |
| 1019 | if ((flag & CMD_FLAG_REPEAT) == 0) { |
| 1020 | /* New command specified. Check for a size specification. |
| 1021 | * Defaults to long if no or incorrect specification. |
| 1022 | */ |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 1023 | if ((size = cmd_get_data_size(argv[0], 4)) < 0) |
| 1024 | return 1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1025 | |
| 1026 | /* Address is specified since argc > 1 |
| 1027 | */ |
| 1028 | addr = simple_strtoul(argv[1], NULL, 16); |
| 1029 | addr += base_address; |
| 1030 | } |
| 1031 | |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 1032 | #ifdef CONFIG_HAS_DATAFLASH |
| 1033 | if (addr_dataflash(addr)){ |
wdenk | 42c0547 | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 1034 | puts ("Can't modify DataFlash in place. Use cp instead.\n\r"); |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 1035 | return 0; |
| 1036 | } |
| 1037 | #endif |
| 1038 | |
Mike Frysinger | e578d68 | 2008-02-04 19:26:56 -0500 | [diff] [blame] | 1039 | #ifdef CONFIG_BLACKFIN |
| 1040 | if (addr_bfin_on_chip_mem(addr)) { |
| 1041 | puts ("Can't modify L1 instruction in place. Use cp instead.\n\r"); |
| 1042 | return 0; |
| 1043 | } |
| 1044 | #endif |
| 1045 | |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1046 | /* Print the address, followed by value. Then accept input for |
| 1047 | * the next value. A non-converted value exits. |
| 1048 | */ |
| 1049 | do { |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 1050 | ptr = map_sysmem(addr, size); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1051 | printf("%08lx:", addr); |
| 1052 | if (size == 4) |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 1053 | printf(" %08x", *((uint *)ptr)); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1054 | else if (size == 2) |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 1055 | printf(" %04x", *((ushort *)ptr)); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1056 | else |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 1057 | printf(" %02x", *((u_char *)ptr)); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1058 | |
| 1059 | nbytes = readline (" ? "); |
| 1060 | if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) { |
| 1061 | /* <CR> pressed as only input, don't modify current |
| 1062 | * location and move to next. "-" pressed will go back. |
| 1063 | */ |
| 1064 | if (incrflag) |
| 1065 | addr += nbytes ? -size : size; |
| 1066 | nbytes = 1; |
| 1067 | #ifdef CONFIG_BOOT_RETRY_TIME |
| 1068 | reset_cmd_timeout(); /* good enough to not time out */ |
| 1069 | #endif |
| 1070 | } |
| 1071 | #ifdef CONFIG_BOOT_RETRY_TIME |
| 1072 | else if (nbytes == -2) { |
| 1073 | break; /* timed out, exit the command */ |
| 1074 | } |
| 1075 | #endif |
| 1076 | else { |
| 1077 | char *endp; |
| 1078 | i = simple_strtoul(console_buffer, &endp, 16); |
| 1079 | nbytes = endp - console_buffer; |
| 1080 | if (nbytes) { |
| 1081 | #ifdef CONFIG_BOOT_RETRY_TIME |
| 1082 | /* good enough to not time out |
| 1083 | */ |
| 1084 | reset_cmd_timeout(); |
| 1085 | #endif |
| 1086 | if (size == 4) |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 1087 | *((uint *)ptr) = i; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1088 | else if (size == 2) |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 1089 | *((ushort *)ptr) = i; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1090 | else |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 1091 | *((u_char *)ptr) = i; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1092 | if (incrflag) |
| 1093 | addr += size; |
| 1094 | } |
| 1095 | } |
| 1096 | } while (nbytes); |
Simon Glass | e6d0ca2 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 1097 | if (ptr) |
| 1098 | unmap_sysmem(ptr); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1099 | |
| 1100 | mm_last_addr = addr; |
| 1101 | mm_last_size = size; |
| 1102 | return 0; |
| 1103 | } |
| 1104 | |
Mike Frysinger | 321ab9e | 2010-12-21 14:19:51 -0500 | [diff] [blame] | 1105 | #ifdef CONFIG_CMD_CRC32 |
| 1106 | |
Kim Phillips | dc00a68 | 2012-10-29 13:34:31 +0000 | [diff] [blame] | 1107 | static int do_mem_crc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1108 | { |
Simon Glass | 0bbd76f | 2013-02-24 20:30:22 +0000 | [diff] [blame] | 1109 | int flags = 0; |
wdenk | 6203e40 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1110 | int ac; |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 1111 | char * const *av; |
wdenk | 6203e40 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1112 | |
Simon Glass | 0bbd76f | 2013-02-24 20:30:22 +0000 | [diff] [blame] | 1113 | if (argc < 3) |
Simon Glass | a06dfc7 | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 1114 | return CMD_RET_USAGE; |
wdenk | 6203e40 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1115 | |
| 1116 | av = argv + 1; |
| 1117 | ac = argc - 1; |
Simon Glass | 0bbd76f | 2013-02-24 20:30:22 +0000 | [diff] [blame] | 1118 | #ifdef CONFIG_HASH_VERIFY |
wdenk | 6203e40 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1119 | if (strcmp(*av, "-v") == 0) { |
Simon Glass | 0bbd76f | 2013-02-24 20:30:22 +0000 | [diff] [blame] | 1120 | flags |= HASH_FLAG_VERIFY; |
wdenk | 6203e40 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1121 | av++; |
| 1122 | ac--; |
wdenk | 6203e40 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1123 | } |
Simon Glass | 0bbd76f | 2013-02-24 20:30:22 +0000 | [diff] [blame] | 1124 | #endif |
wdenk | 6203e40 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1125 | |
Simon Glass | 0bbd76f | 2013-02-24 20:30:22 +0000 | [diff] [blame] | 1126 | return hash_command("crc32", flags, cmdtp, flag, ac, av); |
wdenk | 6203e40 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1127 | } |
wdenk | 6203e40 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1128 | |
Robin Getz | 93d6cb0 | 2009-07-27 00:07:59 -0400 | [diff] [blame] | 1129 | #endif |
| 1130 | |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1131 | /**************************************************/ |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1132 | U_BOOT_CMD( |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1133 | md, 3, 1, do_mem_md, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1134 | "memory display", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1135 | "[.b, .w, .l] address [# of objects]" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1136 | ); |
| 1137 | |
| 1138 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1139 | U_BOOT_CMD( |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1140 | mm, 2, 1, do_mem_mm, |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1141 | "memory modify (auto-incrementing address)", |
| 1142 | "[.b, .w, .l] address" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1143 | ); |
| 1144 | |
| 1145 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1146 | U_BOOT_CMD( |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1147 | nm, 2, 1, do_mem_nm, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1148 | "memory modify (constant address)", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1149 | "[.b, .w, .l] address" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1150 | ); |
| 1151 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1152 | U_BOOT_CMD( |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1153 | mw, 4, 1, do_mem_mw, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1154 | "memory write (fill)", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1155 | "[.b, .w, .l] address value [count]" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1156 | ); |
| 1157 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1158 | U_BOOT_CMD( |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1159 | cp, 4, 1, do_mem_cp, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1160 | "memory copy", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1161 | "[.b, .w, .l] source target count" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1162 | ); |
| 1163 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1164 | U_BOOT_CMD( |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1165 | cmp, 4, 1, do_mem_cmp, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1166 | "memory compare", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1167 | "[.b, .w, .l] addr1 addr2 count" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1168 | ); |
| 1169 | |
Mike Frysinger | 321ab9e | 2010-12-21 14:19:51 -0500 | [diff] [blame] | 1170 | #ifdef CONFIG_CMD_CRC32 |
| 1171 | |
wdenk | 6203e40 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1172 | #ifndef CONFIG_CRC32_VERIFY |
| 1173 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1174 | U_BOOT_CMD( |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1175 | crc32, 4, 1, do_mem_crc, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1176 | "checksum calculation", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1177 | "address count [addr]\n - compute CRC32 checksum [save at addr]" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1178 | ); |
| 1179 | |
wdenk | 6203e40 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1180 | #else /* CONFIG_CRC32_VERIFY */ |
| 1181 | |
| 1182 | U_BOOT_CMD( |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1183 | crc32, 5, 1, do_mem_crc, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1184 | "checksum calculation", |
wdenk | 6203e40 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1185 | "address count [addr]\n - compute CRC32 checksum [save at addr]\n" |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1186 | "-v address count crc\n - verify crc of memory area" |
wdenk | 6203e40 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1187 | ); |
| 1188 | |
| 1189 | #endif /* CONFIG_CRC32_VERIFY */ |
| 1190 | |
Mike Frysinger | 321ab9e | 2010-12-21 14:19:51 -0500 | [diff] [blame] | 1191 | #endif |
| 1192 | |
Simon Glass | eacd14f | 2012-11-30 13:01:20 +0000 | [diff] [blame] | 1193 | #ifdef CONFIG_CMD_MEMINFO |
| 1194 | __weak void board_show_dram(ulong size) |
| 1195 | { |
| 1196 | puts("DRAM: "); |
| 1197 | print_size(size, "\n"); |
| 1198 | } |
| 1199 | |
| 1200 | static int do_mem_info(cmd_tbl_t *cmdtp, int flag, int argc, |
| 1201 | char * const argv[]) |
| 1202 | { |
| 1203 | board_show_dram(gd->ram_size); |
| 1204 | |
| 1205 | return 0; |
| 1206 | } |
| 1207 | #endif |
| 1208 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1209 | U_BOOT_CMD( |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1210 | base, 2, 1, do_mem_base, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1211 | "print or set address offset", |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1212 | "\n - print address offset for memory commands\n" |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1213 | "base off\n - set address offset for memory commands to 'off'" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1214 | ); |
| 1215 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1216 | U_BOOT_CMD( |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1217 | loop, 3, 1, do_mem_loop, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1218 | "infinite loop on address range", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1219 | "[.b, .w, .l] address number_of_objects" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1220 | ); |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 1221 | |
| 1222 | #ifdef CONFIG_LOOPW |
| 1223 | U_BOOT_CMD( |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1224 | loopw, 4, 1, do_mem_loopw, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1225 | "infinite write loop on address range", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1226 | "[.b, .w, .l] address number_of_objects data_to_write" |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 1227 | ); |
| 1228 | #endif /* CONFIG_LOOPW */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1229 | |
Wolfgang Denk | 9d00928 | 2013-03-08 10:51:32 +0000 | [diff] [blame] | 1230 | #ifdef CONFIG_CMD_MEMTEST |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1231 | U_BOOT_CMD( |
Dirk Eibach | b265989 | 2008-12-16 14:51:56 +0100 | [diff] [blame] | 1232 | mtest, 5, 1, do_mem_mtest, |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1233 | "simple RAM read/write test", |
| 1234 | "[start [end [pattern [iterations]]]]" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1235 | ); |
Wolfgang Denk | 9d00928 | 2013-03-08 10:51:32 +0000 | [diff] [blame] | 1236 | #endif /* CONFIG_CMD_MEMTEST */ |
stroese | fb5e0ac | 2004-12-16 17:42:39 +0000 | [diff] [blame] | 1237 | |
| 1238 | #ifdef CONFIG_MX_CYCLIC |
| 1239 | U_BOOT_CMD( |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1240 | mdc, 4, 1, do_mem_mdc, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1241 | "memory display cyclic", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1242 | "[.b, .w, .l] address count delay(ms)" |
stroese | fb5e0ac | 2004-12-16 17:42:39 +0000 | [diff] [blame] | 1243 | ); |
| 1244 | |
| 1245 | U_BOOT_CMD( |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1246 | mwc, 4, 1, do_mem_mwc, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1247 | "memory write cyclic", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1248 | "[.b, .w, .l] address value delay(ms)" |
stroese | fb5e0ac | 2004-12-16 17:42:39 +0000 | [diff] [blame] | 1249 | ); |
| 1250 | #endif /* CONFIG_MX_CYCLIC */ |
Simon Glass | eacd14f | 2012-11-30 13:01:20 +0000 | [diff] [blame] | 1251 | |
| 1252 | #ifdef CONFIG_CMD_MEMINFO |
| 1253 | U_BOOT_CMD( |
| 1254 | meminfo, 3, 1, do_mem_info, |
| 1255 | "display memory information", |
| 1256 | "" |
| 1257 | ); |
| 1258 | #endif |