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 | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 32 | #ifdef CONFIG_HAS_DATAFLASH |
| 33 | #include <dataflash.h> |
| 34 | #endif |
Simon Glass | d20a40d | 2013-02-24 20:30:22 +0000 | [diff] [blame] | 35 | #include <hash.h> |
Sergei Poselenov | a6e6fc6 | 2008-04-09 16:09:41 +0200 | [diff] [blame] | 36 | #include <watchdog.h> |
Simon Glass | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 37 | #include <asm/io.h> |
Simon Glass | 15a33e4 | 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 | 8e169cc | 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 | 54841ab | 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 | d6efe24 | 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 | 088f1b1 | 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 | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 65 | ulong addr, length; |
Grant Likely | c95c428 | 2007-02-20 09:05:00 +0100 | [diff] [blame] | 66 | #if defined(CONFIG_HAS_DATAFLASH) |
| 67 | ulong nbytes, linebytes; |
| 68 | #endif |
wdenk | 27b207f | 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 | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 79 | if (argc < 2) |
Simon Glass | 4c12eeb | 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 | 27b207f | 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 | c95c428 | 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 | c95c428 | 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 | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 112 | |
Grant Likely | c95c428 | 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 | 8bde7f7 | 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 | c95c428 | 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 | c95c428 | 2007-02-20 09:05:00 +0100 | [diff] [blame] | 124 | #else |
Mike Frysinger | 4c727c7 | 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 | 0628ab8 | 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 | 4c727c7 | 2008-02-04 19:26:56 -0500 | [diff] [blame] | 150 | /* Print the lines. */ |
Simon Glass | 0628ab8 | 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 | 4c727c7 | 2008-02-04 19:26:56 -0500 | [diff] [blame] | 154 | } |
Grant Likely | c95c428 | 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 | 088f1b1 | 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 | 088f1b1 | 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 | 088f1b1 | 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 | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 174 | ulong addr, writeval, count; |
| 175 | int size; |
Simon Glass | 0628ab8 | 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 | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 179 | if ((argc < 3) || (argc > 4)) |
Simon Glass | 4c12eeb | 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 | 27b207f | 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 | 0628ab8 | 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 | 0628ab8 | 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 | 0628ab8 | 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 | 0628ab8 | 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 | 0628ab8 | 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 | 4aaf29b | 2004-12-16 17:42:39 +0000 | [diff] [blame] | 218 | #ifdef CONFIG_MX_CYCLIC |
Wolfgang Denk | 54841ab | 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 | 4aaf29b | 2004-12-16 17:42:39 +0000 | [diff] [blame] | 220 | { |
| 221 | int i; |
| 222 | ulong count; |
| 223 | |
Wolfgang Denk | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 224 | if (argc < 4) |
Simon Glass | 4c12eeb | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 225 | return CMD_RET_USAGE; |
stroese | 4aaf29b | 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 | 54841ab | 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 | 4aaf29b | 2004-12-16 17:42:39 +0000 | [diff] [blame] | 247 | { |
| 248 | int i; |
| 249 | ulong count; |
| 250 | |
Wolfgang Denk | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 251 | if (argc < 4) |
Simon Glass | 4c12eeb | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 252 | return CMD_RET_USAGE; |
stroese | 4aaf29b | 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 | 088f1b1 | 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 | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 276 | ulong addr1, addr2, count, ngood, bytes; |
wdenk | 27b207f | 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 | 054ea17 | 2012-01-20 09:07:21 +0000 | [diff] [blame] | 279 | const char *type; |
Simon Glass | 0628ab8 | 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 | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 282 | if (argc != 4) |
Simon Glass | 4c12eeb | 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 | 27b207f | 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 | 054ea17 | 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 | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 299 | #ifdef CONFIG_HAS_DATAFLASH |
| 300 | if (addr_dataflash(addr1) | addr_dataflash(addr2)){ |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 301 | puts ("Comparison with DataFlash space not supported.\n\r"); |
wdenk | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 302 | return 0; |
| 303 | } |
| 304 | #endif |
| 305 | |
Mike Frysinger | 4c727c7 | 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 | 0628ab8 | 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 | feb12a1 | 2012-01-20 09:07:22 +0000 | [diff] [blame] | 316 | for (ngood = 0; ngood < count; ++ngood) { |
Mike Frysinger | 054ea17 | 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 | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 319 | word1 = *(ulong *)buf1; |
| 320 | word2 = *(ulong *)buf2; |
Mike Frysinger | 054ea17 | 2012-01-20 09:07:21 +0000 | [diff] [blame] | 321 | } else if (size == 2) { |
Simon Glass | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 322 | word1 = *(ushort *)buf1; |
| 323 | word2 = *(ushort *)buf2; |
Mike Frysinger | 054ea17 | 2012-01-20 09:07:21 +0000 | [diff] [blame] | 324 | } else { |
Simon Glass | 0628ab8 | 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 | 054ea17 | 2012-01-20 09:07:21 +0000 | [diff] [blame] | 328 | if (word1 != word2) { |
Simon Glass | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 329 | ulong offset = buf1 - base; |
| 330 | |
Mike Frysinger | 054ea17 | 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 | 0628ab8 | 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 | 054ea17 | 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 | 054ea17 | 2012-01-20 09:07:21 +0000 | [diff] [blame] | 337 | |
Simon Glass | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 338 | buf1 += size; |
| 339 | buf2 += size; |
Stefan Roese | eaadb44 | 2010-09-13 11:10:34 +0200 | [diff] [blame] | 340 | |
| 341 | /* reset watchdog from time to time */ |
Mike Frysinger | feb12a1 | 2012-01-20 09:07:22 +0000 | [diff] [blame] | 342 | if ((ngood % (64 << 10)) == 0) |
Stefan Roese | eaadb44 | 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 | 0628ab8 | 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 | 054ea17 | 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 | 088f1b1 | 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 | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 354 | ulong addr, dest, count, bytes; |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 355 | int size; |
Simon Glass | 0628ab8 | 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 | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 359 | if (argc != 4) |
Simon Glass | 4c12eeb | 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 | 27b207f | 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 | 6d0f6bc | 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 | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 382 | if ( (addr2info(dest) != NULL) |
| 383 | #ifdef CONFIG_HAS_DATAFLASH |
Kim B. Heino | 84d0c2f | 2008-03-03 10:39:13 +0200 | [diff] [blame] | 384 | && (!addr_dataflash(dest)) |
wdenk | 2abbe07 | 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 | 4b9206e | 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 | 77ddac9 | 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 | 2abbe07 | 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 | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 406 | puts ("Copy to DataFlash... "); |
wdenk | 2abbe07 | 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 | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 417 | |
wdenk | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 418 | /* Check if we are copying from DataFlash to RAM */ |
Stelian Pop | 880cc43 | 2008-03-26 22:52:35 +0100 | [diff] [blame] | 419 | if (addr_dataflash(addr) && !addr_dataflash(dest) |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 420 | #ifndef CONFIG_SYS_NO_FLASH |
Stelian Pop | 880cc43 | 2008-03-26 22:52:35 +0100 | [diff] [blame] | 421 | && (addr2info(dest) == NULL) |
| 422 | #endif |
| 423 | ){ |
wdenk | 5779d8d | 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 | d4ca31c | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 427 | dataflash_perror (rc); |
| 428 | return (1); |
| 429 | } |
wdenk | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 430 | return 0; |
| 431 | } |
| 432 | |
| 433 | if (addr_dataflash(addr) && addr_dataflash(dest)){ |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 434 | puts ("Unsupported combination of source/destination.\n\r"); |
wdenk | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 435 | return 1; |
| 436 | } |
| 437 | #endif |
| 438 | |
Mike Frysinger | 4c727c7 | 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 | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 447 | bytes = size * count; |
Masahiro Yamada | 53237af | 2013-05-20 21:08:08 +0000 | [diff] [blame] | 448 | buf = map_sysmem(dest, bytes); |
Simon Glass | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 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 | 0628ab8 | 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 | 0628ab8 | 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 | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 456 | *((u_char *)buf) = *((u_char *)src); |
| 457 | src += size; |
| 458 | buf += size; |
Stefan Roese | eaadb44 | 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 | 088f1b1 | 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 | 088f1b1 | 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 | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 484 | ulong addr, length, i, bytes; |
wdenk | 27b207f | 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 | 0628ab8 | 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 | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 491 | if (argc < 3) |
Simon Glass | 4c12eeb | 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 | 85de63e | 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 | 27b207f | 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 | 0628ab8 | 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 | 0628ab8 | 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 | 0628ab8 | 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 | 0628ab8 | 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 | 0628ab8 | 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 | f3b3c3d | 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 | 0628ab8 | 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 | f3b3c3d | 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 | 0628ab8 | 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 | f3b3c3d | 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 | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 553 | unmap_sysmem(buf); |
Simon Glass | 92765f42 | 2013-06-11 11:14:35 -0700 | [diff] [blame^] | 554 | |
| 555 | return 0; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 556 | } |
| 557 | |
wdenk | 56523f1 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 558 | #ifdef CONFIG_LOOPW |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 559 | int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | 56523f1 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 560 | { |
Simon Glass | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 561 | ulong addr, length, i, data, bytes; |
wdenk | 56523f1 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 562 | int size; |
| 563 | volatile uint *longp; |
| 564 | volatile ushort *shortp; |
| 565 | volatile u_char *cp; |
Simon Glass | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 566 | void *buf; |
wdenk | 8105092 | 2004-07-11 20:04:51 +0000 | [diff] [blame] | 567 | |
Wolfgang Denk | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 568 | if (argc < 4) |
Simon Glass | 4c12eeb | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 569 | return CMD_RET_USAGE; |
wdenk | 56523f1 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 570 | |
Robert P. J. Day | 85de63e | 2013-02-03 02:29:54 +0000 | [diff] [blame] | 571 | /* |
| 572 | * Check for a size specification. |
wdenk | 56523f1 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 573 | * Defaults to long if no or incorrect specification. |
| 574 | */ |
| 575 | if ((size = cmd_get_data_size(argv[0], 4)) < 0) |
| 576 | return 1; |
| 577 | |
| 578 | /* Address is always specified. |
| 579 | */ |
| 580 | addr = simple_strtoul(argv[1], NULL, 16); |
| 581 | |
| 582 | /* Length is the number of objects, not number of bytes. |
| 583 | */ |
| 584 | length = simple_strtoul(argv[2], NULL, 16); |
| 585 | |
| 586 | /* data to write */ |
| 587 | data = simple_strtoul(argv[3], NULL, 16); |
wdenk | 8105092 | 2004-07-11 20:04:51 +0000 | [diff] [blame] | 588 | |
Simon Glass | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 589 | bytes = size * length; |
| 590 | buf = map_sysmem(addr, bytes); |
| 591 | |
wdenk | 56523f1 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 592 | /* We want to optimize the loops to run as fast as possible. |
| 593 | * If we have only one object, just run infinite loops. |
| 594 | */ |
| 595 | if (length == 1) { |
| 596 | if (size == 4) { |
Simon Glass | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 597 | longp = (uint *)buf; |
wdenk | 56523f1 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 598 | for (;;) |
| 599 | *longp = data; |
| 600 | } |
| 601 | if (size == 2) { |
Simon Glass | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 602 | shortp = (ushort *)buf; |
wdenk | 56523f1 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 603 | for (;;) |
| 604 | *shortp = data; |
| 605 | } |
Simon Glass | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 606 | cp = (u_char *)buf; |
wdenk | 56523f1 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 607 | for (;;) |
| 608 | *cp = data; |
| 609 | } |
| 610 | |
| 611 | if (size == 4) { |
| 612 | for (;;) { |
Simon Glass | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 613 | longp = (uint *)buf; |
wdenk | 56523f1 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 614 | i = length; |
| 615 | while (i-- > 0) |
| 616 | *longp++ = data; |
| 617 | } |
| 618 | } |
| 619 | if (size == 2) { |
| 620 | for (;;) { |
Simon Glass | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 621 | shortp = (ushort *)buf; |
wdenk | 56523f1 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 622 | i = length; |
| 623 | while (i-- > 0) |
| 624 | *shortp++ = data; |
| 625 | } |
| 626 | } |
| 627 | for (;;) { |
Simon Glass | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 628 | cp = (u_char *)buf; |
wdenk | 56523f1 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 629 | i = length; |
| 630 | while (i-- > 0) |
| 631 | *cp++ = data; |
| 632 | } |
| 633 | } |
| 634 | #endif /* CONFIG_LOOPW */ |
| 635 | |
Tom Rini | 68149e9 | 2013-03-12 10:07:19 -0400 | [diff] [blame] | 636 | #ifdef CONFIG_CMD_MEMTEST |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 637 | static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr, |
| 638 | vu_long *dummy) |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 639 | { |
Simon Glass | c9638f5 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 640 | vu_long *addr; |
Simon Glass | c9638f5 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 641 | ulong errs = 0; |
| 642 | ulong val, readback; |
| 643 | int j; |
Simon Glass | c9638f5 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 644 | vu_long offset; |
| 645 | vu_long test_offset; |
| 646 | vu_long pattern; |
| 647 | vu_long temp; |
| 648 | vu_long anti_pattern; |
| 649 | vu_long num_words; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 650 | static const ulong bitpattern[] = { |
| 651 | 0x00000001, /* single bit */ |
| 652 | 0x00000003, /* two adjacent bits */ |
| 653 | 0x00000007, /* three adjacent bits */ |
| 654 | 0x0000000F, /* four adjacent bits */ |
| 655 | 0x00000005, /* two non-adjacent bits */ |
| 656 | 0x00000015, /* three non-adjacent bits */ |
| 657 | 0x00000055, /* four non-adjacent bits */ |
| 658 | 0xaaaaaaaa, /* alternating 1/0 */ |
| 659 | }; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 660 | |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 661 | num_words = (end_addr - start_addr) / sizeof(vu_long); |
Simon Glass | 8c86bbe | 2013-02-24 17:33:20 +0000 | [diff] [blame] | 662 | |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 663 | /* |
| 664 | * Data line test: write a pattern to the first |
| 665 | * location, write the 1's complement to a 'parking' |
| 666 | * address (changes the state of the data bus so a |
| 667 | * floating bus doesn't give a false OK), and then |
| 668 | * read the value back. Note that we read it back |
| 669 | * into a variable because the next time we read it, |
| 670 | * it might be right (been there, tough to explain to |
| 671 | * the quality guys why it prints a failure when the |
| 672 | * "is" and "should be" are obviously the same in the |
| 673 | * error message). |
| 674 | * |
| 675 | * Rather than exhaustively testing, we test some |
| 676 | * patterns by shifting '1' bits through a field of |
| 677 | * '0's and '0' bits through a field of '1's (i.e. |
| 678 | * pattern and ~pattern). |
| 679 | */ |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 680 | addr = buf; |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 681 | for (j = 0; j < sizeof(bitpattern) / sizeof(bitpattern[0]); j++) { |
| 682 | val = bitpattern[j]; |
| 683 | for (; val != 0; val <<= 1) { |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 684 | *addr = val; |
Simon Glass | c9638f5 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 685 | *dummy = ~val; /* clear the test data off the bus */ |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 686 | readback = *addr; |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 687 | if (readback != val) { |
Simon Glass | c9638f5 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 688 | printf("FAILURE (data line): " |
| 689 | "expected %08lx, actual %08lx\n", |
| 690 | val, readback); |
| 691 | errs++; |
Simon Glass | c44d438 | 2013-02-24 17:33:19 +0000 | [diff] [blame] | 692 | if (ctrlc()) |
Simon Glass | 51209b1 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 693 | return -1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 694 | } |
| 695 | *addr = ~val; |
| 696 | *dummy = val; |
| 697 | readback = *addr; |
Simon Glass | c9638f5 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 698 | if (readback != ~val) { |
| 699 | printf("FAILURE (data line): " |
| 700 | "Is %08lx, should be %08lx\n", |
| 701 | readback, ~val); |
| 702 | errs++; |
Simon Glass | c44d438 | 2013-02-24 17:33:19 +0000 | [diff] [blame] | 703 | if (ctrlc()) |
Simon Glass | 51209b1 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 704 | return -1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 705 | } |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 706 | } |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 707 | } |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 708 | |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 709 | /* |
| 710 | * Based on code whose Original Author and Copyright |
| 711 | * information follows: Copyright (c) 1998 by Michael |
| 712 | * Barr. This software is placed into the public |
| 713 | * domain and may be used for any purpose. However, |
| 714 | * this notice must not be changed or removed and no |
| 715 | * warranty is either expressed or implied by its |
| 716 | * publication or distribution. |
| 717 | */ |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 718 | |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 719 | /* |
| 720 | * Address line test |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 721 | |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 722 | * Description: Test the address bus wiring in a |
| 723 | * memory region by performing a walking |
| 724 | * 1's test on the relevant bits of the |
| 725 | * address and checking for aliasing. |
| 726 | * This test will find single-bit |
| 727 | * address failures such as stuck-high, |
| 728 | * stuck-low, and shorted pins. The base |
| 729 | * address and size of the region are |
| 730 | * selected by the caller. |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 731 | |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 732 | * Notes: For best results, the selected base |
| 733 | * address should have enough LSB 0's to |
| 734 | * guarantee single address bit changes. |
| 735 | * For example, to test a 64-Kbyte |
| 736 | * region, select a base address on a |
| 737 | * 64-Kbyte boundary. Also, select the |
| 738 | * region size as a power-of-two if at |
| 739 | * all possible. |
| 740 | * |
| 741 | * Returns: 0 if the test succeeds, 1 if the test fails. |
| 742 | */ |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 743 | pattern = (vu_long) 0xaaaaaaaa; |
| 744 | anti_pattern = (vu_long) 0x55555555; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 745 | |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 746 | debug("%s:%d: length = 0x%.8lx\n", __func__, __LINE__, num_words); |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 747 | /* |
| 748 | * Write the default pattern at each of the |
| 749 | * power-of-two offsets. |
| 750 | */ |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 751 | for (offset = 1; offset < num_words; offset <<= 1) |
| 752 | addr[offset] = pattern; |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 753 | |
| 754 | /* |
| 755 | * Check for address bits stuck high. |
| 756 | */ |
| 757 | test_offset = 0; |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 758 | addr[test_offset] = anti_pattern; |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 759 | |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 760 | for (offset = 1; offset < num_words; offset <<= 1) { |
| 761 | temp = addr[offset]; |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 762 | if (temp != pattern) { |
Simon Glass | c9638f5 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 763 | printf("\nFAILURE: Address bit stuck high @ 0x%.8lx:" |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 764 | " expected 0x%.8lx, actual 0x%.8lx\n", |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 765 | start_addr + offset, pattern, temp); |
Paul Gortmaker | 87b22b7 | 2009-10-02 18:18:33 -0400 | [diff] [blame] | 766 | errs++; |
Simon Glass | c44d438 | 2013-02-24 17:33:19 +0000 | [diff] [blame] | 767 | if (ctrlc()) |
Simon Glass | 51209b1 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 768 | return -1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 769 | } |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 770 | } |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 771 | addr[test_offset] = pattern; |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 772 | WATCHDOG_RESET(); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 773 | |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 774 | /* |
| 775 | * Check for addr bits stuck low or shorted. |
| 776 | */ |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 777 | for (test_offset = 1; test_offset < num_words; test_offset <<= 1) { |
| 778 | addr[test_offset] = anti_pattern; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 779 | |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 780 | for (offset = 1; offset < num_words; offset <<= 1) { |
| 781 | temp = addr[offset]; |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 782 | if ((temp != pattern) && (offset != test_offset)) { |
| 783 | printf("\nFAILURE: Address bit stuck low or" |
| 784 | " shorted @ 0x%.8lx: expected 0x%.8lx," |
| 785 | " actual 0x%.8lx\n", |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 786 | start_addr + offset, pattern, temp); |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 787 | errs++; |
Simon Glass | c44d438 | 2013-02-24 17:33:19 +0000 | [diff] [blame] | 788 | if (ctrlc()) |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 789 | return -1; |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 790 | } |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 791 | } |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 792 | addr[test_offset] = pattern; |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 793 | } |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 794 | |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 795 | /* |
| 796 | * Description: Test the integrity of a physical |
| 797 | * memory device by performing an |
| 798 | * increment/decrement test over the |
| 799 | * entire region. In the process every |
| 800 | * storage bit in the device is tested |
| 801 | * as a zero and a one. The base address |
| 802 | * and the size of the region are |
| 803 | * selected by the caller. |
| 804 | * |
| 805 | * Returns: 0 if the test succeeds, 1 if the test fails. |
| 806 | */ |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 807 | num_words++; |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 808 | |
| 809 | /* |
| 810 | * Fill memory with a known pattern. |
| 811 | */ |
| 812 | for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) { |
| 813 | WATCHDOG_RESET(); |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 814 | addr[offset] = pattern; |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 815 | } |
| 816 | |
| 817 | /* |
| 818 | * Check each location and invert it for the second pass. |
| 819 | */ |
| 820 | for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) { |
| 821 | WATCHDOG_RESET(); |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 822 | temp = addr[offset]; |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 823 | if (temp != pattern) { |
Simon Glass | c9638f5 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 824 | printf("\nFAILURE (read/write) @ 0x%.8lx:" |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 825 | " expected 0x%.8lx, actual 0x%.8lx)\n", |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 826 | start_addr + offset, pattern, temp); |
Paul Gortmaker | 87b22b7 | 2009-10-02 18:18:33 -0400 | [diff] [blame] | 827 | errs++; |
Simon Glass | c44d438 | 2013-02-24 17:33:19 +0000 | [diff] [blame] | 828 | if (ctrlc()) |
Simon Glass | 51209b1 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 829 | return -1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 830 | } |
| 831 | |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 832 | anti_pattern = ~pattern; |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 833 | addr[offset] = anti_pattern; |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 834 | } |
| 835 | |
| 836 | /* |
| 837 | * Check each location for the inverted pattern and zero it. |
| 838 | */ |
| 839 | for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) { |
| 840 | WATCHDOG_RESET(); |
| 841 | anti_pattern = ~pattern; |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 842 | temp = addr[offset]; |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 843 | if (temp != anti_pattern) { |
Simon Glass | c9638f5 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 844 | printf("\nFAILURE (read/write): @ 0x%.8lx:" |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 845 | " expected 0x%.8lx, actual 0x%.8lx)\n", |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 846 | start_addr + offset, anti_pattern, temp); |
Paul Gortmaker | 87b22b7 | 2009-10-02 18:18:33 -0400 | [diff] [blame] | 847 | errs++; |
Simon Glass | c44d438 | 2013-02-24 17:33:19 +0000 | [diff] [blame] | 848 | if (ctrlc()) |
Simon Glass | 51209b1 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 849 | return -1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 850 | } |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 851 | addr[offset] = 0; |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 852 | } |
Simon Glass | 51209b1 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 853 | |
| 854 | return 0; |
Simon Glass | c9638f5 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 855 | } |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 856 | |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 857 | static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr, |
| 858 | vu_long pattern, int iteration) |
Simon Glass | c9638f5 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 859 | { |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 860 | vu_long *end; |
Simon Glass | c9638f5 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 861 | vu_long *addr; |
Simon Glass | c9638f5 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 862 | ulong errs = 0; |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 863 | ulong incr, length; |
Simon Glass | c9638f5 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 864 | ulong val, readback; |
| 865 | |
Simon Glass | 51209b1 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 866 | /* Alternate the pattern */ |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 867 | incr = 1; |
Simon Glass | 51209b1 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 868 | if (iteration & 1) { |
| 869 | incr = -incr; |
| 870 | /* |
| 871 | * Flip the pattern each time to make lots of zeros and |
| 872 | * then, the next time, lots of ones. We decrement |
| 873 | * the "negative" patterns and increment the "positive" |
| 874 | * patterns to preserve this feature. |
| 875 | */ |
| 876 | if (pattern & 0x80000000) |
| 877 | pattern = -pattern; /* complement & increment */ |
| 878 | else |
| 879 | pattern = ~pattern; |
| 880 | } |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 881 | length = (end_addr - start_addr) / sizeof(ulong); |
| 882 | end = buf + length; |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 883 | printf("\rPattern %08lX Writing..." |
| 884 | "%12s" |
| 885 | "\b\b\b\b\b\b\b\b\b\b", |
| 886 | pattern, ""); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 887 | |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 888 | for (addr = buf, val = pattern; addr < end; addr++) { |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 889 | WATCHDOG_RESET(); |
| 890 | *addr = val; |
| 891 | val += incr; |
| 892 | } |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 893 | |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 894 | puts("Reading..."); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 895 | |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 896 | for (addr = buf, val = pattern; addr < end; addr++) { |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 897 | WATCHDOG_RESET(); |
| 898 | readback = *addr; |
| 899 | if (readback != val) { |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 900 | ulong offset = addr - buf; |
| 901 | |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 902 | printf("\nMem error @ 0x%08X: " |
| 903 | "found %08lX, expected %08lX\n", |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 904 | (uint)(uintptr_t)(start_addr + offset), |
| 905 | readback, val); |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 906 | errs++; |
Simon Glass | c44d438 | 2013-02-24 17:33:19 +0000 | [diff] [blame] | 907 | if (ctrlc()) |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 908 | return -1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 909 | } |
Simon Glass | 7ecbd4d | 2013-02-24 17:33:18 +0000 | [diff] [blame] | 910 | val += incr; |
| 911 | } |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 912 | |
Simon Glass | 51209b1 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 913 | return 0; |
Simon Glass | c9638f5 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 914 | } |
| 915 | |
| 916 | /* |
| 917 | * Perform a memory test. A more complete alternative test can be |
| 918 | * configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until |
| 919 | * interrupted by ctrl-c or by a failure of one of the sub-tests. |
| 920 | */ |
| 921 | static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, |
| 922 | char * const argv[]) |
| 923 | { |
Simon Glass | 8c86bbe | 2013-02-24 17:33:20 +0000 | [diff] [blame] | 924 | ulong start, end; |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 925 | vu_long *buf, *dummy; |
Simon Glass | c9638f5 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 926 | int iteration_limit; |
| 927 | int ret; |
Simon Glass | 51209b1 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 928 | ulong errs = 0; /* number of errors, or -1 if interrupted */ |
Simon Glass | c9638f5 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 929 | ulong pattern; |
Simon Glass | 51209b1 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 930 | int iteration; |
Simon Glass | c9638f5 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 931 | #if defined(CONFIG_SYS_ALT_MEMTEST) |
| 932 | const int alt_test = 1; |
| 933 | #else |
| 934 | const int alt_test = 0; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 935 | #endif |
Simon Glass | c9638f5 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 936 | |
| 937 | if (argc > 1) |
Simon Glass | 8c86bbe | 2013-02-24 17:33:20 +0000 | [diff] [blame] | 938 | start = simple_strtoul(argv[1], NULL, 16); |
Simon Glass | c9638f5 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 939 | else |
Simon Glass | 8c86bbe | 2013-02-24 17:33:20 +0000 | [diff] [blame] | 940 | start = CONFIG_SYS_MEMTEST_START; |
Simon Glass | c9638f5 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 941 | |
| 942 | if (argc > 2) |
Simon Glass | 8c86bbe | 2013-02-24 17:33:20 +0000 | [diff] [blame] | 943 | end = simple_strtoul(argv[2], NULL, 16); |
Simon Glass | c9638f5 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 944 | else |
Simon Glass | 8c86bbe | 2013-02-24 17:33:20 +0000 | [diff] [blame] | 945 | end = CONFIG_SYS_MEMTEST_END; |
Simon Glass | c9638f5 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 946 | |
| 947 | if (argc > 3) |
| 948 | pattern = (ulong)simple_strtoul(argv[3], NULL, 16); |
| 949 | else |
| 950 | pattern = 0; |
| 951 | |
| 952 | if (argc > 4) |
| 953 | iteration_limit = (ulong)simple_strtoul(argv[4], NULL, 16); |
| 954 | else |
| 955 | iteration_limit = 0; |
| 956 | |
Simon Glass | 8c86bbe | 2013-02-24 17:33:20 +0000 | [diff] [blame] | 957 | printf("Testing %08x ... %08x:\n", (uint)start, (uint)end); |
| 958 | debug("%s:%d: start %#08lx end %#08lx\n", __func__, __LINE__, |
| 959 | start, end); |
Simon Glass | 51209b1 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 960 | |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 961 | buf = map_sysmem(start, end - start); |
| 962 | dummy = map_sysmem(CONFIG_SYS_MEMTEST_SCRATCH, sizeof(vu_long)); |
Simon Glass | 51209b1 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 963 | for (iteration = 0; |
| 964 | !iteration_limit || iteration < iteration_limit; |
| 965 | iteration++) { |
| 966 | if (ctrlc()) { |
Simon Glass | 51209b1 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 967 | errs = -1UL; |
| 968 | break; |
| 969 | } |
| 970 | |
| 971 | printf("Iteration: %6d\r", iteration + 1); |
| 972 | debug("\n"); |
Simon Glass | 5512d5b | 2013-02-28 17:47:14 +0000 | [diff] [blame] | 973 | if (alt_test) { |
| 974 | errs = mem_test_alt(buf, start, end, dummy); |
| 975 | } else { |
| 976 | errs = mem_test_quick(buf, start, end, pattern, |
| 977 | iteration); |
| 978 | } |
| 979 | if (errs == -1UL) |
| 980 | break; |
| 981 | } |
| 982 | |
| 983 | /* |
| 984 | * Work-around for eldk-4.2 which gives this warning if we try to |
| 985 | * case in the unmap_sysmem() call: |
| 986 | * warning: initialization discards qualifiers from pointer target type |
| 987 | */ |
| 988 | { |
| 989 | void *vbuf = (void *)buf; |
| 990 | void *vdummy = (void *)dummy; |
| 991 | |
| 992 | unmap_sysmem(vbuf); |
| 993 | unmap_sysmem(vdummy); |
Simon Glass | 51209b1 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 994 | } |
| 995 | |
| 996 | if (errs == -1UL) { |
Simon Glass | c44d438 | 2013-02-24 17:33:19 +0000 | [diff] [blame] | 997 | /* Memory test was aborted - write a newline to finish off */ |
| 998 | putc('\n'); |
Simon Glass | 51209b1 | 2013-02-24 17:33:17 +0000 | [diff] [blame] | 999 | ret = 1; |
| 1000 | } else { |
| 1001 | printf("Tested %d iteration(s) with %lu errors.\n", |
| 1002 | iteration, errs); |
| 1003 | ret = errs != 0; |
| 1004 | } |
Simon Glass | c9638f5 | 2013-02-24 17:33:16 +0000 | [diff] [blame] | 1005 | |
| 1006 | return ret; /* not reached */ |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1007 | } |
Wolfgang Denk | a268170 | 2013-03-08 10:51:32 +0000 | [diff] [blame] | 1008 | #endif /* CONFIG_CMD_MEMTEST */ |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1009 | |
| 1010 | /* Modify memory. |
| 1011 | * |
| 1012 | * Syntax: |
| 1013 | * mm{.b, .w, .l} {addr} |
| 1014 | * nm{.b, .w, .l} {addr} |
| 1015 | */ |
| 1016 | static int |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 1017 | 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] | 1018 | { |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 1019 | ulong addr, i; |
| 1020 | int nbytes, size; |
Simon Glass | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 1021 | void *ptr = NULL; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1022 | |
Wolfgang Denk | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 1023 | if (argc != 2) |
Simon Glass | 4c12eeb | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 1024 | return CMD_RET_USAGE; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1025 | |
| 1026 | #ifdef CONFIG_BOOT_RETRY_TIME |
| 1027 | reset_cmd_timeout(); /* got a good command to get here */ |
| 1028 | #endif |
| 1029 | /* We use the last specified parameters, unless new ones are |
| 1030 | * entered. |
| 1031 | */ |
| 1032 | addr = mm_last_addr; |
| 1033 | size = mm_last_size; |
| 1034 | |
| 1035 | if ((flag & CMD_FLAG_REPEAT) == 0) { |
| 1036 | /* New command specified. Check for a size specification. |
| 1037 | * Defaults to long if no or incorrect specification. |
| 1038 | */ |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 1039 | if ((size = cmd_get_data_size(argv[0], 4)) < 0) |
| 1040 | return 1; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1041 | |
| 1042 | /* Address is specified since argc > 1 |
| 1043 | */ |
| 1044 | addr = simple_strtoul(argv[1], NULL, 16); |
| 1045 | addr += base_address; |
| 1046 | } |
| 1047 | |
wdenk | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 1048 | #ifdef CONFIG_HAS_DATAFLASH |
| 1049 | if (addr_dataflash(addr)){ |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 1050 | puts ("Can't modify DataFlash in place. Use cp instead.\n\r"); |
wdenk | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 1051 | return 0; |
| 1052 | } |
| 1053 | #endif |
| 1054 | |
Mike Frysinger | 4c727c7 | 2008-02-04 19:26:56 -0500 | [diff] [blame] | 1055 | #ifdef CONFIG_BLACKFIN |
| 1056 | if (addr_bfin_on_chip_mem(addr)) { |
| 1057 | puts ("Can't modify L1 instruction in place. Use cp instead.\n\r"); |
| 1058 | return 0; |
| 1059 | } |
| 1060 | #endif |
| 1061 | |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1062 | /* Print the address, followed by value. Then accept input for |
| 1063 | * the next value. A non-converted value exits. |
| 1064 | */ |
| 1065 | do { |
Simon Glass | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 1066 | ptr = map_sysmem(addr, size); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1067 | printf("%08lx:", addr); |
| 1068 | if (size == 4) |
Simon Glass | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 1069 | printf(" %08x", *((uint *)ptr)); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1070 | else if (size == 2) |
Simon Glass | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 1071 | printf(" %04x", *((ushort *)ptr)); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1072 | else |
Simon Glass | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 1073 | printf(" %02x", *((u_char *)ptr)); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1074 | |
| 1075 | nbytes = readline (" ? "); |
| 1076 | if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) { |
| 1077 | /* <CR> pressed as only input, don't modify current |
| 1078 | * location and move to next. "-" pressed will go back. |
| 1079 | */ |
| 1080 | if (incrflag) |
| 1081 | addr += nbytes ? -size : size; |
| 1082 | nbytes = 1; |
| 1083 | #ifdef CONFIG_BOOT_RETRY_TIME |
| 1084 | reset_cmd_timeout(); /* good enough to not time out */ |
| 1085 | #endif |
| 1086 | } |
| 1087 | #ifdef CONFIG_BOOT_RETRY_TIME |
| 1088 | else if (nbytes == -2) { |
| 1089 | break; /* timed out, exit the command */ |
| 1090 | } |
| 1091 | #endif |
| 1092 | else { |
| 1093 | char *endp; |
| 1094 | i = simple_strtoul(console_buffer, &endp, 16); |
| 1095 | nbytes = endp - console_buffer; |
| 1096 | if (nbytes) { |
| 1097 | #ifdef CONFIG_BOOT_RETRY_TIME |
| 1098 | /* good enough to not time out |
| 1099 | */ |
| 1100 | reset_cmd_timeout(); |
| 1101 | #endif |
| 1102 | if (size == 4) |
Simon Glass | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 1103 | *((uint *)ptr) = i; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1104 | else if (size == 2) |
Simon Glass | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 1105 | *((ushort *)ptr) = i; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1106 | else |
Simon Glass | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 1107 | *((u_char *)ptr) = i; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1108 | if (incrflag) |
| 1109 | addr += size; |
| 1110 | } |
| 1111 | } |
| 1112 | } while (nbytes); |
Simon Glass | 0628ab8 | 2013-02-24 17:33:15 +0000 | [diff] [blame] | 1113 | if (ptr) |
| 1114 | unmap_sysmem(ptr); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1115 | |
| 1116 | mm_last_addr = addr; |
| 1117 | mm_last_size = size; |
| 1118 | return 0; |
| 1119 | } |
| 1120 | |
Mike Frysinger | 710b993 | 2010-12-21 14:19:51 -0500 | [diff] [blame] | 1121 | #ifdef CONFIG_CMD_CRC32 |
| 1122 | |
Kim Phillips | 088f1b1 | 2012-10-29 13:34:31 +0000 | [diff] [blame] | 1123 | 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] | 1124 | { |
Simon Glass | d20a40d | 2013-02-24 20:30:22 +0000 | [diff] [blame] | 1125 | int flags = 0; |
| 1126 | int ac; |
| 1127 | char * const *av; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1128 | |
Wolfgang Denk | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 1129 | if (argc < 3) |
Simon Glass | 4c12eeb | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 1130 | return CMD_RET_USAGE; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1131 | |
wdenk | c26e454 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1132 | av = argv + 1; |
| 1133 | ac = argc - 1; |
Simon Glass | d20a40d | 2013-02-24 20:30:22 +0000 | [diff] [blame] | 1134 | #ifdef CONFIG_HASH_VERIFY |
wdenk | c26e454 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1135 | if (strcmp(*av, "-v") == 0) { |
Simon Glass | d20a40d | 2013-02-24 20:30:22 +0000 | [diff] [blame] | 1136 | flags |= HASH_FLAG_VERIFY; |
wdenk | c26e454 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1137 | av++; |
| 1138 | ac--; |
wdenk | c26e454 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1139 | } |
Simon Glass | d20a40d | 2013-02-24 20:30:22 +0000 | [diff] [blame] | 1140 | #endif |
wdenk | c26e454 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1141 | |
Simon Glass | d20a40d | 2013-02-24 20:30:22 +0000 | [diff] [blame] | 1142 | return hash_command("crc32", flags, cmdtp, flag, ac, av); |
wdenk | c26e454 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1143 | } |
wdenk | c26e454 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1144 | |
Mike Frysinger | 710b993 | 2010-12-21 14:19:51 -0500 | [diff] [blame] | 1145 | #endif |
| 1146 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1147 | /**************************************************/ |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1148 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1149 | md, 3, 1, do_mem_md, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1150 | "memory display", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1151 | "[.b, .w, .l] address [# of objects]" |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1152 | ); |
| 1153 | |
| 1154 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1155 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1156 | mm, 2, 1, do_mem_mm, |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1157 | "memory modify (auto-incrementing address)", |
| 1158 | "[.b, .w, .l] address" |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1159 | ); |
| 1160 | |
| 1161 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1162 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1163 | nm, 2, 1, do_mem_nm, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1164 | "memory modify (constant address)", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1165 | "[.b, .w, .l] address" |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1166 | ); |
| 1167 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1168 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1169 | mw, 4, 1, do_mem_mw, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1170 | "memory write (fill)", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1171 | "[.b, .w, .l] address value [count]" |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1172 | ); |
| 1173 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1174 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1175 | cp, 4, 1, do_mem_cp, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1176 | "memory copy", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1177 | "[.b, .w, .l] source target count" |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1178 | ); |
| 1179 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1180 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1181 | cmp, 4, 1, do_mem_cmp, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1182 | "memory compare", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1183 | "[.b, .w, .l] addr1 addr2 count" |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1184 | ); |
| 1185 | |
Mike Frysinger | 710b993 | 2010-12-21 14:19:51 -0500 | [diff] [blame] | 1186 | #ifdef CONFIG_CMD_CRC32 |
| 1187 | |
wdenk | c26e454 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1188 | #ifndef CONFIG_CRC32_VERIFY |
| 1189 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1190 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1191 | crc32, 4, 1, do_mem_crc, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1192 | "checksum calculation", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1193 | "address count [addr]\n - compute CRC32 checksum [save at addr]" |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1194 | ); |
| 1195 | |
wdenk | c26e454 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1196 | #else /* CONFIG_CRC32_VERIFY */ |
| 1197 | |
| 1198 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1199 | crc32, 5, 1, do_mem_crc, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1200 | "checksum calculation", |
wdenk | c26e454 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1201 | "address count [addr]\n - compute CRC32 checksum [save at addr]\n" |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1202 | "-v address count crc\n - verify crc of memory area" |
wdenk | c26e454 | 2004-04-18 10:13:26 +0000 | [diff] [blame] | 1203 | ); |
| 1204 | |
| 1205 | #endif /* CONFIG_CRC32_VERIFY */ |
| 1206 | |
Mike Frysinger | 710b993 | 2010-12-21 14:19:51 -0500 | [diff] [blame] | 1207 | #endif |
| 1208 | |
Simon Glass | 15a33e4 | 2012-11-30 13:01:20 +0000 | [diff] [blame] | 1209 | #ifdef CONFIG_CMD_MEMINFO |
| 1210 | __weak void board_show_dram(ulong size) |
| 1211 | { |
| 1212 | puts("DRAM: "); |
| 1213 | print_size(size, "\n"); |
| 1214 | } |
| 1215 | |
| 1216 | static int do_mem_info(cmd_tbl_t *cmdtp, int flag, int argc, |
| 1217 | char * const argv[]) |
| 1218 | { |
| 1219 | board_show_dram(gd->ram_size); |
| 1220 | |
| 1221 | return 0; |
| 1222 | } |
| 1223 | #endif |
| 1224 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1225 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1226 | base, 2, 1, do_mem_base, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1227 | "print or set address offset", |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1228 | "\n - print address offset for memory commands\n" |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1229 | "base off\n - set address offset for memory commands to 'off'" |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1230 | ); |
| 1231 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1232 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1233 | loop, 3, 1, do_mem_loop, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1234 | "infinite loop on address range", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1235 | "[.b, .w, .l] address number_of_objects" |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1236 | ); |
| 1237 | |
wdenk | 56523f1 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 1238 | #ifdef CONFIG_LOOPW |
| 1239 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1240 | loopw, 4, 1, do_mem_loopw, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1241 | "infinite write loop on address range", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1242 | "[.b, .w, .l] address number_of_objects data_to_write" |
wdenk | 56523f1 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 1243 | ); |
| 1244 | #endif /* CONFIG_LOOPW */ |
| 1245 | |
Wolfgang Denk | a268170 | 2013-03-08 10:51:32 +0000 | [diff] [blame] | 1246 | #ifdef CONFIG_CMD_MEMTEST |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 1247 | U_BOOT_CMD( |
Dirk Eibach | b6fc6fd | 2008-12-16 14:51:56 +0100 | [diff] [blame] | 1248 | mtest, 5, 1, do_mem_mtest, |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1249 | "simple RAM read/write test", |
| 1250 | "[start [end [pattern [iterations]]]]" |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1251 | ); |
Wolfgang Denk | a268170 | 2013-03-08 10:51:32 +0000 | [diff] [blame] | 1252 | #endif /* CONFIG_CMD_MEMTEST */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1253 | |
stroese | 4aaf29b | 2004-12-16 17:42:39 +0000 | [diff] [blame] | 1254 | #ifdef CONFIG_MX_CYCLIC |
| 1255 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1256 | mdc, 4, 1, do_mem_mdc, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1257 | "memory display cyclic", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1258 | "[.b, .w, .l] address count delay(ms)" |
stroese | 4aaf29b | 2004-12-16 17:42:39 +0000 | [diff] [blame] | 1259 | ); |
| 1260 | |
| 1261 | U_BOOT_CMD( |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 1262 | mwc, 4, 1, do_mem_mwc, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 1263 | "memory write cyclic", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 1264 | "[.b, .w, .l] address value delay(ms)" |
stroese | 4aaf29b | 2004-12-16 17:42:39 +0000 | [diff] [blame] | 1265 | ); |
| 1266 | #endif /* CONFIG_MX_CYCLIC */ |
Simon Glass | 15a33e4 | 2012-11-30 13:01:20 +0000 | [diff] [blame] | 1267 | |
| 1268 | #ifdef CONFIG_CMD_MEMINFO |
| 1269 | U_BOOT_CMD( |
| 1270 | meminfo, 3, 1, do_mem_info, |
| 1271 | "display memory information", |
| 1272 | "" |
| 1273 | ); |
| 1274 | #endif |