cmd_bootm.c 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882
  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. #ifdef CONFIG_SILENT_CONSOLE
  475. if (images->os.os == IH_OS_LINUX)
  476. fixup_silent_linux();
  477. #endif
  478. arch_preboot_os();
  479. boot_fn(state, argc, argv, images);
  480. if (state == BOOTM_STATE_OS_FAKE_GO) /* We expect to return */
  481. return 0;
  482. bootstage_error(BOOTSTAGE_ID_BOOT_OS_RETURNED);
  483. #ifdef DEBUG
  484. puts("\n## Control returned to monitor - resetting...\n");
  485. #endif
  486. return BOOTM_ERR_RESET;
  487. }
  488. /**
  489. * bootm_disable_interrupts() - Disable interrupts in preparation for load/boot
  490. *
  491. * @return interrupt flag (0 if interrupts were disabled, non-zero if they were
  492. * enabled)
  493. */
  494. static ulong bootm_disable_interrupts(void)
  495. {
  496. ulong iflag;
  497. /*
  498. * We have reached the point of no return: we are going to
  499. * overwrite all exception vector code, so we cannot easily
  500. * recover from any failures any more...
  501. */
  502. iflag = disable_interrupts();
  503. #ifdef CONFIG_NETCONSOLE
  504. /* Stop the ethernet stack if NetConsole could have left it up */
  505. eth_halt();
  506. #endif
  507. #if defined(CONFIG_CMD_USB)
  508. /*
  509. * turn off USB to prevent the host controller from writing to the
  510. * SDRAM while Linux is booting. This could happen (at least for OHCI
  511. * controller), because the HCCA (Host Controller Communication Area)
  512. * lies within the SDRAM and the host controller writes continously to
  513. * this area (as busmaster!). The HccaFrameNumber is for example
  514. * updated every 1 ms within the HCCA structure in SDRAM! For more
  515. * details see the OpenHCI specification.
  516. */
  517. usb_stop();
  518. #endif
  519. return iflag;
  520. }
  521. /**
  522. * Execute selected states of the bootm command.
  523. *
  524. * Note the arguments to this state must be the first argument, Any 'bootm'
  525. * or sub-command arguments must have already been taken.
  526. *
  527. * Note that if states contains more than one flag it MUST contain
  528. * BOOTM_STATE_START, since this handles and consumes the command line args.
  529. *
  530. * Also note that aside from boot_os_fn functions and bootm_load_os no other
  531. * functions we store the return value of in 'ret' may use a negative return
  532. * value, without special handling.
  533. *
  534. * @param cmdtp Pointer to bootm command table entry
  535. * @param flag Command flags (CMD_FLAG_...)
  536. * @param argc Number of subcommand arguments (0 = no arguments)
  537. * @param argv Arguments
  538. * @param states Mask containing states to run (BOOTM_STATE_...)
  539. * @param images Image header information
  540. * @param boot_progress 1 to show boot progress, 0 to not do this
  541. * @return 0 if ok, something else on error. Some errors will cause this
  542. * function to perform a reboot! If states contains BOOTM_STATE_OS_GO
  543. * then the intent is to boot an OS, so this function will not return
  544. * unless the image type is standalone.
  545. */
  546. static int do_bootm_states(cmd_tbl_t *cmdtp, int flag, int argc,
  547. char * const argv[], int states, bootm_headers_t *images,
  548. int boot_progress)
  549. {
  550. boot_os_fn *boot_fn;
  551. ulong iflag = 0;
  552. int ret = 0, need_boot_fn;
  553. images->state |= states;
  554. /*
  555. * Work through the states and see how far we get. We stop on
  556. * any error.
  557. */
  558. if (states & BOOTM_STATE_START)
  559. ret = bootm_start(cmdtp, flag, argc, argv);
  560. if (!ret && (states & BOOTM_STATE_FINDOS))
  561. ret = bootm_find_os(cmdtp, flag, argc, argv);
  562. if (!ret && (states & BOOTM_STATE_FINDOTHER)) {
  563. ret = bootm_find_other(cmdtp, flag, argc, argv);
  564. argc = 0; /* consume the args */
  565. }
  566. /* Load the OS */
  567. if (!ret && (states & BOOTM_STATE_LOADOS)) {
  568. ulong load_end;
  569. iflag = bootm_disable_interrupts();
  570. ret = bootm_load_os(images, &load_end, 0);
  571. if (ret == 0)
  572. lmb_reserve(&images->lmb, images->os.load,
  573. (load_end - images->os.load));
  574. else if (ret && ret != BOOTM_ERR_OVERLAP)
  575. goto err;
  576. else if (ret == BOOTM_ERR_OVERLAP)
  577. ret = 0;
  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. /* Check for unsupported subcommand. */
  621. if (ret) {
  622. puts("subcommand not supported\n");
  623. return ret;
  624. }
  625. #ifdef CONFIG_TRACE
  626. /* Pretend to run the OS, then run a user command */
  627. if (!ret && (states & BOOTM_STATE_OS_FAKE_GO)) {
  628. char *cmd_list = getenv("fakegocmd");
  629. ret = boot_selected_os(argc, argv, BOOTM_STATE_OS_FAKE_GO,
  630. images, boot_fn);
  631. if (!ret && cmd_list)
  632. ret = run_command_list(cmd_list, -1, flag);
  633. }
  634. #endif
  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. if (ret)
  640. goto err;
  641. }
  642. return ret;
  643. /* Deal with any fallout */
  644. err:
  645. if (iflag)
  646. enable_interrupts();
  647. if (ret == BOOTM_ERR_UNIMPLEMENTED)
  648. bootstage_error(BOOTSTAGE_ID_DECOMP_UNIMPL);
  649. else if (ret == BOOTM_ERR_RESET)
  650. do_reset(cmdtp, flag, argc, argv);
  651. return ret;
  652. }
  653. static int do_bootm_subcommand(cmd_tbl_t *cmdtp, int flag, int argc,
  654. char * const argv[])
  655. {
  656. int ret = 0;
  657. long state;
  658. cmd_tbl_t *c;
  659. c = find_cmd_tbl(argv[0], &cmd_bootm_sub[0], ARRAY_SIZE(cmd_bootm_sub));
  660. argc--; argv++;
  661. if (c) {
  662. state = (long)c->cmd;
  663. if (state == BOOTM_STATE_START)
  664. state |= BOOTM_STATE_FINDOS | BOOTM_STATE_FINDOTHER;
  665. } else {
  666. /* Unrecognized command */
  667. return CMD_RET_USAGE;
  668. }
  669. if (state != BOOTM_STATE_START && images.state >= state) {
  670. printf("Trying to execute a command out of order\n");
  671. return CMD_RET_USAGE;
  672. }
  673. ret = do_bootm_states(cmdtp, flag, argc, argv, state, &images, 0);
  674. return ret;
  675. }
  676. /*******************************************************************/
  677. /* bootm - boot application image from image in memory */
  678. /*******************************************************************/
  679. int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  680. {
  681. #ifdef CONFIG_NEEDS_MANUAL_RELOC
  682. static int relocated = 0;
  683. if (!relocated) {
  684. int i;
  685. /* relocate boot function table */
  686. for (i = 0; i < ARRAY_SIZE(boot_os); i++)
  687. if (boot_os[i] != NULL)
  688. boot_os[i] += gd->reloc_off;
  689. /* relocate names of sub-command table */
  690. for (i = 0; i < ARRAY_SIZE(cmd_bootm_sub); i++)
  691. cmd_bootm_sub[i].name += gd->reloc_off;
  692. relocated = 1;
  693. }
  694. #endif
  695. /* determine if we have a sub command */
  696. argc--; argv++;
  697. if (argc > 0) {
  698. char *endp;
  699. simple_strtoul(argv[0], &endp, 16);
  700. /* endp pointing to NULL means that argv[0] was just a
  701. * valid number, pass it along to the normal bootm processing
  702. *
  703. * If endp is ':' or '#' assume a FIT identifier so pass
  704. * along for normal processing.
  705. *
  706. * Right now we assume the first arg should never be '-'
  707. */
  708. if ((*endp != 0) && (*endp != ':') && (*endp != '#'))
  709. return do_bootm_subcommand(cmdtp, flag, argc, argv);
  710. }
  711. return do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START |
  712. BOOTM_STATE_FINDOS | BOOTM_STATE_FINDOTHER |
  713. BOOTM_STATE_LOADOS | BOOTM_STATE_OS_PREP |
  714. BOOTM_STATE_OS_FAKE_GO | BOOTM_STATE_OS_GO, &images, 1);
  715. }
  716. int bootm_maybe_autostart(cmd_tbl_t *cmdtp, const char *cmd)
  717. {
  718. const char *ep = getenv("autostart");
  719. if (ep && !strcmp(ep, "yes")) {
  720. char *local_args[2];
  721. local_args[0] = (char *)cmd;
  722. local_args[1] = NULL;
  723. printf("Automatic boot of image at addr 0x%08lX ...\n", load_addr);
  724. return do_bootm(cmdtp, 0, 1, local_args);
  725. }
  726. return 0;
  727. }
  728. /**
  729. * image_get_kernel - verify legacy format kernel image
  730. * @img_addr: in RAM address of the legacy format image to be verified
  731. * @verify: data CRC verification flag
  732. *
  733. * image_get_kernel() verifies legacy image integrity and returns pointer to
  734. * legacy image header if image verification was completed successfully.
  735. *
  736. * returns:
  737. * pointer to a legacy image header if valid image was found
  738. * otherwise return NULL
  739. */
  740. static image_header_t *image_get_kernel(ulong img_addr, int verify)
  741. {
  742. image_header_t *hdr = (image_header_t *)img_addr;
  743. if (!image_check_magic(hdr)) {
  744. puts("Bad Magic Number\n");
  745. bootstage_error(BOOTSTAGE_ID_CHECK_MAGIC);
  746. return NULL;
  747. }
  748. bootstage_mark(BOOTSTAGE_ID_CHECK_HEADER);
  749. if (!image_check_hcrc(hdr)) {
  750. puts("Bad Header Checksum\n");
  751. bootstage_error(BOOTSTAGE_ID_CHECK_HEADER);
  752. return NULL;
  753. }
  754. bootstage_mark(BOOTSTAGE_ID_CHECK_CHECKSUM);
  755. image_print_contents(hdr);
  756. if (verify) {
  757. puts(" Verifying Checksum ... ");
  758. if (!image_check_dcrc(hdr)) {
  759. printf("Bad Data CRC\n");
  760. bootstage_error(BOOTSTAGE_ID_CHECK_CHECKSUM);
  761. return NULL;
  762. }
  763. puts("OK\n");
  764. }
  765. bootstage_mark(BOOTSTAGE_ID_CHECK_ARCH);
  766. if (!image_check_target_arch(hdr)) {
  767. printf("Unsupported Architecture 0x%x\n", image_get_arch(hdr));
  768. bootstage_error(BOOTSTAGE_ID_CHECK_ARCH);
  769. return NULL;
  770. }
  771. return hdr;
  772. }
  773. /**
  774. * boot_get_kernel - find kernel image
  775. * @os_data: pointer to a ulong variable, will hold os data start address
  776. * @os_len: pointer to a ulong variable, will hold os data length
  777. *
  778. * boot_get_kernel() tries to find a kernel image, verifies its integrity
  779. * and locates kernel data.
  780. *
  781. * returns:
  782. * pointer to image header if valid image was found, plus kernel start
  783. * address and length, otherwise NULL
  784. */
  785. static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
  786. char * const argv[], bootm_headers_t *images, ulong *os_data,
  787. ulong *os_len)
  788. {
  789. image_header_t *hdr;
  790. ulong img_addr;
  791. const void *buf;
  792. #if defined(CONFIG_FIT)
  793. const char *fit_uname_config = NULL;
  794. const char *fit_uname_kernel = NULL;
  795. int os_noffset;
  796. #endif
  797. /* find out kernel image address */
  798. if (argc < 1) {
  799. img_addr = load_addr;
  800. debug("* kernel: default image load address = 0x%08lx\n",
  801. load_addr);
  802. #if defined(CONFIG_FIT)
  803. } else if (fit_parse_conf(argv[0], load_addr, &img_addr,
  804. &fit_uname_config)) {
  805. debug("* kernel: config '%s' from image at 0x%08lx\n",
  806. fit_uname_config, img_addr);
  807. } else if (fit_parse_subimage(argv[0], load_addr, &img_addr,
  808. &fit_uname_kernel)) {
  809. debug("* kernel: subimage '%s' from image at 0x%08lx\n",
  810. fit_uname_kernel, img_addr);
  811. #endif
  812. } else {
  813. img_addr = simple_strtoul(argv[0], NULL, 16);
  814. debug("* kernel: cmdline image address = 0x%08lx\n", img_addr);
  815. }
  816. bootstage_mark(BOOTSTAGE_ID_CHECK_MAGIC);
  817. /* copy from dataflash if needed */
  818. img_addr = genimg_get_image(img_addr);
  819. /* check image type, for FIT images get FIT kernel node */
  820. *os_data = *os_len = 0;
  821. buf = map_sysmem(img_addr, 0);
  822. switch (genimg_get_format(buf)) {
  823. case IMAGE_FORMAT_LEGACY:
  824. printf("## Booting kernel from Legacy Image at %08lx ...\n",
  825. img_addr);
  826. hdr = image_get_kernel(img_addr, images->verify);
  827. if (!hdr)
  828. return NULL;
  829. bootstage_mark(BOOTSTAGE_ID_CHECK_IMAGETYPE);
  830. /* get os_data and os_len */
  831. switch (image_get_type(hdr)) {
  832. case IH_TYPE_KERNEL:
  833. case IH_TYPE_KERNEL_NOLOAD:
  834. *os_data = image_get_data(hdr);
  835. *os_len = image_get_data_size(hdr);
  836. break;
  837. case IH_TYPE_MULTI:
  838. image_multi_getimg(hdr, 0, os_data, os_len);
  839. break;
  840. case IH_TYPE_STANDALONE:
  841. *os_data = image_get_data(hdr);
  842. *os_len = image_get_data_size(hdr);
  843. break;
  844. default:
  845. printf("Wrong Image Type for %s command\n",
  846. cmdtp->name);
  847. bootstage_error(BOOTSTAGE_ID_CHECK_IMAGETYPE);
  848. return NULL;
  849. }
  850. /*
  851. * copy image header to allow for image overwrites during
  852. * kernel decompression.
  853. */
  854. memmove(&images->legacy_hdr_os_copy, hdr,
  855. sizeof(image_header_t));
  856. /* save pointer to image header */
  857. images->legacy_hdr_os = hdr;
  858. images->legacy_hdr_valid = 1;
  859. bootstage_mark(BOOTSTAGE_ID_DECOMP_IMAGE);
  860. break;
  861. #if defined(CONFIG_FIT)
  862. case IMAGE_FORMAT_FIT:
  863. os_noffset = fit_image_load(images, FIT_KERNEL_PROP,
  864. img_addr,
  865. &fit_uname_kernel, &fit_uname_config,
  866. IH_ARCH_DEFAULT, IH_TYPE_KERNEL,
  867. BOOTSTAGE_ID_FIT_KERNEL_START,
  868. FIT_LOAD_IGNORED, os_data, os_len);
  869. if (os_noffset < 0)
  870. return NULL;
  871. images->fit_hdr_os = map_sysmem(img_addr, 0);
  872. images->fit_uname_os = fit_uname_kernel;
  873. images->fit_uname_cfg = fit_uname_config;
  874. images->fit_noffset_os = os_noffset;
  875. break;
  876. #endif
  877. default:
  878. printf("Wrong Image Format for %s command\n", cmdtp->name);
  879. bootstage_error(BOOTSTAGE_ID_FIT_KERNEL_INFO);
  880. return NULL;
  881. }
  882. debug(" kernel data at 0x%08lx, len = 0x%08lx (%ld)\n",
  883. *os_data, *os_len, *os_len);
  884. return buf;
  885. }
  886. #ifdef CONFIG_SYS_LONGHELP
  887. static char bootm_help_text[] =
  888. "[addr [arg ...]]\n - boot application image stored in memory\n"
  889. "\tpassing arguments 'arg ...'; when booting a Linux kernel,\n"
  890. "\t'arg' can be the address of an initrd image\n"
  891. #if defined(CONFIG_OF_LIBFDT)
  892. "\tWhen booting a Linux kernel which requires a flat device-tree\n"
  893. "\ta third argument is required which is the address of the\n"
  894. "\tdevice-tree blob. To boot that kernel without an initrd image,\n"
  895. "\tuse a '-' for the second argument. If you do not pass a third\n"
  896. "\ta bd_info struct will be passed instead\n"
  897. #endif
  898. #if defined(CONFIG_FIT)
  899. "\t\nFor the new multi component uImage format (FIT) addresses\n"
  900. "\tmust be extened to include component or configuration unit name:\n"
  901. "\taddr:<subimg_uname> - direct component image specification\n"
  902. "\taddr#<conf_uname> - configuration specification\n"
  903. "\tUse iminfo command to get the list of existing component\n"
  904. "\timages and configurations.\n"
  905. #endif
  906. "\nSub-commands to do part of the bootm sequence. The sub-commands "
  907. "must be\n"
  908. "issued in the order below (it's ok to not issue all sub-commands):\n"
  909. "\tstart [addr [arg ...]]\n"
  910. "\tloados - load OS image\n"
  911. #if defined(CONFIG_SYS_BOOT_RAMDISK_HIGH)
  912. "\tramdisk - relocate initrd, set env initrd_start/initrd_end\n"
  913. #endif
  914. #if defined(CONFIG_OF_LIBFDT)
  915. "\tfdt - relocate flat device tree\n"
  916. #endif
  917. "\tcmdline - OS specific command line processing/setup\n"
  918. "\tbdt - OS specific bd_t processing\n"
  919. "\tprep - OS specific prep before relocation or go\n"
  920. "\tgo - start OS";
  921. #endif
  922. U_BOOT_CMD(
  923. bootm, CONFIG_SYS_MAXARGS, 1, do_bootm,
  924. "boot application image from memory", bootm_help_text
  925. );
  926. /*******************************************************************/
  927. /* bootd - boot default image */
  928. /*******************************************************************/
  929. #if defined(CONFIG_CMD_BOOTD)
  930. int do_bootd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  931. {
  932. int rcode = 0;
  933. if (run_command(getenv("bootcmd"), flag) < 0)
  934. rcode = 1;
  935. return rcode;
  936. }
  937. U_BOOT_CMD(
  938. boot, 1, 1, do_bootd,
  939. "boot default, i.e., run 'bootcmd'",
  940. ""
  941. );
  942. /* keep old command name "bootd" for backward compatibility */
  943. U_BOOT_CMD(
  944. bootd, 1, 1, do_bootd,
  945. "boot default, i.e., run 'bootcmd'",
  946. ""
  947. );
  948. #endif
  949. /*******************************************************************/
  950. /* iminfo - print header info for a requested image */
  951. /*******************************************************************/
  952. #if defined(CONFIG_CMD_IMI)
  953. static int do_iminfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  954. {
  955. int arg;
  956. ulong addr;
  957. int rcode = 0;
  958. if (argc < 2) {
  959. return image_info(load_addr);
  960. }
  961. for (arg = 1; arg < argc; ++arg) {
  962. addr = simple_strtoul(argv[arg], NULL, 16);
  963. if (image_info(addr) != 0)
  964. rcode = 1;
  965. }
  966. return rcode;
  967. }
  968. static int image_info(ulong addr)
  969. {
  970. void *hdr = (void *)addr;
  971. printf("\n## Checking Image at %08lx ...\n", addr);
  972. switch (genimg_get_format(hdr)) {
  973. case IMAGE_FORMAT_LEGACY:
  974. puts(" Legacy image found\n");
  975. if (!image_check_magic(hdr)) {
  976. puts(" Bad Magic Number\n");
  977. return 1;
  978. }
  979. if (!image_check_hcrc(hdr)) {
  980. puts(" Bad Header Checksum\n");
  981. return 1;
  982. }
  983. image_print_contents(hdr);
  984. puts(" Verifying Checksum ... ");
  985. if (!image_check_dcrc(hdr)) {
  986. puts(" Bad Data CRC\n");
  987. return 1;
  988. }
  989. puts("OK\n");
  990. return 0;
  991. #if defined(CONFIG_FIT)
  992. case IMAGE_FORMAT_FIT:
  993. puts(" FIT image found\n");
  994. if (!fit_check_format(hdr)) {
  995. puts("Bad FIT image format!\n");
  996. return 1;
  997. }
  998. fit_print_contents(hdr);
  999. if (!fit_all_image_verify(hdr)) {
  1000. puts("Bad hash in FIT image!\n");
  1001. return 1;
  1002. }
  1003. return 0;
  1004. #endif
  1005. default:
  1006. puts("Unknown image format!\n");
  1007. break;
  1008. }
  1009. return 1;
  1010. }
  1011. U_BOOT_CMD(
  1012. iminfo, CONFIG_SYS_MAXARGS, 1, do_iminfo,
  1013. "print header information for application image",
  1014. "addr [addr ...]\n"
  1015. " - print header information for application image starting at\n"
  1016. " address 'addr' in memory; this includes verification of the\n"
  1017. " image contents (magic number, header and payload checksums)"
  1018. );
  1019. #endif
  1020. /*******************************************************************/
  1021. /* imls - list all images found in flash */
  1022. /*******************************************************************/
  1023. #if defined(CONFIG_CMD_IMLS)
  1024. static int do_imls_nor(void)
  1025. {
  1026. flash_info_t *info;
  1027. int i, j;
  1028. void *hdr;
  1029. for (i = 0, info = &flash_info[0];
  1030. i < CONFIG_SYS_MAX_FLASH_BANKS; ++i, ++info) {
  1031. if (info->flash_id == FLASH_UNKNOWN)
  1032. goto next_bank;
  1033. for (j = 0; j < info->sector_count; ++j) {
  1034. hdr = (void *)info->start[j];
  1035. if (!hdr)
  1036. goto next_sector;
  1037. switch (genimg_get_format(hdr)) {
  1038. case IMAGE_FORMAT_LEGACY:
  1039. if (!image_check_hcrc(hdr))
  1040. goto next_sector;
  1041. printf("Legacy Image at %08lX:\n", (ulong)hdr);
  1042. image_print_contents(hdr);
  1043. puts(" Verifying Checksum ... ");
  1044. if (!image_check_dcrc(hdr)) {
  1045. puts("Bad Data CRC\n");
  1046. } else {
  1047. puts("OK\n");
  1048. }
  1049. break;
  1050. #if defined(CONFIG_FIT)
  1051. case IMAGE_FORMAT_FIT:
  1052. if (!fit_check_format(hdr))
  1053. goto next_sector;
  1054. printf("FIT Image at %08lX:\n", (ulong)hdr);
  1055. fit_print_contents(hdr);
  1056. break;
  1057. #endif
  1058. default:
  1059. goto next_sector;
  1060. }
  1061. next_sector: ;
  1062. }
  1063. next_bank: ;
  1064. }
  1065. return 0;
  1066. }
  1067. #endif
  1068. #if defined(CONFIG_CMD_IMLS_NAND)
  1069. static int nand_imls_legacyimage(nand_info_t *nand, int nand_dev, loff_t off,
  1070. size_t len)
  1071. {
  1072. void *imgdata;
  1073. int ret;
  1074. imgdata = malloc(len);
  1075. if (!imgdata) {
  1076. printf("May be a Legacy Image at NAND device %d offset %08llX:\n",
  1077. nand_dev, off);
  1078. printf(" Low memory(cannot allocate memory for image)\n");
  1079. return -ENOMEM;
  1080. }
  1081. ret = nand_read_skip_bad(nand, off, &len,
  1082. imgdata);
  1083. if (ret < 0 && ret != -EUCLEAN) {
  1084. free(imgdata);
  1085. return ret;
  1086. }
  1087. if (!image_check_hcrc(imgdata)) {
  1088. free(imgdata);
  1089. return 0;
  1090. }
  1091. printf("Legacy Image at NAND device %d offset %08llX:\n",
  1092. nand_dev, off);
  1093. image_print_contents(imgdata);
  1094. puts(" Verifying Checksum ... ");
  1095. if (!image_check_dcrc(imgdata))
  1096. puts("Bad Data CRC\n");
  1097. else
  1098. puts("OK\n");
  1099. free(imgdata);
  1100. return 0;
  1101. }
  1102. static int nand_imls_fitimage(nand_info_t *nand, int nand_dev, loff_t off,
  1103. size_t len)
  1104. {
  1105. void *imgdata;
  1106. int ret;
  1107. imgdata = malloc(len);
  1108. if (!imgdata) {
  1109. printf("May be a FIT Image at NAND device %d offset %08llX:\n",
  1110. nand_dev, off);
  1111. printf(" Low memory(cannot allocate memory for image)\n");
  1112. return -ENOMEM;
  1113. }
  1114. ret = nand_read_skip_bad(nand, off, &len,
  1115. imgdata);
  1116. if (ret < 0 && ret != -EUCLEAN) {
  1117. free(imgdata);
  1118. return ret;
  1119. }
  1120. if (!fit_check_format(imgdata)) {
  1121. free(imgdata);
  1122. return 0;
  1123. }
  1124. printf("FIT Image at NAND device %d offset %08llX:\n", nand_dev, off);
  1125. fit_print_contents(imgdata);
  1126. free(imgdata);
  1127. return 0;
  1128. }
  1129. static int do_imls_nand(void)
  1130. {
  1131. nand_info_t *nand;
  1132. int nand_dev = nand_curr_device;
  1133. size_t len;
  1134. loff_t off;
  1135. u32 buffer[16];
  1136. if (nand_dev < 0 || nand_dev >= CONFIG_SYS_MAX_NAND_DEVICE) {
  1137. puts("\nNo NAND devices available\n");
  1138. return -ENODEV;
  1139. }
  1140. printf("\n");
  1141. for (nand_dev = 0; nand_dev < CONFIG_SYS_MAX_NAND_DEVICE; nand_dev++) {
  1142. nand = &nand_info[nand_dev];
  1143. if (!nand->name || !nand->size)
  1144. continue;
  1145. for (off = 0; off < nand->size; off += nand->erasesize) {
  1146. const image_header_t *header;
  1147. int ret;
  1148. if (nand_block_isbad(nand, off))
  1149. continue;
  1150. len = sizeof(buffer);
  1151. ret = nand_read(nand, off, &len, (u8 *)buffer);
  1152. if (ret < 0 && ret != -EUCLEAN) {
  1153. printf("NAND read error %d at offset %08llX\n",
  1154. ret, off);
  1155. continue;
  1156. }
  1157. switch (genimg_get_format(buffer)) {
  1158. case IMAGE_FORMAT_LEGACY:
  1159. header = (const image_header_t *)buffer;
  1160. len = image_get_image_size(header);
  1161. nand_imls_legacyimage(nand, nand_dev, off, len);
  1162. break;
  1163. #if defined(CONFIG_FIT)
  1164. case IMAGE_FORMAT_FIT:
  1165. len = fit_get_size(buffer);
  1166. nand_imls_fitimage(nand, nand_dev, off, len);
  1167. break;
  1168. #endif
  1169. }
  1170. }
  1171. }
  1172. return 0;
  1173. }
  1174. #endif
  1175. #if defined(CONFIG_CMD_IMLS) || defined(CONFIG_CMD_IMLS_NAND)
  1176. static int do_imls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  1177. {
  1178. int ret_nor = 0, ret_nand = 0;
  1179. #if defined(CONFIG_CMD_IMLS)
  1180. ret_nor = do_imls_nor();
  1181. #endif
  1182. #if defined(CONFIG_CMD_IMLS_NAND)
  1183. ret_nand = do_imls_nand();
  1184. #endif
  1185. if (ret_nor)
  1186. return ret_nor;
  1187. if (ret_nand)
  1188. return ret_nand;
  1189. return (0);
  1190. }
  1191. U_BOOT_CMD(
  1192. imls, 1, 1, do_imls,
  1193. "list all images found in flash",
  1194. "\n"
  1195. " - Prints information about all images found at sector/block\n"
  1196. " boundaries in nor/nand flash."
  1197. );
  1198. #endif
  1199. /*******************************************************************/
  1200. /* helper routines */
  1201. /*******************************************************************/
  1202. #if defined(CONFIG_SILENT_CONSOLE) && !defined(CONFIG_SILENT_U_BOOT_ONLY)
  1203. #define CONSOLE_ARG "console="
  1204. #define CONSOLE_ARG_LEN (sizeof(CONSOLE_ARG) - 1)
  1205. static void fixup_silent_linux(void)
  1206. {
  1207. char *buf;
  1208. const char *env_val;
  1209. char *cmdline = getenv("bootargs");
  1210. /* Only fix cmdline when requested */
  1211. if (!(gd->flags & GD_FLG_SILENT))
  1212. return;
  1213. debug("before silent fix-up: %s\n", cmdline);
  1214. if (cmdline && (cmdline[0] != '\0')) {
  1215. char *start = strstr(cmdline, CONSOLE_ARG);
  1216. /* Allocate space for maximum possible new command line */
  1217. buf = malloc(strlen(cmdline) + 1 + CONSOLE_ARG_LEN + 1);
  1218. if (!buf) {
  1219. debug("%s: out of memory\n", __func__);
  1220. return;
  1221. }
  1222. if (start) {
  1223. char *end = strchr(start, ' ');
  1224. int num_start_bytes = start - cmdline + CONSOLE_ARG_LEN;
  1225. strncpy(buf, cmdline, num_start_bytes);
  1226. if (end)
  1227. strcpy(buf + num_start_bytes, end);
  1228. else
  1229. buf[num_start_bytes] = '\0';
  1230. } else {
  1231. sprintf(buf, "%s %s", cmdline, CONSOLE_ARG);
  1232. }
  1233. env_val = buf;
  1234. } else {
  1235. buf = NULL;
  1236. env_val = CONSOLE_ARG;
  1237. }
  1238. setenv("bootargs", env_val);
  1239. debug("after silent fix-up: %s\n", env_val);
  1240. free(buf);
  1241. }
  1242. #endif /* CONFIG_SILENT_CONSOLE */
  1243. #if defined(CONFIG_BOOTM_NETBSD) || defined(CONFIG_BOOTM_PLAN9)
  1244. static void copy_args(char *dest, int argc, char * const argv[], char delim)
  1245. {
  1246. int i;
  1247. for (i = 0; i < argc; i++) {
  1248. if (i > 0)
  1249. *dest++ = delim;
  1250. strcpy(dest, argv[i]);
  1251. dest += strlen(argv[i]);
  1252. }
  1253. }
  1254. #endif
  1255. /*******************************************************************/
  1256. /* OS booting routines */
  1257. /*******************************************************************/
  1258. #ifdef CONFIG_BOOTM_NETBSD
  1259. static int do_bootm_netbsd(int flag, int argc, char * const argv[],
  1260. bootm_headers_t *images)
  1261. {
  1262. void (*loader)(bd_t *, image_header_t *, char *, char *);
  1263. image_header_t *os_hdr, *hdr;
  1264. ulong kernel_data, kernel_len;
  1265. char *consdev;
  1266. char *cmdline;
  1267. if (flag & BOOTM_STATE_OS_PREP)
  1268. return 0;
  1269. if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
  1270. return 1;
  1271. #if defined(CONFIG_FIT)
  1272. if (!images->legacy_hdr_valid) {
  1273. fit_unsupported_reset("NetBSD");
  1274. return 1;
  1275. }
  1276. #endif
  1277. hdr = images->legacy_hdr_os;
  1278. /*
  1279. * Booting a (NetBSD) kernel image
  1280. *
  1281. * This process is pretty similar to a standalone application:
  1282. * The (first part of an multi-) image must be a stage-2 loader,
  1283. * which in turn is responsible for loading & invoking the actual
  1284. * kernel. The only differences are the parameters being passed:
  1285. * besides the board info strucure, the loader expects a command
  1286. * line, the name of the console device, and (optionally) the
  1287. * address of the original image header.
  1288. */
  1289. os_hdr = NULL;
  1290. if (image_check_type(&images->legacy_hdr_os_copy, IH_TYPE_MULTI)) {
  1291. image_multi_getimg(hdr, 1, &kernel_data, &kernel_len);
  1292. if (kernel_len)
  1293. os_hdr = hdr;
  1294. }
  1295. consdev = "";
  1296. #if defined(CONFIG_8xx_CONS_SMC1)
  1297. consdev = "smc1";
  1298. #elif defined(CONFIG_8xx_CONS_SMC2)
  1299. consdev = "smc2";
  1300. #elif defined(CONFIG_8xx_CONS_SCC2)
  1301. consdev = "scc2";
  1302. #elif defined(CONFIG_8xx_CONS_SCC3)
  1303. consdev = "scc3";
  1304. #endif
  1305. if (argc > 0) {
  1306. ulong len;
  1307. int i;
  1308. for (i = 0, len = 0; i < argc; i += 1)
  1309. len += strlen(argv[i]) + 1;
  1310. cmdline = malloc(len);
  1311. copy_args(cmdline, argc, argv, ' ');
  1312. } else if ((cmdline = getenv("bootargs")) == NULL) {
  1313. cmdline = "";
  1314. }
  1315. loader = (void (*)(bd_t *, image_header_t *, char *, char *))images->ep;
  1316. printf("## Transferring control to NetBSD stage-2 loader "
  1317. "(at address %08lx) ...\n",
  1318. (ulong)loader);
  1319. bootstage_mark(BOOTSTAGE_ID_RUN_OS);
  1320. /*
  1321. * NetBSD Stage-2 Loader Parameters:
  1322. * r3: ptr to board info data
  1323. * r4: image address
  1324. * r5: console device
  1325. * r6: boot args string
  1326. */
  1327. (*loader)(gd->bd, os_hdr, consdev, cmdline);
  1328. return 1;
  1329. }
  1330. #endif /* CONFIG_BOOTM_NETBSD*/
  1331. #ifdef CONFIG_LYNXKDI
  1332. static int do_bootm_lynxkdi(int flag, int argc, char * const argv[],
  1333. bootm_headers_t *images)
  1334. {
  1335. image_header_t *hdr = &images->legacy_hdr_os_copy;
  1336. if (flag & BOOTM_STATE_OS_PREP)
  1337. return 0;
  1338. if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
  1339. return 1;
  1340. #if defined(CONFIG_FIT)
  1341. if (!images->legacy_hdr_valid) {
  1342. fit_unsupported_reset("Lynx");
  1343. return 1;
  1344. }
  1345. #endif
  1346. lynxkdi_boot((image_header_t *)hdr);
  1347. return 1;
  1348. }
  1349. #endif /* CONFIG_LYNXKDI */
  1350. #ifdef CONFIG_BOOTM_RTEMS
  1351. static int do_bootm_rtems(int flag, int argc, char * const argv[],
  1352. bootm_headers_t *images)
  1353. {
  1354. void (*entry_point)(bd_t *);
  1355. if (flag & BOOTM_STATE_OS_PREP)
  1356. return 0;
  1357. if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
  1358. return 1;
  1359. #if defined(CONFIG_FIT)
  1360. if (!images->legacy_hdr_valid) {
  1361. fit_unsupported_reset("RTEMS");
  1362. return 1;
  1363. }
  1364. #endif
  1365. entry_point = (void (*)(bd_t *))images->ep;
  1366. printf("## Transferring control to RTEMS (at address %08lx) ...\n",
  1367. (ulong)entry_point);
  1368. bootstage_mark(BOOTSTAGE_ID_RUN_OS);
  1369. /*
  1370. * RTEMS Parameters:
  1371. * r3: ptr to board info data
  1372. */
  1373. (*entry_point)(gd->bd);
  1374. return 1;
  1375. }
  1376. #endif /* CONFIG_BOOTM_RTEMS */
  1377. #if defined(CONFIG_BOOTM_OSE)
  1378. static int do_bootm_ose(int flag, int argc, char * const argv[],
  1379. bootm_headers_t *images)
  1380. {
  1381. void (*entry_point)(void);
  1382. if (flag & BOOTM_STATE_OS_PREP)
  1383. return 0;
  1384. if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
  1385. return 1;
  1386. #if defined(CONFIG_FIT)
  1387. if (!images->legacy_hdr_valid) {
  1388. fit_unsupported_reset("OSE");
  1389. return 1;
  1390. }
  1391. #endif
  1392. entry_point = (void (*)(void))images->ep;
  1393. printf("## Transferring control to OSE (at address %08lx) ...\n",
  1394. (ulong)entry_point);
  1395. bootstage_mark(BOOTSTAGE_ID_RUN_OS);
  1396. /*
  1397. * OSE Parameters:
  1398. * None
  1399. */
  1400. (*entry_point)();
  1401. return 1;
  1402. }
  1403. #endif /* CONFIG_BOOTM_OSE */
  1404. #if defined(CONFIG_BOOTM_PLAN9)
  1405. static int do_bootm_plan9(int flag, int argc, char * const argv[],
  1406. bootm_headers_t *images)
  1407. {
  1408. void (*entry_point)(void);
  1409. char *s;
  1410. if (flag & BOOTM_STATE_OS_PREP)
  1411. return 0;
  1412. if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
  1413. return 1;
  1414. #if defined(CONFIG_FIT)
  1415. if (!images->legacy_hdr_valid) {
  1416. fit_unsupported_reset("Plan 9");
  1417. return 1;
  1418. }
  1419. #endif
  1420. /* See README.plan9 */
  1421. s = getenv("confaddr");
  1422. if (s != NULL) {
  1423. char *confaddr = (char *)simple_strtoul(s, NULL, 16);
  1424. if (argc > 0) {
  1425. copy_args(confaddr, argc, argv, '\n');
  1426. } else {
  1427. s = getenv("bootargs");
  1428. if (s != NULL)
  1429. strcpy(confaddr, s);
  1430. }
  1431. }
  1432. entry_point = (void (*)(void))images->ep;
  1433. printf("## Transferring control to Plan 9 (at address %08lx) ...\n",
  1434. (ulong)entry_point);
  1435. bootstage_mark(BOOTSTAGE_ID_RUN_OS);
  1436. /*
  1437. * Plan 9 Parameters:
  1438. * None
  1439. */
  1440. (*entry_point)();
  1441. return 1;
  1442. }
  1443. #endif /* CONFIG_BOOTM_PLAN9 */
  1444. #if defined(CONFIG_CMD_ELF)
  1445. static int do_bootm_vxworks(int flag, int argc, char * const argv[],
  1446. bootm_headers_t *images)
  1447. {
  1448. char str[80];
  1449. if (flag & BOOTM_STATE_OS_PREP)
  1450. return 0;
  1451. if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
  1452. return 1;
  1453. #if defined(CONFIG_FIT)
  1454. if (!images->legacy_hdr_valid) {
  1455. fit_unsupported_reset("VxWorks");
  1456. return 1;
  1457. }
  1458. #endif
  1459. sprintf(str, "%lx", images->ep); /* write entry-point into string */
  1460. setenv("loadaddr", str);
  1461. do_bootvx(NULL, 0, 0, NULL);
  1462. return 1;
  1463. }
  1464. static int do_bootm_qnxelf(int flag, int argc, char * const argv[],
  1465. bootm_headers_t *images)
  1466. {
  1467. char *local_args[2];
  1468. char str[16];
  1469. if (flag & BOOTM_STATE_OS_PREP)
  1470. return 0;
  1471. if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
  1472. return 1;
  1473. #if defined(CONFIG_FIT)
  1474. if (!images->legacy_hdr_valid) {
  1475. fit_unsupported_reset("QNX");
  1476. return 1;
  1477. }
  1478. #endif
  1479. sprintf(str, "%lx", images->ep); /* write entry-point into string */
  1480. local_args[0] = argv[0];
  1481. local_args[1] = str; /* and provide it via the arguments */
  1482. do_bootelf(NULL, 0, 2, local_args);
  1483. return 1;
  1484. }
  1485. #endif
  1486. #ifdef CONFIG_INTEGRITY
  1487. static int do_bootm_integrity(int flag, int argc, char * const argv[],
  1488. bootm_headers_t *images)
  1489. {
  1490. void (*entry_point)(void);
  1491. if (flag & BOOTM_STATE_OS_PREP)
  1492. return 0;
  1493. if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
  1494. return 1;
  1495. #if defined(CONFIG_FIT)
  1496. if (!images->legacy_hdr_valid) {
  1497. fit_unsupported_reset("INTEGRITY");
  1498. return 1;
  1499. }
  1500. #endif
  1501. entry_point = (void (*)(void))images->ep;
  1502. printf("## Transferring control to INTEGRITY (at address %08lx) ...\n",
  1503. (ulong)entry_point);
  1504. bootstage_mark(BOOTSTAGE_ID_RUN_OS);
  1505. /*
  1506. * INTEGRITY Parameters:
  1507. * None
  1508. */
  1509. (*entry_point)();
  1510. return 1;
  1511. }
  1512. #endif
  1513. #ifdef CONFIG_CMD_BOOTZ
  1514. int __weak bootz_setup(ulong image, ulong *start, ulong *end)
  1515. {
  1516. /* Please define bootz_setup() for your platform */
  1517. puts("Your platform's zImage format isn't supported yet!\n");
  1518. return -1;
  1519. }
  1520. /*
  1521. * zImage booting support
  1522. */
  1523. static int bootz_start(cmd_tbl_t *cmdtp, int flag, int argc,
  1524. char * const argv[], bootm_headers_t *images)
  1525. {
  1526. int ret;
  1527. ulong zi_start, zi_end;
  1528. ret = do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START,
  1529. images, 1);
  1530. /* Setup Linux kernel zImage entry point */
  1531. if (!argc) {
  1532. images->ep = load_addr;
  1533. debug("* kernel: default image load address = 0x%08lx\n",
  1534. load_addr);
  1535. } else {
  1536. images->ep = simple_strtoul(argv[0], NULL, 16);
  1537. debug("* kernel: cmdline image address = 0x%08lx\n",
  1538. images->ep);
  1539. }
  1540. ret = bootz_setup(images->ep, &zi_start, &zi_end);
  1541. if (ret != 0)
  1542. return 1;
  1543. lmb_reserve(&images->lmb, images->ep, zi_end - zi_start);
  1544. /*
  1545. * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not
  1546. * have a header that provide this informaiton.
  1547. */
  1548. if (bootm_find_ramdisk(flag, argc, argv))
  1549. return 1;
  1550. #if defined(CONFIG_OF_LIBFDT)
  1551. if (bootm_find_fdt(flag, argc, argv))
  1552. return 1;
  1553. #endif
  1554. return 0;
  1555. }
  1556. int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  1557. {
  1558. int ret;
  1559. /* Consume 'bootz' */
  1560. argc--; argv++;
  1561. if (bootz_start(cmdtp, flag, argc, argv, &images))
  1562. return 1;
  1563. /*
  1564. * We are doing the BOOTM_STATE_LOADOS state ourselves, so must
  1565. * disable interrupts ourselves
  1566. */
  1567. bootm_disable_interrupts();
  1568. images.os.os = IH_OS_LINUX;
  1569. ret = do_bootm_states(cmdtp, flag, argc, argv,
  1570. BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
  1571. BOOTM_STATE_OS_GO,
  1572. &images, 1);
  1573. return ret;
  1574. }
  1575. #ifdef CONFIG_SYS_LONGHELP
  1576. static char bootz_help_text[] =
  1577. "[addr [initrd[:size]] [fdt]]\n"
  1578. " - boot Linux zImage stored in memory\n"
  1579. "\tThe argument 'initrd' is optional and specifies the address\n"
  1580. "\tof the initrd in memory. The optional argument ':size' allows\n"
  1581. "\tspecifying the size of RAW initrd.\n"
  1582. #if defined(CONFIG_OF_LIBFDT)
  1583. "\tWhen booting a Linux kernel which requires a flat device-tree\n"
  1584. "\ta third argument is required which is the address of the\n"
  1585. "\tdevice-tree blob. To boot that kernel without an initrd image,\n"
  1586. "\tuse a '-' for the second argument. If you do not pass a third\n"
  1587. "\ta bd_info struct will be passed instead\n"
  1588. #endif
  1589. "";
  1590. #endif
  1591. U_BOOT_CMD(
  1592. bootz, CONFIG_SYS_MAXARGS, 1, do_bootz,
  1593. "boot Linux zImage image from memory", bootz_help_text
  1594. );
  1595. #endif /* CONFIG_CMD_BOOTZ */