cmd_mem.c 30 KB

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