cmd_bootm.c 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877
  1. /*
  2. * (C) Copyright 2000-2009
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. /*
  24. * Boot support
  25. */
  26. #include <common.h>
  27. #include <watchdog.h>
  28. #include <command.h>
  29. #include <image.h>
  30. #include <malloc.h>
  31. #include <u-boot/zlib.h>
  32. #include <bzlib.h>
  33. #include <environment.h>
  34. #include <lmb.h>
  35. #include <linux/ctype.h>
  36. #include <asm/byteorder.h>
  37. #include <asm/io.h>
  38. #include <linux/compiler.h>
  39. #if defined(CONFIG_CMD_USB)
  40. #include <usb.h>
  41. #endif
  42. #ifdef CONFIG_SYS_HUSH_PARSER
  43. #include <hush.h>
  44. #endif
  45. #if defined(CONFIG_OF_LIBFDT)
  46. #include <libfdt.h>
  47. #include <fdt_support.h>
  48. #endif
  49. #ifdef CONFIG_LZMA
  50. #include <lzma/LzmaTypes.h>
  51. #include <lzma/LzmaDec.h>
  52. #include <lzma/LzmaTools.h>
  53. #endif /* CONFIG_LZMA */
  54. #ifdef CONFIG_LZO
  55. #include <linux/lzo.h>
  56. #endif /* CONFIG_LZO */
  57. DECLARE_GLOBAL_DATA_PTR;
  58. #ifndef CONFIG_SYS_BOOTM_LEN
  59. #define CONFIG_SYS_BOOTM_LEN 0x800000 /* use 8MByte as default max gunzip size */
  60. #endif
  61. #ifdef CONFIG_BZIP2
  62. extern void bz_internal_error(int);
  63. #endif
  64. #if defined(CONFIG_CMD_IMI)
  65. static int image_info(unsigned long addr);
  66. #endif
  67. #if defined(CONFIG_CMD_IMLS)
  68. #include <flash.h>
  69. #include <mtd/cfi_flash.h>
  70. extern flash_info_t flash_info[]; /* info for FLASH chips */
  71. #endif
  72. #if defined(CONFIG_CMD_IMLS) || defined(CONFIG_CMD_IMLS_NAND)
  73. static int do_imls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
  74. #endif
  75. #include <linux/err.h>
  76. #include <nand.h>
  77. #if defined(CONFIG_SILENT_CONSOLE) && !defined(CONFIG_SILENT_U_BOOT_ONLY)
  78. static void fixup_silent_linux(void);
  79. #endif
  80. static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
  81. char * const argv[], bootm_headers_t *images,
  82. ulong *os_data, ulong *os_len);
  83. /*
  84. * Continue booting an OS image; caller already has:
  85. * - copied image header to global variable `header'
  86. * - checked header magic number, checksums (both header & image),
  87. * - verified image architecture (PPC) and type (KERNEL or MULTI),
  88. * - loaded (first part of) image to header load address,
  89. * - disabled interrupts.
  90. *
  91. * @flag: Flags indicating what to do (BOOTM_STATE_...)
  92. * @argc: Number of arguments. Note that the arguments are shifted down
  93. * so that 0 is the first argument not processed by U-Boot, and
  94. * argc is adjusted accordingly. This avoids confusion as to how
  95. * many arguments are available for the OS.
  96. * @images: Pointers to os/initrd/fdt
  97. * @return 1 on error. On success the OS boots so this function does
  98. * not return.
  99. */
  100. typedef int boot_os_fn(int flag, int argc, char * const argv[],
  101. bootm_headers_t *images);
  102. #ifdef CONFIG_BOOTM_LINUX
  103. extern boot_os_fn do_bootm_linux;
  104. #endif
  105. #ifdef CONFIG_BOOTM_NETBSD
  106. static boot_os_fn do_bootm_netbsd;
  107. #endif
  108. #if defined(CONFIG_LYNXKDI)
  109. static boot_os_fn do_bootm_lynxkdi;
  110. extern void lynxkdi_boot(image_header_t *);
  111. #endif
  112. #ifdef CONFIG_BOOTM_RTEMS
  113. static boot_os_fn do_bootm_rtems;
  114. #endif
  115. #if defined(CONFIG_BOOTM_OSE)
  116. static boot_os_fn do_bootm_ose;
  117. #endif
  118. #if defined(CONFIG_BOOTM_PLAN9)
  119. static boot_os_fn do_bootm_plan9;
  120. #endif
  121. #if defined(CONFIG_CMD_ELF)
  122. static boot_os_fn do_bootm_vxworks;
  123. static boot_os_fn do_bootm_qnxelf;
  124. int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
  125. int do_bootelf(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
  126. #endif
  127. #if defined(CONFIG_INTEGRITY)
  128. static boot_os_fn do_bootm_integrity;
  129. #endif
  130. static boot_os_fn *boot_os[] = {
  131. #ifdef CONFIG_BOOTM_LINUX
  132. [IH_OS_LINUX] = do_bootm_linux,
  133. #endif
  134. #ifdef CONFIG_BOOTM_NETBSD
  135. [IH_OS_NETBSD] = do_bootm_netbsd,
  136. #endif
  137. #ifdef CONFIG_LYNXKDI
  138. [IH_OS_LYNXOS] = do_bootm_lynxkdi,
  139. #endif
  140. #ifdef CONFIG_BOOTM_RTEMS
  141. [IH_OS_RTEMS] = do_bootm_rtems,
  142. #endif
  143. #if defined(CONFIG_BOOTM_OSE)
  144. [IH_OS_OSE] = do_bootm_ose,
  145. #endif
  146. #if defined(CONFIG_BOOTM_PLAN9)
  147. [IH_OS_PLAN9] = do_bootm_plan9,
  148. #endif
  149. #if defined(CONFIG_CMD_ELF)
  150. [IH_OS_VXWORKS] = do_bootm_vxworks,
  151. [IH_OS_QNX] = do_bootm_qnxelf,
  152. #endif
  153. #ifdef CONFIG_INTEGRITY
  154. [IH_OS_INTEGRITY] = do_bootm_integrity,
  155. #endif
  156. };
  157. bootm_headers_t images; /* pointers to os/initrd/fdt images */
  158. /* Allow for arch specific config before we boot */
  159. static void __arch_preboot_os(void)
  160. {
  161. /* please define platform specific arch_preboot_os() */
  162. }
  163. void arch_preboot_os(void) __attribute__((weak, alias("__arch_preboot_os")));
  164. #define IH_INITRD_ARCH IH_ARCH_DEFAULT
  165. #ifdef CONFIG_LMB
  166. static void boot_start_lmb(bootm_headers_t *images)
  167. {
  168. ulong mem_start;
  169. phys_size_t mem_size;
  170. lmb_init(&images->lmb);
  171. mem_start = getenv_bootm_low();
  172. mem_size = getenv_bootm_size();
  173. lmb_add(&images->lmb, (phys_addr_t)mem_start, mem_size);
  174. arch_lmb_reserve(&images->lmb);
  175. board_lmb_reserve(&images->lmb);
  176. }
  177. #else
  178. #define lmb_reserve(lmb, base, size)
  179. static inline void boot_start_lmb(bootm_headers_t *images) { }
  180. #endif
  181. static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  182. {
  183. memset((void *)&images, 0, sizeof(images));
  184. images.verify = getenv_yesno("verify");
  185. boot_start_lmb(&images);
  186. bootstage_mark_name(BOOTSTAGE_ID_BOOTM_START, "bootm_start");
  187. images.state = BOOTM_STATE_START;
  188. return 0;
  189. }
  190. static int bootm_find_os(cmd_tbl_t *cmdtp, int flag, int argc,
  191. char * const argv[])
  192. {
  193. const void *os_hdr;
  194. /* get kernel image header, start address and length */
  195. os_hdr = boot_get_kernel(cmdtp, flag, argc, argv,
  196. &images, &images.os.image_start, &images.os.image_len);
  197. if (images.os.image_len == 0) {
  198. puts("ERROR: can't get kernel image!\n");
  199. return 1;
  200. }
  201. /* get image parameters */
  202. switch (genimg_get_format(os_hdr)) {
  203. case IMAGE_FORMAT_LEGACY:
  204. images.os.type = image_get_type(os_hdr);
  205. images.os.comp = image_get_comp(os_hdr);
  206. images.os.os = image_get_os(os_hdr);
  207. images.os.end = image_get_image_end(os_hdr);
  208. images.os.load = image_get_load(os_hdr);
  209. break;
  210. #if defined(CONFIG_FIT)
  211. case IMAGE_FORMAT_FIT:
  212. if (fit_image_get_type(images.fit_hdr_os,
  213. images.fit_noffset_os, &images.os.type)) {
  214. puts("Can't get image type!\n");
  215. bootstage_error(BOOTSTAGE_ID_FIT_TYPE);
  216. return 1;
  217. }
  218. if (fit_image_get_comp(images.fit_hdr_os,
  219. images.fit_noffset_os, &images.os.comp)) {
  220. puts("Can't get image compression!\n");
  221. bootstage_error(BOOTSTAGE_ID_FIT_COMPRESSION);
  222. return 1;
  223. }
  224. if (fit_image_get_os(images.fit_hdr_os,
  225. images.fit_noffset_os, &images.os.os)) {
  226. puts("Can't get image OS!\n");
  227. bootstage_error(BOOTSTAGE_ID_FIT_OS);
  228. return 1;
  229. }
  230. images.os.end = fit_get_end(images.fit_hdr_os);
  231. if (fit_image_get_load(images.fit_hdr_os, images.fit_noffset_os,
  232. &images.os.load)) {
  233. puts("Can't get image load address!\n");
  234. bootstage_error(BOOTSTAGE_ID_FIT_LOADADDR);
  235. return 1;
  236. }
  237. break;
  238. #endif
  239. default:
  240. puts("ERROR: unknown image format type!\n");
  241. return 1;
  242. }
  243. /* find kernel entry point */
  244. if (images.legacy_hdr_valid) {
  245. images.ep = image_get_ep(&images.legacy_hdr_os_copy);
  246. #if defined(CONFIG_FIT)
  247. } else if (images.fit_uname_os) {
  248. int ret;
  249. ret = fit_image_get_entry(images.fit_hdr_os,
  250. images.fit_noffset_os, &images.ep);
  251. if (ret) {
  252. puts("Can't get entry point property!\n");
  253. return 1;
  254. }
  255. #endif
  256. } else {
  257. puts("Could not find kernel entry point!\n");
  258. return 1;
  259. }
  260. if (images.os.type == IH_TYPE_KERNEL_NOLOAD) {
  261. images.os.load = images.os.image_start;
  262. images.ep += images.os.load;
  263. }
  264. images.os.start = (ulong)os_hdr;
  265. return 0;
  266. }
  267. static int bootm_find_ramdisk(int flag, int argc, char * const argv[])
  268. {
  269. int ret;
  270. /* find ramdisk */
  271. ret = boot_get_ramdisk(argc, argv, &images, IH_INITRD_ARCH,
  272. &images.rd_start, &images.rd_end);
  273. if (ret) {
  274. puts("Ramdisk image is corrupt or invalid\n");
  275. return 1;
  276. }
  277. return 0;
  278. }
  279. #if defined(CONFIG_OF_LIBFDT)
  280. static int bootm_find_fdt(int flag, int argc, char * const argv[])
  281. {
  282. int ret;
  283. /* find flattened device tree */
  284. ret = boot_get_fdt(flag, argc, argv, IH_ARCH_DEFAULT, &images,
  285. &images.ft_addr, &images.ft_len);
  286. if (ret) {
  287. puts("Could not find a valid device tree\n");
  288. return 1;
  289. }
  290. set_working_fdt_addr(images.ft_addr);
  291. return 0;
  292. }
  293. #endif
  294. static int bootm_find_other(cmd_tbl_t *cmdtp, int flag, int argc,
  295. char * const argv[])
  296. {
  297. if (((images.os.type == IH_TYPE_KERNEL) ||
  298. (images.os.type == IH_TYPE_KERNEL_NOLOAD) ||
  299. (images.os.type == IH_TYPE_MULTI)) &&
  300. (images.os.os == IH_OS_LINUX)) {
  301. if (bootm_find_ramdisk(flag, argc, argv))
  302. return 1;
  303. #if defined(CONFIG_OF_LIBFDT)
  304. if (bootm_find_fdt(flag, argc, argv))
  305. return 1;
  306. #endif
  307. }
  308. return 0;
  309. }
  310. #define BOOTM_ERR_RESET -1
  311. #define BOOTM_ERR_OVERLAP -2
  312. #define BOOTM_ERR_UNIMPLEMENTED -3
  313. static int bootm_load_os(bootm_headers_t *images, unsigned long *load_end,
  314. int boot_progress)
  315. {
  316. image_info_t os = images->os;
  317. uint8_t comp = os.comp;
  318. ulong load = os.load;
  319. ulong blob_start = os.start;
  320. ulong blob_end = os.end;
  321. ulong image_start = os.image_start;
  322. ulong image_len = os.image_len;
  323. __maybe_unused uint unc_len = CONFIG_SYS_BOOTM_LEN;
  324. int no_overlap = 0;
  325. void *load_buf, *image_buf;
  326. #if defined(CONFIG_LZMA) || defined(CONFIG_LZO)
  327. int ret;
  328. #endif /* defined(CONFIG_LZMA) || defined(CONFIG_LZO) */
  329. const char *type_name = genimg_get_type_name(os.type);
  330. load_buf = map_sysmem(load, image_len);
  331. image_buf = map_sysmem(image_start, image_len);
  332. switch (comp) {
  333. case IH_COMP_NONE:
  334. if (load == blob_start || load == image_start) {
  335. printf(" XIP %s ... ", type_name);
  336. no_overlap = 1;
  337. } else {
  338. printf(" Loading %s ... ", type_name);
  339. memmove_wd(load_buf, image_buf, image_len, CHUNKSZ);
  340. }
  341. *load_end = load + image_len;
  342. break;
  343. #ifdef CONFIG_GZIP
  344. case IH_COMP_GZIP:
  345. printf(" Uncompressing %s ... ", type_name);
  346. if (gunzip(load_buf, unc_len, image_buf, &image_len) != 0) {
  347. puts("GUNZIP: uncompress, out-of-mem or overwrite "
  348. "error - must RESET board to recover\n");
  349. if (boot_progress)
  350. bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE);
  351. return BOOTM_ERR_RESET;
  352. }
  353. *load_end = load + image_len;
  354. break;
  355. #endif /* CONFIG_GZIP */
  356. #ifdef CONFIG_BZIP2
  357. case IH_COMP_BZIP2:
  358. printf(" Uncompressing %s ... ", type_name);
  359. /*
  360. * If we've got less than 4 MB of malloc() space,
  361. * use slower decompression algorithm which requires
  362. * at most 2300 KB of memory.
  363. */
  364. int i = BZ2_bzBuffToBuffDecompress(load_buf, &unc_len,
  365. image_buf, image_len,
  366. CONFIG_SYS_MALLOC_LEN < (4096 * 1024), 0);
  367. if (i != BZ_OK) {
  368. printf("BUNZIP2: uncompress or overwrite error %d "
  369. "- must RESET board to recover\n", i);
  370. if (boot_progress)
  371. bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE);
  372. return BOOTM_ERR_RESET;
  373. }
  374. *load_end = load + unc_len;
  375. break;
  376. #endif /* CONFIG_BZIP2 */
  377. #ifdef CONFIG_LZMA
  378. case IH_COMP_LZMA: {
  379. SizeT lzma_len = unc_len;
  380. printf(" Uncompressing %s ... ", type_name);
  381. ret = lzmaBuffToBuffDecompress(load_buf, &lzma_len,
  382. image_buf, image_len);
  383. unc_len = lzma_len;
  384. if (ret != SZ_OK) {
  385. printf("LZMA: uncompress or overwrite error %d "
  386. "- must RESET board to recover\n", ret);
  387. bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE);
  388. return BOOTM_ERR_RESET;
  389. }
  390. *load_end = load + unc_len;
  391. break;
  392. }
  393. #endif /* CONFIG_LZMA */
  394. #ifdef CONFIG_LZO
  395. case IH_COMP_LZO:
  396. printf(" Uncompressing %s ... ", type_name);
  397. ret = lzop_decompress(image_buf, image_len, load_buf,
  398. &unc_len);
  399. if (ret != LZO_E_OK) {
  400. printf("LZO: uncompress or overwrite error %d "
  401. "- must RESET board to recover\n", ret);
  402. if (boot_progress)
  403. bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE);
  404. return BOOTM_ERR_RESET;
  405. }
  406. *load_end = load + unc_len;
  407. break;
  408. #endif /* CONFIG_LZO */
  409. default:
  410. printf("Unimplemented compression type %d\n", comp);
  411. return BOOTM_ERR_UNIMPLEMENTED;
  412. }
  413. flush_cache(load, (*load_end - load) * sizeof(ulong));
  414. puts("OK\n");
  415. debug(" kernel loaded at 0x%08lx, end = 0x%08lx\n", load, *load_end);
  416. bootstage_mark(BOOTSTAGE_ID_KERNEL_LOADED);
  417. if (!no_overlap && (load < blob_end) && (*load_end > blob_start)) {
  418. debug("images.os.start = 0x%lX, images.os.end = 0x%lx\n",
  419. blob_start, blob_end);
  420. debug("images.os.load = 0x%lx, load_end = 0x%lx\n", load,
  421. *load_end);
  422. /* Check what type of image this is. */
  423. if (images->legacy_hdr_valid) {
  424. if (image_get_type(&images->legacy_hdr_os_copy)
  425. == IH_TYPE_MULTI)
  426. puts("WARNING: legacy format multi component image overwritten\n");
  427. return BOOTM_ERR_OVERLAP;
  428. } else {
  429. puts("ERROR: new format image overwritten - must RESET the board to recover\n");
  430. bootstage_error(BOOTSTAGE_ID_OVERWRITTEN);
  431. return BOOTM_ERR_RESET;
  432. }
  433. }
  434. return 0;
  435. }
  436. static int bootm_start_standalone(int argc, char * const argv[])
  437. {
  438. char *s;
  439. int (*appl)(int, char * const []);
  440. /* Don't start if "autostart" is set to "no" */
  441. if (((s = getenv("autostart")) != NULL) && (strcmp(s, "no") == 0)) {
  442. setenv_hex("filesize", images.os.image_len);
  443. return 0;
  444. }
  445. appl = (int (*)(int, char * const []))(ulong)ntohl(images.ep);
  446. (*appl)(argc, argv);
  447. return 0;
  448. }
  449. /* we overload the cmd field with our state machine info instead of a
  450. * function pointer */
  451. static cmd_tbl_t cmd_bootm_sub[] = {
  452. U_BOOT_CMD_MKENT(start, 0, 1, (void *)BOOTM_STATE_START, "", ""),
  453. U_BOOT_CMD_MKENT(loados, 0, 1, (void *)BOOTM_STATE_LOADOS, "", ""),
  454. #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
  455. U_BOOT_CMD_MKENT(ramdisk, 0, 1, (void *)BOOTM_STATE_RAMDISK, "", ""),
  456. #endif
  457. #ifdef CONFIG_OF_LIBFDT
  458. U_BOOT_CMD_MKENT(fdt, 0, 1, (void *)BOOTM_STATE_FDT, "", ""),
  459. #endif
  460. U_BOOT_CMD_MKENT(cmdline, 0, 1, (void *)BOOTM_STATE_OS_CMDLINE, "", ""),
  461. U_BOOT_CMD_MKENT(bdt, 0, 1, (void *)BOOTM_STATE_OS_BD_T, "", ""),
  462. U_BOOT_CMD_MKENT(prep, 0, 1, (void *)BOOTM_STATE_OS_PREP, "", ""),
  463. U_BOOT_CMD_MKENT(fake, 0, 1, (void *)BOOTM_STATE_OS_FAKE_GO, "", ""),
  464. U_BOOT_CMD_MKENT(go, 0, 1, (void *)BOOTM_STATE_OS_GO, "", ""),
  465. };
  466. static int boot_selected_os(int argc, char * const argv[], int state,
  467. bootm_headers_t *images, boot_os_fn *boot_fn)
  468. {
  469. if (images->os.type == IH_TYPE_STANDALONE) {
  470. /* This may return when 'autostart' is 'no' */
  471. bootm_start_standalone(argc, argv);
  472. return 0;
  473. }
  474. arch_preboot_os();
  475. boot_fn(state, argc, argv, images);
  476. if (state == BOOTM_STATE_OS_FAKE_GO) /* We expect to return */
  477. return 0;
  478. bootstage_error(BOOTSTAGE_ID_BOOT_OS_RETURNED);
  479. #ifdef DEBUG
  480. puts("\n## Control returned to monitor - resetting...\n");
  481. #endif
  482. return BOOTM_ERR_RESET;
  483. }
  484. /**
  485. * bootm_disable_interrupts() - Disable interrupts in preparation for load/boot
  486. *
  487. * @return interrupt flag (0 if interrupts were disabled, non-zero if they were
  488. * enabled)
  489. */
  490. static ulong bootm_disable_interrupts(void)
  491. {
  492. ulong iflag;
  493. /*
  494. * We have reached the point of no return: we are going to
  495. * overwrite all exception vector code, so we cannot easily
  496. * recover from any failures any more...
  497. */
  498. iflag = disable_interrupts();
  499. #ifdef CONFIG_NETCONSOLE
  500. /* Stop the ethernet stack if NetConsole could have left it up */
  501. eth_halt();
  502. #endif
  503. #if defined(CONFIG_CMD_USB)
  504. /*
  505. * turn off USB to prevent the host controller from writing to the
  506. * SDRAM while Linux is booting. This could happen (at least for OHCI
  507. * controller), because the HCCA (Host Controller Communication Area)
  508. * lies within the SDRAM and the host controller writes continously to
  509. * this area (as busmaster!). The HccaFrameNumber is for example
  510. * updated every 1 ms within the HCCA structure in SDRAM! For more
  511. * details see the OpenHCI specification.
  512. */
  513. usb_stop();
  514. #endif
  515. return iflag;
  516. }
  517. /**
  518. * Execute selected states of the bootm command.
  519. *
  520. * Note the arguments to this state must be the first argument, Any 'bootm'
  521. * or sub-command arguments must have already been taken.
  522. *
  523. * Note that if states contains more than one flag it MUST contain
  524. * BOOTM_STATE_START, since this handles and consumes the command line args.
  525. *
  526. * Also note that aside from boot_os_fn functions and bootm_load_os no other
  527. * functions we store the return value of in 'ret' may use a negative return
  528. * value, without special handling.
  529. *
  530. * @param cmdtp Pointer to bootm command table entry
  531. * @param flag Command flags (CMD_FLAG_...)
  532. * @param argc Number of subcommand arguments (0 = no arguments)
  533. * @param argv Arguments
  534. * @param states Mask containing states to run (BOOTM_STATE_...)
  535. * @param images Image header information
  536. * @param boot_progress 1 to show boot progress, 0 to not do this
  537. * @return 0 if ok, something else on error. Some errors will cause this
  538. * function to perform a reboot! If states contains BOOTM_STATE_OS_GO
  539. * then the intent is to boot an OS, so this function will not return
  540. * unless the image type is standalone.
  541. */
  542. static int do_bootm_states(cmd_tbl_t *cmdtp, int flag, int argc,
  543. char * const argv[], int states, bootm_headers_t *images,
  544. int boot_progress)
  545. {
  546. boot_os_fn *boot_fn;
  547. ulong iflag = 0;
  548. int ret = 0, need_boot_fn;
  549. images->state |= states;
  550. /*
  551. * Work through the states and see how far we get. We stop on
  552. * any error.
  553. */
  554. if (states & BOOTM_STATE_START)
  555. ret = bootm_start(cmdtp, flag, argc, argv);
  556. if (!ret && (states & BOOTM_STATE_FINDOS))
  557. ret = bootm_find_os(cmdtp, flag, argc, argv);
  558. if (!ret && (states & BOOTM_STATE_FINDOTHER)) {
  559. ret = bootm_find_other(cmdtp, flag, argc, argv);
  560. argc = 0; /* consume the args */
  561. }
  562. /* Load the OS */
  563. if (!ret && (states & BOOTM_STATE_LOADOS)) {
  564. ulong load_end;
  565. iflag = bootm_disable_interrupts();
  566. ret = bootm_load_os(images, &load_end, 0);
  567. if (ret == 0)
  568. lmb_reserve(&images->lmb, images->os.load,
  569. (load_end - images->os.load));
  570. else if (ret && ret != BOOTM_ERR_OVERLAP)
  571. goto err;
  572. else if (ret == BOOTM_ERR_OVERLAP)
  573. ret = 0;
  574. #ifdef CONFIG_SILENT_CONSOLE
  575. if (images->os.os == IH_OS_LINUX)
  576. fixup_silent_linux();
  577. #endif
  578. }
  579. /* Relocate the ramdisk */
  580. #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
  581. if (!ret && (states & BOOTM_STATE_RAMDISK)) {
  582. ulong rd_len = images->rd_end - images->rd_start;
  583. ret = boot_ramdisk_high(&images->lmb, images->rd_start,
  584. rd_len, &images->initrd_start, &images->initrd_end);
  585. if (!ret) {
  586. setenv_hex("initrd_start", images->initrd_start);
  587. setenv_hex("initrd_end", images->initrd_end);
  588. }
  589. }
  590. #endif
  591. #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_LMB)
  592. if (!ret && (states & BOOTM_STATE_FDT)) {
  593. boot_fdt_add_mem_rsv_regions(&images->lmb, images->ft_addr);
  594. ret = boot_relocate_fdt(&images->lmb, &images->ft_addr,
  595. &images->ft_len);
  596. }
  597. #endif
  598. /* From now on, we need the OS boot function */
  599. if (ret)
  600. return ret;
  601. boot_fn = boot_os[images->os.os];
  602. need_boot_fn = states & (BOOTM_STATE_OS_CMDLINE |
  603. BOOTM_STATE_OS_BD_T | BOOTM_STATE_OS_PREP |
  604. BOOTM_STATE_OS_FAKE_GO | BOOTM_STATE_OS_GO);
  605. if (boot_fn == NULL && need_boot_fn) {
  606. if (iflag)
  607. enable_interrupts();
  608. printf("ERROR: booting os '%s' (%d) is not supported\n",
  609. genimg_get_os_name(images->os.os), images->os.os);
  610. bootstage_error(BOOTSTAGE_ID_CHECK_BOOT_OS);
  611. return 1;
  612. }
  613. /* Call various other states that are not generally used */
  614. if (!ret && (states & BOOTM_STATE_OS_CMDLINE))
  615. ret = boot_fn(BOOTM_STATE_OS_CMDLINE, argc, argv, images);
  616. if (!ret && (states & BOOTM_STATE_OS_BD_T))
  617. ret = boot_fn(BOOTM_STATE_OS_BD_T, argc, argv, images);
  618. if (!ret && (states & BOOTM_STATE_OS_PREP))
  619. ret = boot_fn(BOOTM_STATE_OS_PREP, argc, argv, images);
  620. #ifdef CONFIG_TRACE
  621. /* Pretend to run the OS, then run a user command */
  622. if (!ret && (states & BOOTM_STATE_OS_FAKE_GO)) {
  623. char *cmd_list = getenv("fakegocmd");
  624. ret = boot_selected_os(argc, argv, BOOTM_STATE_OS_FAKE_GO,
  625. images, boot_fn);
  626. if (!ret && cmd_list)
  627. ret = run_command_list(cmd_list, -1, flag);
  628. }
  629. #endif
  630. /* Check for unsupported subcommand. */
  631. if (ret) {
  632. puts("subcommand not supported\n");
  633. return ret;
  634. }
  635. /* Now run the OS! We hope this doesn't return */
  636. if (!ret && (states & BOOTM_STATE_OS_GO))
  637. ret = boot_selected_os(argc, argv, BOOTM_STATE_OS_GO,
  638. images, boot_fn);
  639. /* Deal with any fallout */
  640. err:
  641. if (iflag)
  642. enable_interrupts();
  643. if (ret == BOOTM_ERR_UNIMPLEMENTED)
  644. bootstage_error(BOOTSTAGE_ID_DECOMP_UNIMPL);
  645. else if (ret == BOOTM_ERR_RESET)
  646. do_reset(cmdtp, flag, argc, argv);
  647. return ret;
  648. }
  649. static int do_bootm_subcommand(cmd_tbl_t *cmdtp, int flag, int argc,
  650. char * const argv[])
  651. {
  652. int ret = 0;
  653. long state;
  654. cmd_tbl_t *c;
  655. c = find_cmd_tbl(argv[0], &cmd_bootm_sub[0], ARRAY_SIZE(cmd_bootm_sub));
  656. argc--; argv++;
  657. if (c) {
  658. state = (long)c->cmd;
  659. if (state == BOOTM_STATE_START)
  660. state |= BOOTM_STATE_FINDOS | BOOTM_STATE_FINDOTHER;
  661. } else {
  662. /* Unrecognized command */
  663. return CMD_RET_USAGE;
  664. }
  665. if (state != BOOTM_STATE_START && images.state >= state) {
  666. printf("Trying to execute a command out of order\n");
  667. return CMD_RET_USAGE;
  668. }
  669. ret = do_bootm_states(cmdtp, flag, argc, argv, state, &images, 0);
  670. return ret;
  671. }
  672. /*******************************************************************/
  673. /* bootm - boot application image from image in memory */
  674. /*******************************************************************/
  675. int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  676. {
  677. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  678. static int relocated = 0;
  679. if (!relocated) {
  680. int i;
  681. /* relocate boot function table */
  682. for (i = 0; i < ARRAY_SIZE(boot_os); i++)
  683. if (boot_os[i] != NULL)
  684. boot_os[i] += gd->reloc_off;
  685. /* relocate names of sub-command table */
  686. for (i = 0; i < ARRAY_SIZE(cmd_bootm_sub); i++)
  687. cmd_bootm_sub[i].name += gd->reloc_off;
  688. relocated = 1;
  689. }
  690. #endif
  691. /* determine if we have a sub command */
  692. argc--; argv++;
  693. if (argc > 0) {
  694. char *endp;
  695. simple_strtoul(argv[0], &endp, 16);
  696. /* endp pointing to NULL means that argv[0] was just a
  697. * valid number, pass it along to the normal bootm processing
  698. *
  699. * If endp is ':' or '#' assume a FIT identifier so pass
  700. * along for normal processing.
  701. *
  702. * Right now we assume the first arg should never be '-'
  703. */
  704. if ((*endp != 0) && (*endp != ':') && (*endp != '#'))
  705. return do_bootm_subcommand(cmdtp, flag, argc, argv);
  706. }
  707. return do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START |
  708. BOOTM_STATE_FINDOS | BOOTM_STATE_FINDOTHER |
  709. BOOTM_STATE_LOADOS | BOOTM_STATE_OS_PREP |
  710. BOOTM_STATE_OS_FAKE_GO | BOOTM_STATE_OS_GO, &images, 1);
  711. }
  712. int bootm_maybe_autostart(cmd_tbl_t *cmdtp, const char *cmd)
  713. {
  714. const char *ep = getenv("autostart");
  715. if (ep && !strcmp(ep, "yes")) {
  716. char *local_args[2];
  717. local_args[0] = (char *)cmd;
  718. local_args[1] = NULL;
  719. printf("Automatic boot of image at addr 0x%08lX ...\n", load_addr);
  720. return do_bootm(cmdtp, 0, 1, local_args);
  721. }
  722. return 0;
  723. }
  724. /**
  725. * image_get_kernel - verify legacy format kernel image
  726. * @img_addr: in RAM address of the legacy format image to be verified
  727. * @verify: data CRC verification flag
  728. *
  729. * image_get_kernel() verifies legacy image integrity and returns pointer to
  730. * legacy image header if image verification was completed successfully.
  731. *
  732. * returns:
  733. * pointer to a legacy image header if valid image was found
  734. * otherwise return NULL
  735. */
  736. static image_header_t *image_get_kernel(ulong img_addr, int verify)
  737. {
  738. image_header_t *hdr = (image_header_t *)img_addr;
  739. if (!image_check_magic(hdr)) {
  740. puts("Bad Magic Number\n");
  741. bootstage_error(BOOTSTAGE_ID_CHECK_MAGIC);
  742. return NULL;
  743. }
  744. bootstage_mark(BOOTSTAGE_ID_CHECK_HEADER);
  745. if (!image_check_hcrc(hdr)) {
  746. puts("Bad Header Checksum\n");
  747. bootstage_error(BOOTSTAGE_ID_CHECK_HEADER);
  748. return NULL;
  749. }
  750. bootstage_mark(BOOTSTAGE_ID_CHECK_CHECKSUM);
  751. image_print_contents(hdr);
  752. if (verify) {
  753. puts(" Verifying Checksum ... ");
  754. if (!image_check_dcrc(hdr)) {
  755. printf("Bad Data CRC\n");
  756. bootstage_error(BOOTSTAGE_ID_CHECK_CHECKSUM);
  757. return NULL;
  758. }
  759. puts("OK\n");
  760. }
  761. bootstage_mark(BOOTSTAGE_ID_CHECK_ARCH);
  762. if (!image_check_target_arch(hdr)) {
  763. printf("Unsupported Architecture 0x%x\n", image_get_arch(hdr));
  764. bootstage_error(BOOTSTAGE_ID_CHECK_ARCH);
  765. return NULL;
  766. }
  767. return hdr;
  768. }
  769. /**
  770. * boot_get_kernel - find kernel image
  771. * @os_data: pointer to a ulong variable, will hold os data start address
  772. * @os_len: pointer to a ulong variable, will hold os data length
  773. *
  774. * boot_get_kernel() tries to find a kernel image, verifies its integrity
  775. * and locates kernel data.
  776. *
  777. * returns:
  778. * pointer to image header if valid image was found, plus kernel start
  779. * address and length, otherwise NULL
  780. */
  781. static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
  782. char * const argv[], bootm_headers_t *images, ulong *os_data,
  783. ulong *os_len)
  784. {
  785. image_header_t *hdr;
  786. ulong img_addr;
  787. const void *buf;
  788. #if defined(CONFIG_FIT)
  789. const char *fit_uname_config = NULL;
  790. const char *fit_uname_kernel = NULL;
  791. int os_noffset;
  792. #endif
  793. /* find out kernel image address */
  794. if (argc < 1) {
  795. img_addr = load_addr;
  796. debug("* kernel: default image load address = 0x%08lx\n",
  797. load_addr);
  798. #if defined(CONFIG_FIT)
  799. } else if (fit_parse_conf(argv[0], load_addr, &img_addr,
  800. &fit_uname_config)) {
  801. debug("* kernel: config '%s' from image at 0x%08lx\n",
  802. fit_uname_config, img_addr);
  803. } else if (fit_parse_subimage(argv[0], load_addr, &img_addr,
  804. &fit_uname_kernel)) {
  805. debug("* kernel: subimage '%s' from image at 0x%08lx\n",
  806. fit_uname_kernel, img_addr);
  807. #endif
  808. } else {
  809. img_addr = simple_strtoul(argv[0], NULL, 16);
  810. debug("* kernel: cmdline image address = 0x%08lx\n", img_addr);
  811. }
  812. bootstage_mark(BOOTSTAGE_ID_CHECK_MAGIC);
  813. /* copy from dataflash if needed */
  814. img_addr = genimg_get_image(img_addr);
  815. /* check image type, for FIT images get FIT kernel node */
  816. *os_data = *os_len = 0;
  817. buf = map_sysmem(img_addr, 0);
  818. switch (genimg_get_format(buf)) {
  819. case IMAGE_FORMAT_LEGACY:
  820. printf("## Booting kernel from Legacy Image at %08lx ...\n",
  821. img_addr);
  822. hdr = image_get_kernel(img_addr, images->verify);
  823. if (!hdr)
  824. return NULL;
  825. bootstage_mark(BOOTSTAGE_ID_CHECK_IMAGETYPE);
  826. /* get os_data and os_len */
  827. switch (image_get_type(hdr)) {
  828. case IH_TYPE_KERNEL:
  829. case IH_TYPE_KERNEL_NOLOAD:
  830. *os_data = image_get_data(hdr);
  831. *os_len = image_get_data_size(hdr);
  832. break;
  833. case IH_TYPE_MULTI:
  834. image_multi_getimg(hdr, 0, os_data, os_len);
  835. break;
  836. case IH_TYPE_STANDALONE:
  837. *os_data = image_get_data(hdr);
  838. *os_len = image_get_data_size(hdr);
  839. break;
  840. default:
  841. printf("Wrong Image Type for %s command\n",
  842. cmdtp->name);
  843. bootstage_error(BOOTSTAGE_ID_CHECK_IMAGETYPE);
  844. return NULL;
  845. }
  846. /*
  847. * copy image header to allow for image overwrites during
  848. * kernel decompression.
  849. */
  850. memmove(&images->legacy_hdr_os_copy, hdr,
  851. sizeof(image_header_t));
  852. /* save pointer to image header */
  853. images->legacy_hdr_os = hdr;
  854. images->legacy_hdr_valid = 1;
  855. bootstage_mark(BOOTSTAGE_ID_DECOMP_IMAGE);
  856. break;
  857. #if defined(CONFIG_FIT)
  858. case IMAGE_FORMAT_FIT:
  859. os_noffset = fit_image_load(images, FIT_KERNEL_PROP,
  860. img_addr,
  861. &fit_uname_kernel, &fit_uname_config,
  862. IH_ARCH_DEFAULT, IH_TYPE_KERNEL,
  863. BOOTSTAGE_ID_FIT_KERNEL_START,
  864. FIT_LOAD_IGNORED, os_data, os_len);
  865. if (os_noffset < 0)
  866. return NULL;
  867. images->fit_hdr_os = map_sysmem(img_addr, 0);
  868. images->fit_uname_os = fit_uname_kernel;
  869. images->fit_uname_cfg = fit_uname_config;
  870. images->fit_noffset_os = os_noffset;
  871. break;
  872. #endif
  873. default:
  874. printf("Wrong Image Format for %s command\n", cmdtp->name);
  875. bootstage_error(BOOTSTAGE_ID_FIT_KERNEL_INFO);
  876. return NULL;
  877. }
  878. debug(" kernel data at 0x%08lx, len = 0x%08lx (%ld)\n",
  879. *os_data, *os_len, *os_len);
  880. return buf;
  881. }
  882. #ifdef CONFIG_SYS_LONGHELP
  883. static char bootm_help_text[] =
  884. "[addr [arg ...]]\n - boot application image stored in memory\n"
  885. "\tpassing arguments 'arg ...'; when booting a Linux kernel,\n"
  886. "\t'arg' can be the address of an initrd image\n"
  887. #if defined(CONFIG_OF_LIBFDT)
  888. "\tWhen booting a Linux kernel which requires a flat device-tree\n"
  889. "\ta third argument is required which is the address of the\n"
  890. "\tdevice-tree blob. To boot that kernel without an initrd image,\n"
  891. "\tuse a '-' for the second argument. If you do not pass a third\n"
  892. "\ta bd_info struct will be passed instead\n"
  893. #endif
  894. #if defined(CONFIG_FIT)
  895. "\t\nFor the new multi component uImage format (FIT) addresses\n"
  896. "\tmust be extened to include component or configuration unit name:\n"
  897. "\taddr:<subimg_uname> - direct component image specification\n"
  898. "\taddr#<conf_uname> - configuration specification\n"
  899. "\tUse iminfo command to get the list of existing component\n"
  900. "\timages and configurations.\n"
  901. #endif
  902. "\nSub-commands to do part of the bootm sequence. The sub-commands "
  903. "must be\n"
  904. "issued in the order below (it's ok to not issue all sub-commands):\n"
  905. "\tstart [addr [arg ...]]\n"
  906. "\tloados - load OS image\n"
  907. #if defined(CONFIG_SYS_BOOT_RAMDISK_HIGH)
  908. "\tramdisk - relocate initrd, set env initrd_start/initrd_end\n"
  909. #endif
  910. #if defined(CONFIG_OF_LIBFDT)
  911. "\tfdt - relocate flat device tree\n"
  912. #endif
  913. "\tcmdline - OS specific command line processing/setup\n"
  914. "\tbdt - OS specific bd_t processing\n"
  915. "\tprep - OS specific prep before relocation or go\n"
  916. "\tgo - start OS";
  917. #endif
  918. U_BOOT_CMD(
  919. bootm, CONFIG_SYS_MAXARGS, 1, do_bootm,
  920. "boot application image from memory", bootm_help_text
  921. );
  922. /*******************************************************************/
  923. /* bootd - boot default image */
  924. /*******************************************************************/
  925. #if defined(CONFIG_CMD_BOOTD)
  926. int do_bootd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  927. {
  928. int rcode = 0;
  929. if (run_command(getenv("bootcmd"), flag) < 0)
  930. rcode = 1;
  931. return rcode;
  932. }
  933. U_BOOT_CMD(
  934. boot, 1, 1, do_bootd,
  935. "boot default, i.e., run 'bootcmd'",
  936. ""
  937. );
  938. /* keep old command name "bootd" for backward compatibility */
  939. U_BOOT_CMD(
  940. bootd, 1, 1, do_bootd,
  941. "boot default, i.e., run 'bootcmd'",
  942. ""
  943. );
  944. #endif
  945. /*******************************************************************/
  946. /* iminfo - print header info for a requested image */
  947. /*******************************************************************/
  948. #if defined(CONFIG_CMD_IMI)
  949. static int do_iminfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  950. {
  951. int arg;
  952. ulong addr;
  953. int rcode = 0;
  954. if (argc < 2) {
  955. return image_info(load_addr);
  956. }
  957. for (arg = 1; arg < argc; ++arg) {
  958. addr = simple_strtoul(argv[arg], NULL, 16);
  959. if (image_info(addr) != 0)
  960. rcode = 1;
  961. }
  962. return rcode;
  963. }
  964. static int image_info(ulong addr)
  965. {
  966. void *hdr = (void *)addr;
  967. printf("\n## Checking Image at %08lx ...\n", addr);
  968. switch (genimg_get_format(hdr)) {
  969. case IMAGE_FORMAT_LEGACY:
  970. puts(" Legacy image found\n");
  971. if (!image_check_magic(hdr)) {
  972. puts(" Bad Magic Number\n");
  973. return 1;
  974. }
  975. if (!image_check_hcrc(hdr)) {
  976. puts(" Bad Header Checksum\n");
  977. return 1;
  978. }
  979. image_print_contents(hdr);
  980. puts(" Verifying Checksum ... ");
  981. if (!image_check_dcrc(hdr)) {
  982. puts(" Bad Data CRC\n");
  983. return 1;
  984. }
  985. puts("OK\n");
  986. return 0;
  987. #if defined(CONFIG_FIT)
  988. case IMAGE_FORMAT_FIT:
  989. puts(" FIT image found\n");
  990. if (!fit_check_format(hdr)) {
  991. puts("Bad FIT image format!\n");
  992. return 1;
  993. }
  994. fit_print_contents(hdr);
  995. if (!fit_all_image_verify(hdr)) {
  996. puts("Bad hash in FIT image!\n");
  997. return 1;
  998. }
  999. return 0;
  1000. #endif
  1001. default:
  1002. puts("Unknown image format!\n");
  1003. break;
  1004. }
  1005. return 1;
  1006. }
  1007. U_BOOT_CMD(
  1008. iminfo, CONFIG_SYS_MAXARGS, 1, do_iminfo,
  1009. "print header information for application image",
  1010. "addr [addr ...]\n"
  1011. " - print header information for application image starting at\n"
  1012. " address 'addr' in memory; this includes verification of the\n"
  1013. " image contents (magic number, header and payload checksums)"
  1014. );
  1015. #endif
  1016. /*******************************************************************/
  1017. /* imls - list all images found in flash */
  1018. /*******************************************************************/
  1019. #if defined(CONFIG_CMD_IMLS)
  1020. static int do_imls_nor(void)
  1021. {
  1022. flash_info_t *info;
  1023. int i, j;
  1024. void *hdr;
  1025. for (i = 0, info = &flash_info[0];
  1026. i < CONFIG_SYS_MAX_FLASH_BANKS; ++i, ++info) {
  1027. if (info->flash_id == FLASH_UNKNOWN)
  1028. goto next_bank;
  1029. for (j = 0; j < info->sector_count; ++j) {
  1030. hdr = (void *)info->start[j];
  1031. if (!hdr)
  1032. goto next_sector;
  1033. switch (genimg_get_format(hdr)) {
  1034. case IMAGE_FORMAT_LEGACY:
  1035. if (!image_check_hcrc(hdr))
  1036. goto next_sector;
  1037. printf("Legacy Image at %08lX:\n", (ulong)hdr);
  1038. image_print_contents(hdr);
  1039. puts(" Verifying Checksum ... ");
  1040. if (!image_check_dcrc(hdr)) {
  1041. puts("Bad Data CRC\n");
  1042. } else {
  1043. puts("OK\n");
  1044. }
  1045. break;
  1046. #if defined(CONFIG_FIT)
  1047. case IMAGE_FORMAT_FIT:
  1048. if (!fit_check_format(hdr))
  1049. goto next_sector;
  1050. printf("FIT Image at %08lX:\n", (ulong)hdr);
  1051. fit_print_contents(hdr);
  1052. break;
  1053. #endif
  1054. default:
  1055. goto next_sector;
  1056. }
  1057. next_sector: ;
  1058. }
  1059. next_bank: ;
  1060. }
  1061. return 0;
  1062. }
  1063. #endif
  1064. #if defined(CONFIG_CMD_IMLS_NAND)
  1065. static int nand_imls_legacyimage(nand_info_t *nand, int nand_dev, loff_t off,
  1066. size_t len)
  1067. {
  1068. void *imgdata;
  1069. int ret;
  1070. imgdata = malloc(len);
  1071. if (!imgdata) {
  1072. printf("May be a Legacy Image at NAND device %d offset %08llX:\n",
  1073. nand_dev, off);
  1074. printf(" Low memory(cannot allocate memory for image)\n");
  1075. return -ENOMEM;
  1076. }
  1077. ret = nand_read_skip_bad(nand, off, &len,
  1078. imgdata);
  1079. if (ret < 0 && ret != -EUCLEAN) {
  1080. free(imgdata);
  1081. return ret;
  1082. }
  1083. if (!image_check_hcrc(imgdata)) {
  1084. free(imgdata);
  1085. return 0;
  1086. }
  1087. printf("Legacy Image at NAND device %d offset %08llX:\n",
  1088. nand_dev, off);
  1089. image_print_contents(imgdata);
  1090. puts(" Verifying Checksum ... ");
  1091. if (!image_check_dcrc(imgdata))
  1092. puts("Bad Data CRC\n");
  1093. else
  1094. puts("OK\n");
  1095. free(imgdata);
  1096. return 0;
  1097. }
  1098. static int nand_imls_fitimage(nand_info_t *nand, int nand_dev, loff_t off,
  1099. size_t len)
  1100. {
  1101. void *imgdata;
  1102. int ret;
  1103. imgdata = malloc(len);
  1104. if (!imgdata) {
  1105. printf("May be a FIT Image at NAND device %d offset %08llX:\n",
  1106. nand_dev, off);
  1107. printf(" Low memory(cannot allocate memory for image)\n");
  1108. return -ENOMEM;
  1109. }
  1110. ret = nand_read_skip_bad(nand, off, &len,
  1111. imgdata);
  1112. if (ret < 0 && ret != -EUCLEAN) {
  1113. free(imgdata);
  1114. return ret;
  1115. }
  1116. if (!fit_check_format(imgdata)) {
  1117. free(imgdata);
  1118. return 0;
  1119. }
  1120. printf("FIT Image at NAND device %d offset %08llX:\n", nand_dev, off);
  1121. fit_print_contents(imgdata);
  1122. free(imgdata);
  1123. return 0;
  1124. }
  1125. static int do_imls_nand(void)
  1126. {
  1127. nand_info_t *nand;
  1128. int nand_dev = nand_curr_device;
  1129. size_t len;
  1130. loff_t off;
  1131. u32 buffer[16];
  1132. if (nand_dev < 0 || nand_dev >= CONFIG_SYS_MAX_NAND_DEVICE) {
  1133. puts("\nNo NAND devices available\n");
  1134. return -ENODEV;
  1135. }
  1136. printf("\n");
  1137. for (nand_dev = 0; nand_dev < CONFIG_SYS_MAX_NAND_DEVICE; nand_dev++) {
  1138. nand = &nand_info[nand_dev];
  1139. if (!nand->name || !nand->size)
  1140. continue;
  1141. for (off = 0; off < nand->size; off += nand->erasesize) {
  1142. const image_header_t *header;
  1143. int ret;
  1144. if (nand_block_isbad(nand, off))
  1145. continue;
  1146. len = sizeof(buffer);
  1147. ret = nand_read(nand, off, &len, (u8 *)buffer);
  1148. if (ret < 0 && ret != -EUCLEAN) {
  1149. printf("NAND read error %d at offset %08llX\n",
  1150. ret, off);
  1151. continue;
  1152. }
  1153. switch (genimg_get_format(buffer)) {
  1154. case IMAGE_FORMAT_LEGACY:
  1155. header = (const image_header_t *)buffer;
  1156. len = image_get_image_size(header);
  1157. nand_imls_legacyimage(nand, nand_dev, off, len);
  1158. break;
  1159. #if defined(CONFIG_FIT)
  1160. case IMAGE_FORMAT_FIT:
  1161. len = fit_get_size(buffer);
  1162. nand_imls_fitimage(nand, nand_dev, off, len);
  1163. break;
  1164. #endif
  1165. }
  1166. }
  1167. }
  1168. return 0;
  1169. }
  1170. #endif
  1171. #if defined(CONFIG_CMD_IMLS) || defined(CONFIG_CMD_IMLS_NAND)
  1172. static int do_imls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  1173. {
  1174. int ret_nor = 0, ret_nand = 0;
  1175. #if defined(CONFIG_CMD_IMLS)
  1176. ret_nor = do_imls_nor();
  1177. #endif
  1178. #if defined(CONFIG_CMD_IMLS_NAND)
  1179. ret_nand = do_imls_nand();
  1180. #endif
  1181. if (ret_nor)
  1182. return ret_nor;
  1183. if (ret_nand)
  1184. return ret_nand;
  1185. return (0);
  1186. }
  1187. U_BOOT_CMD(
  1188. imls, 1, 1, do_imls,
  1189. "list all images found in flash",
  1190. "\n"
  1191. " - Prints information about all images found at sector/block\n"
  1192. " boundaries in nor/nand flash."
  1193. );
  1194. #endif
  1195. /*******************************************************************/
  1196. /* helper routines */
  1197. /*******************************************************************/
  1198. #if defined(CONFIG_SILENT_CONSOLE) && !defined(CONFIG_SILENT_U_BOOT_ONLY)
  1199. #define CONSOLE_ARG "console="
  1200. #define CONSOLE_ARG_LEN (sizeof(CONSOLE_ARG) - 1)
  1201. static void fixup_silent_linux(void)
  1202. {
  1203. char *buf;
  1204. const char *env_val;
  1205. char *cmdline = getenv("bootargs");
  1206. /* Only fix cmdline when requested */
  1207. if (!(gd->flags & GD_FLG_SILENT))
  1208. return;
  1209. debug("before silent fix-up: %s\n", cmdline);
  1210. if (cmdline && (cmdline[0] != '\0')) {
  1211. char *start = strstr(cmdline, CONSOLE_ARG);
  1212. /* Allocate space for maximum possible new command line */
  1213. buf = malloc(strlen(cmdline) + 1 + CONSOLE_ARG_LEN + 1);
  1214. if (!buf) {
  1215. debug("%s: out of memory\n", __func__);
  1216. return;
  1217. }
  1218. if (start) {
  1219. char *end = strchr(start, ' ');
  1220. int num_start_bytes = start - cmdline + CONSOLE_ARG_LEN;
  1221. strncpy(buf, cmdline, num_start_bytes);
  1222. if (end)
  1223. strcpy(buf + num_start_bytes, end);
  1224. else
  1225. buf[num_start_bytes] = '\0';
  1226. } else {
  1227. sprintf(buf, "%s %s", cmdline, CONSOLE_ARG);
  1228. }
  1229. env_val = buf;
  1230. } else {
  1231. buf = NULL;
  1232. env_val = CONSOLE_ARG;
  1233. }
  1234. setenv("bootargs", env_val);
  1235. debug("after silent fix-up: %s\n", env_val);
  1236. free(buf);
  1237. }
  1238. #endif /* CONFIG_SILENT_CONSOLE */
  1239. #if defined(CONFIG_BOOTM_NETBSD) || defined(CONFIG_BOOTM_PLAN9)
  1240. static void copy_args(char *dest, int argc, char * const argv[], char delim)
  1241. {
  1242. int i;
  1243. for (i = 0; i < argc; i++) {
  1244. if (i > 0)
  1245. *dest++ = delim;
  1246. strcpy(dest, argv[i]);
  1247. dest += strlen(argv[i]);
  1248. }
  1249. }
  1250. #endif
  1251. /*******************************************************************/
  1252. /* OS booting routines */
  1253. /*******************************************************************/
  1254. #ifdef CONFIG_BOOTM_NETBSD
  1255. static int do_bootm_netbsd(int flag, int argc, char * const argv[],
  1256. bootm_headers_t *images)
  1257. {
  1258. void (*loader)(bd_t *, image_header_t *, char *, char *);
  1259. image_header_t *os_hdr, *hdr;
  1260. ulong kernel_data, kernel_len;
  1261. char *consdev;
  1262. char *cmdline;
  1263. if (flag & BOOTM_STATE_OS_PREP)
  1264. return 0;
  1265. if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
  1266. return 1;
  1267. #if defined(CONFIG_FIT)
  1268. if (!images->legacy_hdr_valid) {
  1269. fit_unsupported_reset("NetBSD");
  1270. return 1;
  1271. }
  1272. #endif
  1273. hdr = images->legacy_hdr_os;
  1274. /*
  1275. * Booting a (NetBSD) kernel image
  1276. *
  1277. * This process is pretty similar to a standalone application:
  1278. * The (first part of an multi-) image must be a stage-2 loader,
  1279. * which in turn is responsible for loading & invoking the actual
  1280. * kernel. The only differences are the parameters being passed:
  1281. * besides the board info strucure, the loader expects a command
  1282. * line, the name of the console device, and (optionally) the
  1283. * address of the original image header.
  1284. */
  1285. os_hdr = NULL;
  1286. if (image_check_type(&images->legacy_hdr_os_copy, IH_TYPE_MULTI)) {
  1287. image_multi_getimg(hdr, 1, &kernel_data, &kernel_len);
  1288. if (kernel_len)
  1289. os_hdr = hdr;
  1290. }
  1291. consdev = "";
  1292. #if defined(CONFIG_8xx_CONS_SMC1)
  1293. consdev = "smc1";
  1294. #elif defined(CONFIG_8xx_CONS_SMC2)
  1295. consdev = "smc2";
  1296. #elif defined(CONFIG_8xx_CONS_SCC2)
  1297. consdev = "scc2";
  1298. #elif defined(CONFIG_8xx_CONS_SCC3)
  1299. consdev = "scc3";
  1300. #endif
  1301. if (argc > 0) {
  1302. ulong len;
  1303. int i;
  1304. for (i = 0, len = 0; i < argc; i += 1)
  1305. len += strlen(argv[i]) + 1;
  1306. cmdline = malloc(len);
  1307. copy_args(cmdline, argc, argv, ' ');
  1308. } else if ((cmdline = getenv("bootargs")) == NULL) {
  1309. cmdline = "";
  1310. }
  1311. loader = (void (*)(bd_t *, image_header_t *, char *, char *))images->ep;
  1312. printf("## Transferring control to NetBSD stage-2 loader "
  1313. "(at address %08lx) ...\n",
  1314. (ulong)loader);
  1315. bootstage_mark(BOOTSTAGE_ID_RUN_OS);
  1316. /*
  1317. * NetBSD Stage-2 Loader Parameters:
  1318. * r3: ptr to board info data
  1319. * r4: image address
  1320. * r5: console device
  1321. * r6: boot args string
  1322. */
  1323. (*loader)(gd->bd, os_hdr, consdev, cmdline);
  1324. return 1;
  1325. }
  1326. #endif /* CONFIG_BOOTM_NETBSD*/
  1327. #ifdef CONFIG_LYNXKDI
  1328. static int do_bootm_lynxkdi(int flag, int argc, char * const argv[],
  1329. bootm_headers_t *images)
  1330. {
  1331. image_header_t *hdr = &images->legacy_hdr_os_copy;
  1332. if (flag & BOOTM_STATE_OS_PREP)
  1333. return 0;
  1334. if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
  1335. return 1;
  1336. #if defined(CONFIG_FIT)
  1337. if (!images->legacy_hdr_valid) {
  1338. fit_unsupported_reset("Lynx");
  1339. return 1;
  1340. }
  1341. #endif
  1342. lynxkdi_boot((image_header_t *)hdr);
  1343. return 1;
  1344. }
  1345. #endif /* CONFIG_LYNXKDI */
  1346. #ifdef CONFIG_BOOTM_RTEMS
  1347. static int do_bootm_rtems(int flag, int argc, char * const argv[],
  1348. bootm_headers_t *images)
  1349. {
  1350. void (*entry_point)(bd_t *);
  1351. if (flag & BOOTM_STATE_OS_PREP)
  1352. return 0;
  1353. if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
  1354. return 1;
  1355. #if defined(CONFIG_FIT)
  1356. if (!images->legacy_hdr_valid) {
  1357. fit_unsupported_reset("RTEMS");
  1358. return 1;
  1359. }
  1360. #endif
  1361. entry_point = (void (*)(bd_t *))images->ep;
  1362. printf("## Transferring control to RTEMS (at address %08lx) ...\n",
  1363. (ulong)entry_point);
  1364. bootstage_mark(BOOTSTAGE_ID_RUN_OS);
  1365. /*
  1366. * RTEMS Parameters:
  1367. * r3: ptr to board info data
  1368. */
  1369. (*entry_point)(gd->bd);
  1370. return 1;
  1371. }
  1372. #endif /* CONFIG_BOOTM_RTEMS */
  1373. #if defined(CONFIG_BOOTM_OSE)
  1374. static int do_bootm_ose(int flag, int argc, char * const argv[],
  1375. bootm_headers_t *images)
  1376. {
  1377. void (*entry_point)(void);
  1378. if (flag & BOOTM_STATE_OS_PREP)
  1379. return 0;
  1380. if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
  1381. return 1;
  1382. #if defined(CONFIG_FIT)
  1383. if (!images->legacy_hdr_valid) {
  1384. fit_unsupported_reset("OSE");
  1385. return 1;
  1386. }
  1387. #endif
  1388. entry_point = (void (*)(void))images->ep;
  1389. printf("## Transferring control to OSE (at address %08lx) ...\n",
  1390. (ulong)entry_point);
  1391. bootstage_mark(BOOTSTAGE_ID_RUN_OS);
  1392. /*
  1393. * OSE Parameters:
  1394. * None
  1395. */
  1396. (*entry_point)();
  1397. return 1;
  1398. }
  1399. #endif /* CONFIG_BOOTM_OSE */
  1400. #if defined(CONFIG_BOOTM_PLAN9)
  1401. static int do_bootm_plan9(int flag, int argc, char * const argv[],
  1402. bootm_headers_t *images)
  1403. {
  1404. void (*entry_point)(void);
  1405. char *s;
  1406. if (flag & BOOTM_STATE_OS_PREP)
  1407. return 0;
  1408. if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
  1409. return 1;
  1410. #if defined(CONFIG_FIT)
  1411. if (!images->legacy_hdr_valid) {
  1412. fit_unsupported_reset("Plan 9");
  1413. return 1;
  1414. }
  1415. #endif
  1416. /* See README.plan9 */
  1417. s = getenv("confaddr");
  1418. if (s != NULL) {
  1419. char *confaddr = (char *)simple_strtoul(s, NULL, 16);
  1420. if (argc > 0) {
  1421. copy_args(confaddr, argc, argv, '\n');
  1422. } else {
  1423. s = getenv("bootargs");
  1424. if (s != NULL)
  1425. strcpy(confaddr, s);
  1426. }
  1427. }
  1428. entry_point = (void (*)(void))images->ep;
  1429. printf("## Transferring control to Plan 9 (at address %08lx) ...\n",
  1430. (ulong)entry_point);
  1431. bootstage_mark(BOOTSTAGE_ID_RUN_OS);
  1432. /*
  1433. * Plan 9 Parameters:
  1434. * None
  1435. */
  1436. (*entry_point)();
  1437. return 1;
  1438. }
  1439. #endif /* CONFIG_BOOTM_PLAN9 */
  1440. #if defined(CONFIG_CMD_ELF)
  1441. static int do_bootm_vxworks(int flag, int argc, char * const argv[],
  1442. bootm_headers_t *images)
  1443. {
  1444. char str[80];
  1445. if (flag & BOOTM_STATE_OS_PREP)
  1446. return 0;
  1447. if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
  1448. return 1;
  1449. #if defined(CONFIG_FIT)
  1450. if (!images->legacy_hdr_valid) {
  1451. fit_unsupported_reset("VxWorks");
  1452. return 1;
  1453. }
  1454. #endif
  1455. sprintf(str, "%lx", images->ep); /* write entry-point into string */
  1456. setenv("loadaddr", str);
  1457. do_bootvx(NULL, 0, 0, NULL);
  1458. return 1;
  1459. }
  1460. static int do_bootm_qnxelf(int flag, int argc, char * const argv[],
  1461. bootm_headers_t *images)
  1462. {
  1463. char *local_args[2];
  1464. char str[16];
  1465. if (flag & BOOTM_STATE_OS_PREP)
  1466. return 0;
  1467. if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
  1468. return 1;
  1469. #if defined(CONFIG_FIT)
  1470. if (!images->legacy_hdr_valid) {
  1471. fit_unsupported_reset("QNX");
  1472. return 1;
  1473. }
  1474. #endif
  1475. sprintf(str, "%lx", images->ep); /* write entry-point into string */
  1476. local_args[0] = argv[0];
  1477. local_args[1] = str; /* and provide it via the arguments */
  1478. do_bootelf(NULL, 0, 2, local_args);
  1479. return 1;
  1480. }
  1481. #endif
  1482. #ifdef CONFIG_INTEGRITY
  1483. static int do_bootm_integrity(int flag, int argc, char * const argv[],
  1484. bootm_headers_t *images)
  1485. {
  1486. void (*entry_point)(void);
  1487. if (flag & BOOTM_STATE_OS_PREP)
  1488. return 0;
  1489. if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
  1490. return 1;
  1491. #if defined(CONFIG_FIT)
  1492. if (!images->legacy_hdr_valid) {
  1493. fit_unsupported_reset("INTEGRITY");
  1494. return 1;
  1495. }
  1496. #endif
  1497. entry_point = (void (*)(void))images->ep;
  1498. printf("## Transferring control to INTEGRITY (at address %08lx) ...\n",
  1499. (ulong)entry_point);
  1500. bootstage_mark(BOOTSTAGE_ID_RUN_OS);
  1501. /*
  1502. * INTEGRITY Parameters:
  1503. * None
  1504. */
  1505. (*entry_point)();
  1506. return 1;
  1507. }
  1508. #endif
  1509. #ifdef CONFIG_CMD_BOOTZ
  1510. int __weak bootz_setup(ulong image, ulong *start, ulong *end)
  1511. {
  1512. /* Please define bootz_setup() for your platform */
  1513. puts("Your platform's zImage format isn't supported yet!\n");
  1514. return -1;
  1515. }
  1516. /*
  1517. * zImage booting support
  1518. */
  1519. static int bootz_start(cmd_tbl_t *cmdtp, int flag, int argc,
  1520. char * const argv[], bootm_headers_t *images)
  1521. {
  1522. int ret;
  1523. ulong zi_start, zi_end;
  1524. ret = do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START,
  1525. images, 1);
  1526. /* Setup Linux kernel zImage entry point */
  1527. if (!argc) {
  1528. images->ep = load_addr;
  1529. debug("* kernel: default image load address = 0x%08lx\n",
  1530. load_addr);
  1531. } else {
  1532. images->ep = simple_strtoul(argv[0], NULL, 16);
  1533. debug("* kernel: cmdline image address = 0x%08lx\n",
  1534. images->ep);
  1535. }
  1536. ret = bootz_setup(images->ep, &zi_start, &zi_end);
  1537. if (ret != 0)
  1538. return 1;
  1539. lmb_reserve(&images->lmb, images->ep, zi_end - zi_start);
  1540. /*
  1541. * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not
  1542. * have a header that provide this informaiton.
  1543. */
  1544. if (bootm_find_ramdisk(flag, argc, argv))
  1545. return 1;
  1546. #if defined(CONFIG_OF_LIBFDT)
  1547. if (bootm_find_fdt(flag, argc, argv))
  1548. return 1;
  1549. #endif
  1550. return 0;
  1551. }
  1552. int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  1553. {
  1554. int ret;
  1555. /* Consume 'bootz' */
  1556. argc--; argv++;
  1557. if (bootz_start(cmdtp, flag, argc, argv, &images))
  1558. return 1;
  1559. /*
  1560. * We are doing the BOOTM_STATE_LOADOS state ourselves, so must
  1561. * disable interrupts ourselves
  1562. */
  1563. bootm_disable_interrupts();
  1564. images.os.os = IH_OS_LINUX;
  1565. ret = do_bootm_states(cmdtp, flag, argc, argv,
  1566. BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
  1567. BOOTM_STATE_OS_GO,
  1568. &images, 1);
  1569. return ret;
  1570. }
  1571. #ifdef CONFIG_SYS_LONGHELP
  1572. static char bootz_help_text[] =
  1573. "[addr [initrd[:size]] [fdt]]\n"
  1574. " - boot Linux zImage stored in memory\n"
  1575. "\tThe argument 'initrd' is optional and specifies the address\n"
  1576. "\tof the initrd in memory. The optional argument ':size' allows\n"
  1577. "\tspecifying the size of RAW initrd.\n"
  1578. #if defined(CONFIG_OF_LIBFDT)
  1579. "\tWhen booting a Linux kernel which requires a flat device-tree\n"
  1580. "\ta third argument is required which is the address of the\n"
  1581. "\tdevice-tree blob. To boot that kernel without an initrd image,\n"
  1582. "\tuse a '-' for the second argument. If you do not pass a third\n"
  1583. "\ta bd_info struct will be passed instead\n"
  1584. #endif
  1585. "";
  1586. #endif
  1587. U_BOOT_CMD(
  1588. bootz, CONFIG_SYS_MAXARGS, 1, do_bootz,
  1589. "boot Linux zImage image from memory", bootz_help_text
  1590. );
  1591. #endif /* CONFIG_CMD_BOOTZ */