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