board.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. /*
  2. * (C) Copyright 2002-2006
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * (C) Copyright 2002
  6. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  7. * Marius Groeger <mgroeger@sysgo.de>
  8. *
  9. * See file CREDITS for list of people who contributed to this
  10. * project.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  25. * MA 02111-1307 USA
  26. */
  27. /*
  28. * To match the U-Boot user interface on ARM platforms to the U-Boot
  29. * standard (as on PPC platforms), some messages with debug character
  30. * are removed from the default U-Boot build.
  31. *
  32. * Define DEBUG here if you want additional info as shown below
  33. * printed upon startup:
  34. *
  35. * U-Boot code: 00F00000 -> 00F3C774 BSS: -> 00FC3274
  36. * IRQ Stack: 00ebff7c
  37. * FIQ Stack: 00ebef7c
  38. */
  39. #include <common.h>
  40. #include <command.h>
  41. #include <malloc.h>
  42. #include <stdio_dev.h>
  43. #include <version.h>
  44. #include <net.h>
  45. #include <serial.h>
  46. #include <nand.h>
  47. #include <onenand_uboot.h>
  48. #include <mmc.h>
  49. #include <post.h>
  50. #include <logbuff.h>
  51. #ifdef CONFIG_BITBANGMII
  52. #include <miiphy.h>
  53. #endif
  54. #ifdef CONFIG_DRIVER_SMC91111
  55. #include "../drivers/net/smc91111.h"
  56. #endif
  57. #ifdef CONFIG_DRIVER_LAN91C96
  58. #include "../drivers/net/lan91c96.h"
  59. #endif
  60. DECLARE_GLOBAL_DATA_PTR;
  61. ulong monitor_flash_len;
  62. #ifdef CONFIG_HAS_DATAFLASH
  63. extern int AT91F_DataflashInit(void);
  64. extern void dataflash_print_info(void);
  65. #endif
  66. #ifdef CONFIG_DRIVER_RTL8019
  67. extern void rtl8019_get_enetaddr (uchar * addr);
  68. #endif
  69. #if defined(CONFIG_HARD_I2C) || \
  70. defined(CONFIG_SOFT_I2C)
  71. #include <i2c.h>
  72. #endif
  73. /************************************************************************
  74. * Coloured LED functionality
  75. ************************************************************************
  76. * May be supplied by boards if desired
  77. */
  78. inline void __coloured_LED_init(void) {}
  79. void coloured_LED_init(void)
  80. __attribute__((weak, alias("__coloured_LED_init")));
  81. inline void __red_led_on(void) {}
  82. void red_led_on(void) __attribute__((weak, alias("__red_led_on")));
  83. inline void __red_led_off(void) {}
  84. void red_led_off(void) __attribute__((weak, alias("__red_led_off")));
  85. inline void __green_led_on(void) {}
  86. void green_led_on(void) __attribute__((weak, alias("__green_led_on")));
  87. inline void __green_led_off(void) {}
  88. void green_led_off(void) __attribute__((weak, alias("__green_led_off")));
  89. inline void __yellow_led_on(void) {}
  90. void yellow_led_on(void) __attribute__((weak, alias("__yellow_led_on")));
  91. inline void __yellow_led_off(void) {}
  92. void yellow_led_off(void) __attribute__((weak, alias("__yellow_led_off")));
  93. inline void __blue_led_on(void) {}
  94. void blue_led_on(void) __attribute__((weak, alias("__blue_led_on")));
  95. inline void __blue_led_off(void) {}
  96. void blue_led_off(void) __attribute__((weak, alias("__blue_led_off")));
  97. /*
  98. ************************************************************************
  99. * Init Utilities *
  100. ************************************************************************
  101. * Some of this code should be moved into the core functions,
  102. * or dropped completely,
  103. * but let's get it working (again) first...
  104. */
  105. #if defined(CONFIG_ARM_DCC) && !defined(CONFIG_BAUDRATE)
  106. #define CONFIG_BAUDRATE 115200
  107. #endif
  108. static int init_baudrate(void)
  109. {
  110. char tmp[64]; /* long enough for environment variables */
  111. int i = getenv_f("baudrate", tmp, sizeof(tmp));
  112. gd->baudrate = (i > 0)
  113. ? (int) simple_strtoul(tmp, NULL, 10)
  114. : CONFIG_BAUDRATE;
  115. return (0);
  116. }
  117. static int display_banner(void)
  118. {
  119. printf("\n\n%s\n\n", version_string);
  120. debug("U-Boot code: %08lX -> %08lX BSS: -> %08lX\n",
  121. _TEXT_BASE,
  122. _bss_start_ofs + _TEXT_BASE, _bss_end_ofs + _TEXT_BASE);
  123. #ifdef CONFIG_MODEM_SUPPORT
  124. debug("Modem Support enabled\n");
  125. #endif
  126. #ifdef CONFIG_USE_IRQ
  127. debug("IRQ Stack: %08lx\n", IRQ_STACK_START);
  128. debug("FIQ Stack: %08lx\n", FIQ_STACK_START);
  129. #endif
  130. return (0);
  131. }
  132. /*
  133. * WARNING: this code looks "cleaner" than the PowerPC version, but
  134. * has the disadvantage that you either get nothing, or everything.
  135. * On PowerPC, you might see "DRAM: " before the system hangs - which
  136. * gives a simple yet clear indication which part of the
  137. * initialization if failing.
  138. */
  139. static int display_dram_config(void)
  140. {
  141. int i;
  142. #ifdef DEBUG
  143. puts("RAM Configuration:\n");
  144. for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
  145. printf("Bank #%d: %08lx ", i, gd->bd->bi_dram[i].start);
  146. print_size(gd->bd->bi_dram[i].size, "\n");
  147. }
  148. #else
  149. ulong size = 0;
  150. for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++)
  151. size += gd->bd->bi_dram[i].size;
  152. puts("DRAM: ");
  153. print_size(size, "\n");
  154. #endif
  155. return (0);
  156. }
  157. #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
  158. static int init_func_i2c(void)
  159. {
  160. puts("I2C: ");
  161. i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
  162. puts("ready\n");
  163. return (0);
  164. }
  165. #endif
  166. #if defined(CONFIG_CMD_PCI) || defined (CONFIG_PCI)
  167. #include <pci.h>
  168. static int arm_pci_init(void)
  169. {
  170. pci_init();
  171. return 0;
  172. }
  173. #endif /* CONFIG_CMD_PCI || CONFIG_PCI */
  174. /*
  175. * Breathe some life into the board...
  176. *
  177. * Initialize a serial port as console, and carry out some hardware
  178. * tests.
  179. *
  180. * The first part of initialization is running from Flash memory;
  181. * its main purpose is to initialize the RAM so that we
  182. * can relocate the monitor code to RAM.
  183. */
  184. /*
  185. * All attempts to come up with a "common" initialization sequence
  186. * that works for all boards and architectures failed: some of the
  187. * requirements are just _too_ different. To get rid of the resulting
  188. * mess of board dependent #ifdef'ed code we now make the whole
  189. * initialization sequence configurable to the user.
  190. *
  191. * The requirements for any new initalization function is simple: it
  192. * receives a pointer to the "global data" structure as it's only
  193. * argument, and returns an integer return code, where 0 means
  194. * "continue" and != 0 means "fatal error, hang the system".
  195. */
  196. typedef int (init_fnc_t) (void);
  197. int print_cpuinfo(void);
  198. void __dram_init_banksize(void)
  199. {
  200. gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
  201. gd->bd->bi_dram[0].size = gd->ram_size;
  202. }
  203. void dram_init_banksize(void)
  204. __attribute__((weak, alias("__dram_init_banksize")));
  205. init_fnc_t *init_sequence[] = {
  206. #if defined(CONFIG_ARCH_CPU_INIT)
  207. arch_cpu_init, /* basic arch cpu dependent setup */
  208. #endif
  209. #if defined(CONFIG_BOARD_EARLY_INIT_F)
  210. board_early_init_f,
  211. #endif
  212. timer_init, /* initialize timer */
  213. #ifdef CONFIG_FSL_ESDHC
  214. get_clocks,
  215. #endif
  216. env_init, /* initialize environment */
  217. init_baudrate, /* initialze baudrate settings */
  218. serial_init, /* serial communications setup */
  219. console_init_f, /* stage 1 init of console */
  220. display_banner, /* say that we are here */
  221. #if defined(CONFIG_DISPLAY_CPUINFO)
  222. print_cpuinfo, /* display cpu info (and speed) */
  223. #endif
  224. #if defined(CONFIG_DISPLAY_BOARDINFO)
  225. checkboard, /* display board info */
  226. #endif
  227. #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
  228. init_func_i2c,
  229. #endif
  230. dram_init, /* configure available RAM banks */
  231. NULL,
  232. };
  233. void board_init_f(ulong bootflag)
  234. {
  235. bd_t *bd;
  236. init_fnc_t **init_fnc_ptr;
  237. gd_t *id;
  238. ulong addr, addr_sp;
  239. /* Pointer is writable since we allocated a register for it */
  240. gd = (gd_t *) ((CONFIG_SYS_INIT_SP_ADDR) & ~0x07);
  241. /* compiler optimization barrier needed for GCC >= 3.4 */
  242. __asm__ __volatile__("": : :"memory");
  243. memset((void *)gd, 0, sizeof(gd_t));
  244. gd->mon_len = _bss_end_ofs;
  245. for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
  246. if ((*init_fnc_ptr)() != 0) {
  247. hang ();
  248. }
  249. }
  250. debug("monitor len: %08lX\n", gd->mon_len);
  251. /*
  252. * Ram is setup, size stored in gd !!
  253. */
  254. debug("ramsize: %08lX\n", gd->ram_size);
  255. #if defined(CONFIG_SYS_MEM_TOP_HIDE)
  256. /*
  257. * Subtract specified amount of memory to hide so that it won't
  258. * get "touched" at all by U-Boot. By fixing up gd->ram_size
  259. * the Linux kernel should now get passed the now "corrected"
  260. * memory size and won't touch it either. This should work
  261. * for arch/ppc and arch/powerpc. Only Linux board ports in
  262. * arch/powerpc with bootwrapper support, that recalculate the
  263. * memory size from the SDRAM controller setup will have to
  264. * get fixed.
  265. */
  266. gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE;
  267. #endif
  268. addr = CONFIG_SYS_SDRAM_BASE + gd->ram_size;
  269. #ifdef CONFIG_LOGBUFFER
  270. #ifndef CONFIG_ALT_LB_ADDR
  271. /* reserve kernel log buffer */
  272. addr -= (LOGBUFF_RESERVE);
  273. debug("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN,
  274. addr);
  275. #endif
  276. #endif
  277. #ifdef CONFIG_PRAM
  278. /*
  279. * reserve protected RAM
  280. */
  281. i = getenv_r("pram", (char *)tmp, sizeof(tmp));
  282. reg = (i > 0) ? simple_strtoul((const char *)tmp, NULL, 10) :
  283. CONFIG_PRAM;
  284. addr -= (reg << 10); /* size is in kB */
  285. debug("Reserving %ldk for protected RAM at %08lx\n", reg, addr);
  286. #endif /* CONFIG_PRAM */
  287. #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
  288. /* reserve TLB table */
  289. addr -= (4096 * 4);
  290. /* round down to next 64 kB limit */
  291. addr &= ~(0x10000 - 1);
  292. gd->tlb_addr = addr;
  293. debug("TLB table at: %08lx\n", addr);
  294. #endif
  295. /* round down to next 4 kB limit */
  296. addr &= ~(4096 - 1);
  297. debug("Top of RAM usable for U-Boot at: %08lx\n", addr);
  298. #ifdef CONFIG_LCD
  299. #ifdef CONFIG_FB_ADDR
  300. gd->fb_base = CONFIG_FB_ADDR;
  301. #else
  302. /* reserve memory for LCD display (always full pages) */
  303. addr = lcd_setmem(addr);
  304. gd->fb_base = addr;
  305. #endif /* CONFIG_FB_ADDR */
  306. #endif /* CONFIG_LCD */
  307. /*
  308. * reserve memory for U-Boot code, data & bss
  309. * round down to next 4 kB limit
  310. */
  311. addr -= gd->mon_len;
  312. addr &= ~(4096 - 1);
  313. debug("Reserving %ldk for U-Boot at: %08lx\n", gd->mon_len >> 10, addr);
  314. #ifndef CONFIG_SPL_BUILD
  315. /*
  316. * reserve memory for malloc() arena
  317. */
  318. addr_sp = addr - TOTAL_MALLOC_LEN;
  319. debug("Reserving %dk for malloc() at: %08lx\n",
  320. TOTAL_MALLOC_LEN >> 10, addr_sp);
  321. /*
  322. * (permanently) allocate a Board Info struct
  323. * and a permanent copy of the "global" data
  324. */
  325. addr_sp -= sizeof (bd_t);
  326. bd = (bd_t *) addr_sp;
  327. gd->bd = bd;
  328. debug("Reserving %zu Bytes for Board Info at: %08lx\n",
  329. sizeof (bd_t), addr_sp);
  330. #ifdef CONFIG_MACH_TYPE
  331. gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
  332. #endif
  333. addr_sp -= sizeof (gd_t);
  334. id = (gd_t *) addr_sp;
  335. debug("Reserving %zu Bytes for Global Data at: %08lx\n",
  336. sizeof (gd_t), addr_sp);
  337. /* setup stackpointer for exeptions */
  338. gd->irq_sp = addr_sp;
  339. #ifdef CONFIG_USE_IRQ
  340. addr_sp -= (CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ);
  341. debug("Reserving %zu Bytes for IRQ stack at: %08lx\n",
  342. CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ, addr_sp);
  343. #endif
  344. /* leave 3 words for abort-stack */
  345. addr_sp -= 12;
  346. /* 8-byte alignment for ABI compliance */
  347. addr_sp &= ~0x07;
  348. #else
  349. addr_sp += 128; /* leave 32 words for abort-stack */
  350. gd->irq_sp = addr_sp;
  351. #endif
  352. debug("New Stack Pointer is: %08lx\n", addr_sp);
  353. #ifdef CONFIG_POST
  354. post_bootmode_init();
  355. post_run(NULL, POST_ROM | post_bootmode_get(0));
  356. #endif
  357. gd->bd->bi_baudrate = gd->baudrate;
  358. /* Ram ist board specific, so move it to board code ... */
  359. dram_init_banksize();
  360. display_dram_config(); /* and display it */
  361. gd->relocaddr = addr;
  362. gd->start_addr_sp = addr_sp;
  363. gd->reloc_off = addr - _TEXT_BASE;
  364. debug("relocation Offset is: %08lx\n", gd->reloc_off);
  365. memcpy(id, (void *)gd, sizeof(gd_t));
  366. relocate_code(addr_sp, id, addr);
  367. /* NOTREACHED - relocate_code() does not return */
  368. }
  369. #if !defined(CONFIG_SYS_NO_FLASH)
  370. static char *failed = "*** failed ***\n";
  371. #endif
  372. /*
  373. ************************************************************************
  374. *
  375. * This is the next part if the initialization sequence: we are now
  376. * running from RAM and have a "normal" C environment, i. e. global
  377. * data can be written, BSS has been cleared, the stack size in not
  378. * that critical any more, etc.
  379. *
  380. ************************************************************************
  381. */
  382. void board_init_r(gd_t *id, ulong dest_addr)
  383. {
  384. char *s;
  385. bd_t *bd;
  386. ulong malloc_start;
  387. #if !defined(CONFIG_SYS_NO_FLASH)
  388. ulong flash_size;
  389. #endif
  390. gd = id;
  391. bd = gd->bd;
  392. gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
  393. monitor_flash_len = _end_ofs;
  394. /* Enable caches */
  395. enable_caches();
  396. debug("monitor flash len: %08lX\n", monitor_flash_len);
  397. board_init(); /* Setup chipselects */
  398. #ifdef CONFIG_SERIAL_MULTI
  399. serial_initialize();
  400. #endif
  401. debug("Now running in RAM - U-Boot at: %08lx\n", dest_addr);
  402. #ifdef CONFIG_LOGBUFFER
  403. logbuff_init_ptrs();
  404. #endif
  405. #ifdef CONFIG_POST
  406. post_output_backlog();
  407. #endif
  408. /* The Malloc area is immediately below the monitor copy in DRAM */
  409. malloc_start = dest_addr - TOTAL_MALLOC_LEN;
  410. mem_malloc_init (malloc_start, TOTAL_MALLOC_LEN);
  411. #if !defined(CONFIG_SYS_NO_FLASH)
  412. puts("Flash: ");
  413. flash_size = flash_init();
  414. if (flash_size > 0) {
  415. # ifdef CONFIG_SYS_FLASH_CHECKSUM
  416. print_size(flash_size, "");
  417. /*
  418. * Compute and print flash CRC if flashchecksum is set to 'y'
  419. *
  420. * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
  421. */
  422. s = getenv("flashchecksum");
  423. if (s && (*s == 'y')) {
  424. printf(" CRC: %08X", crc32(0,
  425. (const unsigned char *) CONFIG_SYS_FLASH_BASE,
  426. flash_size));
  427. }
  428. putc('\n');
  429. # else /* !CONFIG_SYS_FLASH_CHECKSUM */
  430. print_size(flash_size, "\n");
  431. # endif /* CONFIG_SYS_FLASH_CHECKSUM */
  432. } else {
  433. puts(failed);
  434. hang();
  435. }
  436. #endif
  437. #if defined(CONFIG_CMD_NAND)
  438. puts("NAND: ");
  439. nand_init(); /* go init the NAND */
  440. #endif
  441. #if defined(CONFIG_CMD_ONENAND)
  442. onenand_init();
  443. #endif
  444. #ifdef CONFIG_GENERIC_MMC
  445. puts("MMC: ");
  446. mmc_initialize(bd);
  447. #endif
  448. #ifdef CONFIG_HAS_DATAFLASH
  449. AT91F_DataflashInit();
  450. dataflash_print_info();
  451. #endif
  452. /* initialize environment */
  453. env_relocate();
  454. #if defined(CONFIG_CMD_PCI) || defined(CONFIG_PCI)
  455. arm_pci_init();
  456. #endif
  457. /* IP Address */
  458. gd->bd->bi_ip_addr = getenv_IPaddr("ipaddr");
  459. stdio_init(); /* get the devices list going. */
  460. jumptable_init();
  461. #if defined(CONFIG_API)
  462. /* Initialize API */
  463. api_init();
  464. #endif
  465. console_init_r(); /* fully init console as a device */
  466. #if defined(CONFIG_ARCH_MISC_INIT)
  467. /* miscellaneous arch dependent initialisations */
  468. arch_misc_init();
  469. #endif
  470. #if defined(CONFIG_MISC_INIT_R)
  471. /* miscellaneous platform dependent initialisations */
  472. misc_init_r();
  473. #endif
  474. /* set up exceptions */
  475. interrupt_init();
  476. /* enable exceptions */
  477. enable_interrupts();
  478. /* Perform network card initialisation if necessary */
  479. #if defined(CONFIG_DRIVER_SMC91111) || defined (CONFIG_DRIVER_LAN91C96)
  480. /* XXX: this needs to be moved to board init */
  481. if (getenv("ethaddr")) {
  482. uchar enetaddr[6];
  483. eth_getenv_enetaddr("ethaddr", enetaddr);
  484. smc_set_mac_addr(enetaddr);
  485. }
  486. #endif /* CONFIG_DRIVER_SMC91111 || CONFIG_DRIVER_LAN91C96 */
  487. /* Initialize from environment */
  488. s = getenv("loadaddr");
  489. if (s != NULL)
  490. load_addr = simple_strtoul(s, NULL, 16);
  491. #if defined(CONFIG_CMD_NET)
  492. s = getenv("bootfile");
  493. if (s != NULL)
  494. copy_filename(BootFile, s, sizeof(BootFile));
  495. #endif
  496. #ifdef BOARD_LATE_INIT
  497. board_late_init();
  498. #endif
  499. #ifdef CONFIG_BITBANGMII
  500. bb_miiphy_init();
  501. #endif
  502. #if defined(CONFIG_CMD_NET)
  503. puts("Net: ");
  504. eth_initialize(gd->bd);
  505. #if defined(CONFIG_RESET_PHY_R)
  506. debug("Reset Ethernet PHY\n");
  507. reset_phy();
  508. #endif
  509. #endif
  510. #ifdef CONFIG_POST
  511. post_run(NULL, POST_RAM | post_bootmode_get(0));
  512. #endif
  513. #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
  514. /*
  515. * Export available size of memory for Linux,
  516. * taking into account the protected RAM at top of memory
  517. */
  518. {
  519. ulong pram;
  520. uchar memsz[32];
  521. #ifdef CONFIG_PRAM
  522. char *s;
  523. s = getenv("pram");
  524. if (s != NULL)
  525. pram = simple_strtoul(s, NULL, 10);
  526. else
  527. pram = CONFIG_PRAM;
  528. #else
  529. pram = 0;
  530. #endif
  531. #ifdef CONFIG_LOGBUFFER
  532. #ifndef CONFIG_ALT_LB_ADDR
  533. /* Also take the logbuffer into account (pram is in kB) */
  534. pram += (LOGBUFF_LEN + LOGBUFF_OVERHEAD) / 1024;
  535. #endif
  536. #endif
  537. sprintf((char *)memsz, "%ldk", (gd->ram_size / 1024) - pram);
  538. setenv("mem", (char *)memsz);
  539. }
  540. #endif
  541. /* main_loop() can return to retry autoboot, if so just run it again. */
  542. for (;;) {
  543. main_loop();
  544. }
  545. /* NOTREACHED - no way out of command loop except booting */
  546. }
  547. void hang(void)
  548. {
  549. puts("### ERROR ### Please RESET the board ###\n");
  550. for (;;);
  551. }