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