mem.c 30 KB

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