spl_fit.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2016 Google, Inc
  4. * Written by Simon Glass <sjg@chromium.org>
  5. */
  6. #include <common.h>
  7. #include <errno.h>
  8. #include <board.h>
  9. #include <fpga.h>
  10. #include <gzip.h>
  11. #include <image.h>
  12. #include <log.h>
  13. #include <malloc.h>
  14. #include <spl.h>
  15. #include <asm/cache.h>
  16. #include <linux/libfdt.h>
  17. DECLARE_GLOBAL_DATA_PTR;
  18. #ifndef CONFIG_SPL_LOAD_FIT_APPLY_OVERLAY_BUF_SZ
  19. #define CONFIG_SPL_LOAD_FIT_APPLY_OVERLAY_BUF_SZ (64 * 1024)
  20. #endif
  21. #ifndef CONFIG_SYS_BOOTM_LEN
  22. #define CONFIG_SYS_BOOTM_LEN (64 << 20)
  23. #endif
  24. __weak void board_spl_fit_post_load(ulong load_addr, size_t length)
  25. {
  26. }
  27. __weak ulong board_spl_fit_size_align(ulong size)
  28. {
  29. return size;
  30. }
  31. static int find_node_from_desc(const void *fit, int node, const char *str)
  32. {
  33. int child;
  34. if (node < 0)
  35. return -EINVAL;
  36. /* iterate the FIT nodes and find a matching description */
  37. for (child = fdt_first_subnode(fit, node); child >= 0;
  38. child = fdt_next_subnode(fit, child)) {
  39. int len;
  40. const char *desc = fdt_getprop(fit, child, "description", &len);
  41. if (!desc)
  42. continue;
  43. if (!strcmp(desc, str))
  44. return child;
  45. }
  46. return -ENOENT;
  47. }
  48. /**
  49. * spl_fit_get_image_name(): By using the matching configuration subnode,
  50. * retrieve the name of an image, specified by a property name and an index
  51. * into that.
  52. * @fit: Pointer to the FDT blob.
  53. * @images: Offset of the /images subnode.
  54. * @type: Name of the property within the configuration subnode.
  55. * @index: Index into the list of strings in this property.
  56. * @outname: Name of the image
  57. *
  58. * Return: 0 on success, or a negative error number
  59. */
  60. static int spl_fit_get_image_name(const void *fit, int images,
  61. const char *type, int index,
  62. const char **outname)
  63. {
  64. struct udevice *board;
  65. const char *name, *str;
  66. __maybe_unused int node;
  67. int conf_node;
  68. int len, i;
  69. bool found = true;
  70. conf_node = fit_find_config_node(fit);
  71. if (conf_node < 0) {
  72. #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
  73. printf("No matching DT out of these options:\n");
  74. for (node = fdt_first_subnode(fit, conf_node);
  75. node >= 0;
  76. node = fdt_next_subnode(fit, node)) {
  77. name = fdt_getprop(fit, node, "description", &len);
  78. printf(" %s\n", name);
  79. }
  80. #endif
  81. return conf_node;
  82. }
  83. name = fdt_getprop(fit, conf_node, type, &len);
  84. if (!name) {
  85. debug("cannot find property '%s': %d\n", type, len);
  86. return -EINVAL;
  87. }
  88. str = name;
  89. for (i = 0; i < index; i++) {
  90. str = strchr(str, '\0') + 1;
  91. if (!str || (str - name >= len)) {
  92. found = false;
  93. break;
  94. }
  95. }
  96. if (!found && !board_get(&board)) {
  97. int rc;
  98. /*
  99. * no string in the property for this index. Check if the board
  100. * level code can supply one.
  101. */
  102. rc = board_get_fit_loadable(board, index - i - 1, type, &str);
  103. if (rc && rc != -ENOENT)
  104. return rc;
  105. if (!rc) {
  106. /*
  107. * The board provided a name for a loadable.
  108. * Try to match it against the description properties
  109. * first. If no matching node is found, use it as a
  110. * node name.
  111. */
  112. int node;
  113. int images = fdt_path_offset(fit, FIT_IMAGES_PATH);
  114. node = find_node_from_desc(fit, images, str);
  115. if (node > 0)
  116. str = fdt_get_name(fit, node, NULL);
  117. found = true;
  118. }
  119. }
  120. if (!found) {
  121. debug("no string for index %d\n", index);
  122. return -E2BIG;
  123. }
  124. *outname = str;
  125. return 0;
  126. }
  127. /**
  128. * spl_fit_get_image_node(): By using the matching configuration subnode,
  129. * retrieve the name of an image, specified by a property name and an index
  130. * into that.
  131. * @fit: Pointer to the FDT blob.
  132. * @images: Offset of the /images subnode.
  133. * @type: Name of the property within the configuration subnode.
  134. * @index: Index into the list of strings in this property.
  135. *
  136. * Return: the node offset of the respective image node or a negative
  137. * error number.
  138. */
  139. static int spl_fit_get_image_node(const void *fit, int images,
  140. const char *type, int index)
  141. {
  142. const char *str;
  143. int err;
  144. int node;
  145. err = spl_fit_get_image_name(fit, images, type, index, &str);
  146. if (err)
  147. return err;
  148. debug("%s: '%s'\n", type, str);
  149. node = fdt_subnode_offset(fit, images, str);
  150. if (node < 0) {
  151. pr_err("cannot find image node '%s': %d\n", str, node);
  152. return -EINVAL;
  153. }
  154. return node;
  155. }
  156. static int get_aligned_image_offset(struct spl_load_info *info, int offset)
  157. {
  158. /*
  159. * If it is a FS read, get the first address before offset which is
  160. * aligned to ARCH_DMA_MINALIGN. If it is raw read return the
  161. * block number to which offset belongs.
  162. */
  163. if (info->filename)
  164. return offset & ~(ARCH_DMA_MINALIGN - 1);
  165. return offset / info->bl_len;
  166. }
  167. static int get_aligned_image_overhead(struct spl_load_info *info, int offset)
  168. {
  169. /*
  170. * If it is a FS read, get the difference between the offset and
  171. * the first address before offset which is aligned to
  172. * ARCH_DMA_MINALIGN. If it is raw read return the offset within the
  173. * block.
  174. */
  175. if (info->filename)
  176. return offset & (ARCH_DMA_MINALIGN - 1);
  177. return offset % info->bl_len;
  178. }
  179. static int get_aligned_image_size(struct spl_load_info *info, int data_size,
  180. int offset)
  181. {
  182. data_size = data_size + get_aligned_image_overhead(info, offset);
  183. if (info->filename)
  184. return data_size;
  185. return (data_size + info->bl_len - 1) / info->bl_len;
  186. }
  187. /**
  188. * spl_load_fit_image(): load the image described in a certain FIT node
  189. * @info: points to information about the device to load data from
  190. * @sector: the start sector of the FIT image on the device
  191. * @fit: points to the flattened device tree blob describing the FIT
  192. * image
  193. * @base_offset: the beginning of the data area containing the actual
  194. * image data, relative to the beginning of the FIT
  195. * @node: offset of the DT node describing the image to load (relative
  196. * to @fit)
  197. * @image_info: will be filled with information about the loaded image
  198. * If the FIT node does not contain a "load" (address) property,
  199. * the image gets loaded to the address pointed to by the
  200. * load_addr member in this struct.
  201. *
  202. * Return: 0 on success or a negative error number.
  203. */
  204. static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
  205. void *fit, ulong base_offset, int node,
  206. struct spl_image_info *image_info)
  207. {
  208. int offset;
  209. size_t length;
  210. int len;
  211. ulong size;
  212. ulong load_addr, load_ptr;
  213. void *src;
  214. ulong overhead;
  215. int nr_sectors;
  216. int align_len = ARCH_DMA_MINALIGN - 1;
  217. uint8_t image_comp = -1, type = -1;
  218. const void *data;
  219. bool external_data = false;
  220. if (IS_ENABLED(CONFIG_SPL_FPGA) ||
  221. (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_GZIP))) {
  222. if (fit_image_get_type(fit, node, &type))
  223. puts("Cannot get image type.\n");
  224. else
  225. debug("%s ", genimg_get_type_name(type));
  226. }
  227. if (IS_ENABLED(CONFIG_SPL_GZIP)) {
  228. fit_image_get_comp(fit, node, &image_comp);
  229. debug("%s ", genimg_get_comp_name(image_comp));
  230. }
  231. if (fit_image_get_load(fit, node, &load_addr))
  232. load_addr = image_info->load_addr;
  233. if (!fit_image_get_data_position(fit, node, &offset)) {
  234. external_data = true;
  235. } else if (!fit_image_get_data_offset(fit, node, &offset)) {
  236. offset += base_offset;
  237. external_data = true;
  238. }
  239. if (external_data) {
  240. /* External data */
  241. if (fit_image_get_data_size(fit, node, &len))
  242. return -ENOENT;
  243. load_ptr = (load_addr + align_len) & ~align_len;
  244. length = len;
  245. overhead = get_aligned_image_overhead(info, offset);
  246. nr_sectors = get_aligned_image_size(info, length, offset);
  247. if (info->read(info,
  248. sector + get_aligned_image_offset(info, offset),
  249. nr_sectors, (void *)load_ptr) != nr_sectors)
  250. return -EIO;
  251. debug("External data: dst=%lx, offset=%x, size=%lx\n",
  252. load_ptr, offset, (unsigned long)length);
  253. src = (void *)load_ptr + overhead;
  254. } else {
  255. /* Embedded data */
  256. if (fit_image_get_data(fit, node, &data, &length)) {
  257. puts("Cannot get image data/size\n");
  258. return -ENOENT;
  259. }
  260. debug("Embedded data: dst=%lx, size=%lx\n", load_addr,
  261. (unsigned long)length);
  262. src = (void *)data;
  263. }
  264. #ifdef CONFIG_SPL_FIT_SIGNATURE
  265. printf("## Checking hash(es) for Image %s ... ",
  266. fit_get_name(fit, node, NULL));
  267. if (!fit_image_verify_with_data(fit, node,
  268. src, length))
  269. return -EPERM;
  270. puts("OK\n");
  271. #endif
  272. #ifdef CONFIG_SPL_FIT_IMAGE_POST_PROCESS
  273. board_fit_image_post_process(&src, &length);
  274. #endif
  275. if (IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP) {
  276. size = length;
  277. if (gunzip((void *)load_addr, CONFIG_SYS_BOOTM_LEN,
  278. src, &size)) {
  279. puts("Uncompressing error\n");
  280. return -EIO;
  281. }
  282. length = size;
  283. } else {
  284. memcpy((void *)load_addr, src, length);
  285. }
  286. if (image_info) {
  287. ulong entry_point;
  288. image_info->load_addr = load_addr;
  289. image_info->size = length;
  290. if (!fit_image_get_entry(fit, node, &entry_point))
  291. image_info->entry_point = entry_point;
  292. else
  293. image_info->entry_point = FDT_ERROR;
  294. }
  295. return 0;
  296. }
  297. static int spl_fit_append_fdt(struct spl_image_info *spl_image,
  298. struct spl_load_info *info, ulong sector,
  299. void *fit, int images, ulong base_offset)
  300. {
  301. struct spl_image_info image_info;
  302. int node, ret = 0, index = 0;
  303. /*
  304. * Use the address following the image as target address for the
  305. * device tree.
  306. */
  307. image_info.load_addr = spl_image->load_addr + spl_image->size;
  308. /* Figure out which device tree the board wants to use */
  309. node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP, index++);
  310. if (node < 0) {
  311. debug("%s: cannot find FDT node\n", __func__);
  312. /*
  313. * U-Boot did not find a device tree inside the FIT image. Use
  314. * the U-Boot device tree instead.
  315. */
  316. if (gd->fdt_blob)
  317. memcpy((void *)image_info.load_addr, gd->fdt_blob,
  318. fdt_totalsize(gd->fdt_blob));
  319. else
  320. return node;
  321. } else {
  322. ret = spl_load_fit_image(info, sector, fit, base_offset, node,
  323. &image_info);
  324. if (ret < 0)
  325. return ret;
  326. }
  327. /* Make the load-address of the FDT available for the SPL framework */
  328. spl_image->fdt_addr = (void *)image_info.load_addr;
  329. #if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY)
  330. if (CONFIG_IS_ENABLED(LOAD_FIT_APPLY_OVERLAY)) {
  331. void *tmpbuffer = NULL;
  332. for (; ; index++) {
  333. node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP,
  334. index);
  335. if (node == -E2BIG) {
  336. debug("%s: No additional FDT node\n", __func__);
  337. break;
  338. } else if (node < 0) {
  339. debug("%s: unable to find FDT node %d\n",
  340. __func__, index);
  341. continue;
  342. }
  343. if (!tmpbuffer) {
  344. /*
  345. * allocate memory to store the DT overlay
  346. * before it is applied. It may not be used
  347. * depending on how the overlay is stored, so
  348. * don't fail yet if the allocation failed.
  349. */
  350. tmpbuffer = malloc(CONFIG_SPL_LOAD_FIT_APPLY_OVERLAY_BUF_SZ);
  351. if (!tmpbuffer)
  352. debug("%s: unable to allocate space for overlays\n",
  353. __func__);
  354. }
  355. image_info.load_addr = (ulong)tmpbuffer;
  356. ret = spl_load_fit_image(info, sector, fit, base_offset,
  357. node, &image_info);
  358. if (ret < 0)
  359. break;
  360. /* Make room in FDT for changes from the overlay */
  361. ret = fdt_increase_size(spl_image->fdt_addr,
  362. image_info.size);
  363. if (ret < 0)
  364. break;
  365. ret = fdt_overlay_apply_verbose(spl_image->fdt_addr,
  366. (void *)image_info.load_addr);
  367. if (ret) {
  368. pr_err("failed to apply DT overlay %s\n",
  369. fit_get_name(fit, node, NULL));
  370. break;
  371. }
  372. debug("%s: DT overlay %s applied\n", __func__,
  373. fit_get_name(fit, node, NULL));
  374. }
  375. free(tmpbuffer);
  376. if (ret)
  377. return ret;
  378. }
  379. /* Try to make space, so we can inject details on the loadables */
  380. ret = fdt_shrink_to_minimum(spl_image->fdt_addr, 8192);
  381. if (ret < 0)
  382. return ret;
  383. #endif
  384. return ret;
  385. }
  386. static int spl_fit_record_loadable(const void *fit, int images, int index,
  387. void *blob, struct spl_image_info *image)
  388. {
  389. int ret = 0;
  390. #if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY)
  391. const char *name;
  392. int node;
  393. ret = spl_fit_get_image_name(fit, images, "loadables",
  394. index, &name);
  395. if (ret < 0)
  396. return ret;
  397. node = spl_fit_get_image_node(fit, images, "loadables", index);
  398. ret = fdt_record_loadable(blob, index, name, image->load_addr,
  399. image->size, image->entry_point,
  400. fdt_getprop(fit, node, "type", NULL),
  401. fdt_getprop(fit, node, "os", NULL));
  402. #endif
  403. return ret;
  404. }
  405. static int spl_fit_image_get_os(const void *fit, int noffset, uint8_t *os)
  406. {
  407. #if CONFIG_IS_ENABLED(FIT_IMAGE_TINY) && !defined(CONFIG_SPL_OS_BOOT)
  408. const char *name = fdt_getprop(fit, noffset, FIT_OS_PROP, NULL);
  409. if (!name)
  410. return -ENOENT;
  411. /*
  412. * We don't care what the type of the image actually is,
  413. * only whether or not it is U-Boot. This saves some
  414. * space by omitting the large table of OS types.
  415. */
  416. if (!strcmp(name, "u-boot"))
  417. *os = IH_OS_U_BOOT;
  418. else
  419. *os = IH_OS_INVALID;
  420. return 0;
  421. #else
  422. return fit_image_get_os(fit, noffset, os);
  423. #endif
  424. }
  425. /*
  426. * Weak default function to allow customizing SPL fit loading for load-only
  427. * use cases by allowing to skip the parsing/processing of the FIT contents
  428. * (so that this can be done separately in a more customized fashion)
  429. */
  430. __weak bool spl_load_simple_fit_skip_processing(void)
  431. {
  432. return false;
  433. }
  434. int spl_load_simple_fit(struct spl_image_info *spl_image,
  435. struct spl_load_info *info, ulong sector, void *fit)
  436. {
  437. int sectors;
  438. ulong size;
  439. unsigned long count;
  440. struct spl_image_info image_info;
  441. int node = -1;
  442. int images, ret;
  443. int base_offset, hsize, align_len = ARCH_DMA_MINALIGN - 1;
  444. int index = 0;
  445. int firmware_node;
  446. /*
  447. * For FIT with external data, figure out where the external images
  448. * start. This is the base for the data-offset properties in each
  449. * image.
  450. */
  451. size = fdt_totalsize(fit);
  452. size = (size + 3) & ~3;
  453. size = board_spl_fit_size_align(size);
  454. base_offset = (size + 3) & ~3;
  455. /*
  456. * So far we only have one block of data from the FIT. Read the entire
  457. * thing, including that first block, placing it so it finishes before
  458. * where we will load the image.
  459. *
  460. * Note that we will load the image such that its first byte will be
  461. * at the load address. Since that byte may be part-way through a
  462. * block, we may load the image up to one block before the load
  463. * address. So take account of that here by subtracting an addition
  464. * block length from the FIT start position.
  465. *
  466. * In fact the FIT has its own load address, but we assume it cannot
  467. * be before CONFIG_SYS_TEXT_BASE.
  468. *
  469. * For FIT with data embedded, data is loaded as part of FIT image.
  470. * For FIT with external data, data is not loaded in this step.
  471. */
  472. hsize = (size + info->bl_len + align_len) & ~align_len;
  473. fit = spl_get_load_buffer(-hsize, hsize);
  474. sectors = get_aligned_image_size(info, size, 0);
  475. count = info->read(info, sector, sectors, fit);
  476. debug("fit read sector %lx, sectors=%d, dst=%p, count=%lu, size=0x%lx\n",
  477. sector, sectors, fit, count, size);
  478. if (count == 0)
  479. return -EIO;
  480. /* skip further processing if requested to enable load-only use cases */
  481. if (spl_load_simple_fit_skip_processing())
  482. return 0;
  483. /* find the node holding the images information */
  484. images = fdt_path_offset(fit, FIT_IMAGES_PATH);
  485. if (images < 0) {
  486. debug("%s: Cannot find /images node: %d\n", __func__, images);
  487. return -1;
  488. }
  489. #ifdef CONFIG_SPL_FPGA
  490. node = spl_fit_get_image_node(fit, images, "fpga", 0);
  491. if (node >= 0) {
  492. /* Load the image and set up the spl_image structure */
  493. ret = spl_load_fit_image(info, sector, fit, base_offset, node,
  494. spl_image);
  495. if (ret) {
  496. printf("%s: Cannot load the FPGA: %i\n", __func__, ret);
  497. return ret;
  498. }
  499. debug("FPGA bitstream at: %x, size: %x\n",
  500. (u32)spl_image->load_addr, spl_image->size);
  501. ret = fpga_load(0, (const void *)spl_image->load_addr,
  502. spl_image->size, BIT_FULL);
  503. if (ret) {
  504. printf("%s: Cannot load the image to the FPGA\n",
  505. __func__);
  506. return ret;
  507. }
  508. puts("FPGA image loaded from FIT\n");
  509. node = -1;
  510. }
  511. #endif
  512. /*
  513. * Find the U-Boot image using the following search order:
  514. * - start at 'firmware' (e.g. an ARM Trusted Firmware)
  515. * - fall back 'kernel' (e.g. a Falcon-mode OS boot
  516. * - fall back to using the first 'loadables' entry
  517. */
  518. if (node < 0)
  519. node = spl_fit_get_image_node(fit, images, FIT_FIRMWARE_PROP,
  520. 0);
  521. #ifdef CONFIG_SPL_OS_BOOT
  522. if (node < 0)
  523. node = spl_fit_get_image_node(fit, images, FIT_KERNEL_PROP, 0);
  524. #endif
  525. if (node < 0) {
  526. debug("could not find firmware image, trying loadables...\n");
  527. node = spl_fit_get_image_node(fit, images, "loadables", 0);
  528. /*
  529. * If we pick the U-Boot image from "loadables", start at
  530. * the second image when later loading additional images.
  531. */
  532. index = 1;
  533. }
  534. if (node < 0) {
  535. debug("%s: Cannot find u-boot image node: %d\n",
  536. __func__, node);
  537. return -1;
  538. }
  539. /* Load the image and set up the spl_image structure */
  540. ret = spl_load_fit_image(info, sector, fit, base_offset, node,
  541. spl_image);
  542. if (ret)
  543. return ret;
  544. /*
  545. * For backward compatibility, we treat the first node that is
  546. * as a U-Boot image, if no OS-type has been declared.
  547. */
  548. if (!spl_fit_image_get_os(fit, node, &spl_image->os))
  549. debug("Image OS is %s\n", genimg_get_os_name(spl_image->os));
  550. #if !defined(CONFIG_SPL_OS_BOOT)
  551. else
  552. spl_image->os = IH_OS_U_BOOT;
  553. #endif
  554. /*
  555. * Booting a next-stage U-Boot may require us to append the FDT.
  556. * We allow this to fail, as the U-Boot image might embed its FDT.
  557. */
  558. if (spl_image->os == IH_OS_U_BOOT) {
  559. ret = spl_fit_append_fdt(spl_image, info, sector, fit,
  560. images, base_offset);
  561. if (!IS_ENABLED(CONFIG_OF_EMBED) && ret < 0)
  562. return ret;
  563. }
  564. firmware_node = node;
  565. /* Now check if there are more images for us to load */
  566. for (; ; index++) {
  567. uint8_t os_type = IH_OS_INVALID;
  568. node = spl_fit_get_image_node(fit, images, "loadables", index);
  569. if (node < 0)
  570. break;
  571. /*
  572. * if the firmware is also a loadable, skip it because
  573. * it already has been loaded. This is typically the case with
  574. * u-boot.img generated by mkimage.
  575. */
  576. if (firmware_node == node)
  577. continue;
  578. ret = spl_load_fit_image(info, sector, fit, base_offset, node,
  579. &image_info);
  580. if (ret < 0)
  581. continue;
  582. if (!spl_fit_image_get_os(fit, node, &os_type))
  583. debug("Loadable is %s\n", genimg_get_os_name(os_type));
  584. if (os_type == IH_OS_U_BOOT) {
  585. spl_fit_append_fdt(&image_info, info, sector,
  586. fit, images, base_offset);
  587. spl_image->fdt_addr = image_info.fdt_addr;
  588. }
  589. /*
  590. * If the "firmware" image did not provide an entry point,
  591. * use the first valid entry point from the loadables.
  592. */
  593. if (spl_image->entry_point == FDT_ERROR &&
  594. image_info.entry_point != FDT_ERROR)
  595. spl_image->entry_point = image_info.entry_point;
  596. /* Record our loadables into the FDT */
  597. if (spl_image->fdt_addr)
  598. spl_fit_record_loadable(fit, images, index,
  599. spl_image->fdt_addr,
  600. &image_info);
  601. }
  602. /*
  603. * If a platform does not provide CONFIG_SYS_UBOOT_START, U-Boot's
  604. * Makefile will set it to 0 and it will end up as the entry point
  605. * here. What it actually means is: use the load address.
  606. */
  607. if (spl_image->entry_point == FDT_ERROR || spl_image->entry_point == 0)
  608. spl_image->entry_point = spl_image->load_addr;
  609. spl_image->flags |= SPL_FIT_FOUND;
  610. #ifdef CONFIG_IMX_HAB
  611. board_spl_fit_post_load((ulong)fit, size);
  612. #endif
  613. return 0;
  614. }