spl_fit.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  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_SUPPORT) ||
  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. image_info->load_addr = load_addr;
  288. image_info->size = length;
  289. image_info->entry_point = fdt_getprop_u32(fit, node, "entry");
  290. }
  291. return 0;
  292. }
  293. static int spl_fit_append_fdt(struct spl_image_info *spl_image,
  294. struct spl_load_info *info, ulong sector,
  295. void *fit, int images, ulong base_offset)
  296. {
  297. struct spl_image_info image_info;
  298. int node, ret = 0, index = 0;
  299. /*
  300. * Use the address following the image as target address for the
  301. * device tree. Load address is aligned to 8 bytes to match the required
  302. * alignment specified for linux arm [1] and arm 64 [2] booting
  303. * [1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/arm/booting.rst#n126
  304. * [2]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/arm64/booting.rst#n45
  305. */
  306. image_info.load_addr = ALIGN(spl_image->load_addr + spl_image->size, 8);
  307. /* Figure out which device tree the board wants to use */
  308. node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP, index++);
  309. if (node < 0) {
  310. debug("%s: cannot find FDT node\n", __func__);
  311. /*
  312. * U-Boot did not find a device tree inside the FIT image. Use
  313. * the U-Boot device tree instead.
  314. */
  315. if (gd->fdt_blob)
  316. memcpy((void *)image_info.load_addr, gd->fdt_blob,
  317. fdt_totalsize(gd->fdt_blob));
  318. else
  319. return node;
  320. } else {
  321. ret = spl_load_fit_image(info, sector, fit, base_offset, node,
  322. &image_info);
  323. if (ret < 0)
  324. return ret;
  325. }
  326. /* Make the load-address of the FDT available for the SPL framework */
  327. spl_image->fdt_addr = (void *)image_info.load_addr;
  328. #if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY)
  329. if (CONFIG_IS_ENABLED(LOAD_FIT_APPLY_OVERLAY)) {
  330. void *tmpbuffer = NULL;
  331. for (; ; index++) {
  332. node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP,
  333. index);
  334. if (node == -E2BIG) {
  335. debug("%s: No additional FDT node\n", __func__);
  336. break;
  337. } else if (node < 0) {
  338. debug("%s: unable to find FDT node %d\n",
  339. __func__, index);
  340. continue;
  341. }
  342. if (!tmpbuffer) {
  343. /*
  344. * allocate memory to store the DT overlay
  345. * before it is applied. It may not be used
  346. * depending on how the overlay is stored, so
  347. * don't fail yet if the allocation failed.
  348. */
  349. tmpbuffer = malloc(CONFIG_SPL_LOAD_FIT_APPLY_OVERLAY_BUF_SZ);
  350. if (!tmpbuffer)
  351. debug("%s: unable to allocate space for overlays\n",
  352. __func__);
  353. }
  354. image_info.load_addr = (ulong)tmpbuffer;
  355. ret = spl_load_fit_image(info, sector, fit, base_offset,
  356. node, &image_info);
  357. if (ret < 0)
  358. break;
  359. /* Make room in FDT for changes from the overlay */
  360. ret = fdt_increase_size(spl_image->fdt_addr,
  361. image_info.size);
  362. if (ret < 0)
  363. break;
  364. ret = fdt_overlay_apply_verbose(spl_image->fdt_addr,
  365. (void *)image_info.load_addr);
  366. if (ret) {
  367. pr_err("failed to apply DT overlay %s\n",
  368. fit_get_name(fit, node, NULL));
  369. break;
  370. }
  371. debug("%s: DT overlay %s applied\n", __func__,
  372. fit_get_name(fit, node, NULL));
  373. }
  374. free(tmpbuffer);
  375. if (ret)
  376. return ret;
  377. }
  378. /* Try to make space, so we can inject details on the loadables */
  379. ret = fdt_shrink_to_minimum(spl_image->fdt_addr, 8192);
  380. if (ret < 0)
  381. return ret;
  382. #endif
  383. return ret;
  384. }
  385. static int spl_fit_record_loadable(const void *fit, int images, int index,
  386. void *blob, struct spl_image_info *image)
  387. {
  388. int ret = 0;
  389. #if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY)
  390. const char *name;
  391. int node;
  392. ret = spl_fit_get_image_name(fit, images, "loadables",
  393. index, &name);
  394. if (ret < 0)
  395. return ret;
  396. node = spl_fit_get_image_node(fit, images, "loadables", index);
  397. ret = fdt_record_loadable(blob, index, name, image->load_addr,
  398. image->size, image->entry_point,
  399. fdt_getprop(fit, node, "type", NULL),
  400. fdt_getprop(fit, node, "os", NULL));
  401. #endif
  402. return ret;
  403. }
  404. static int spl_fit_image_get_os(const void *fit, int noffset, uint8_t *os)
  405. {
  406. #if CONFIG_IS_ENABLED(FIT_IMAGE_TINY) && !defined(CONFIG_SPL_OS_BOOT)
  407. return -ENOTSUPP;
  408. #else
  409. return fit_image_get_os(fit, noffset, os);
  410. #endif
  411. }
  412. /*
  413. * Weak default function to allow customizing SPL fit loading for load-only
  414. * use cases by allowing to skip the parsing/processing of the FIT contents
  415. * (so that this can be done separately in a more customized fashion)
  416. */
  417. __weak bool spl_load_simple_fit_skip_processing(void)
  418. {
  419. return false;
  420. }
  421. int spl_load_simple_fit(struct spl_image_info *spl_image,
  422. struct spl_load_info *info, ulong sector, void *fit)
  423. {
  424. int sectors;
  425. ulong size;
  426. unsigned long count;
  427. struct spl_image_info image_info;
  428. int node = -1;
  429. int images, ret;
  430. int base_offset, hsize, align_len = ARCH_DMA_MINALIGN - 1;
  431. int index = 0;
  432. int firmware_node;
  433. /*
  434. * For FIT with external data, figure out where the external images
  435. * start. This is the base for the data-offset properties in each
  436. * image.
  437. */
  438. size = fdt_totalsize(fit);
  439. size = (size + 3) & ~3;
  440. size = board_spl_fit_size_align(size);
  441. base_offset = (size + 3) & ~3;
  442. /*
  443. * So far we only have one block of data from the FIT. Read the entire
  444. * thing, including that first block, placing it so it finishes before
  445. * where we will load the image.
  446. *
  447. * Note that we will load the image such that its first byte will be
  448. * at the load address. Since that byte may be part-way through a
  449. * block, we may load the image up to one block before the load
  450. * address. So take account of that here by subtracting an addition
  451. * block length from the FIT start position.
  452. *
  453. * In fact the FIT has its own load address, but we assume it cannot
  454. * be before CONFIG_SYS_TEXT_BASE.
  455. *
  456. * For FIT with data embedded, data is loaded as part of FIT image.
  457. * For FIT with external data, data is not loaded in this step.
  458. */
  459. hsize = (size + info->bl_len + align_len) & ~align_len;
  460. fit = spl_get_load_buffer(-hsize, hsize);
  461. sectors = get_aligned_image_size(info, size, 0);
  462. count = info->read(info, sector, sectors, fit);
  463. debug("fit read sector %lx, sectors=%d, dst=%p, count=%lu, size=0x%lx\n",
  464. sector, sectors, fit, count, size);
  465. if (count == 0)
  466. return -EIO;
  467. /* skip further processing if requested to enable load-only use cases */
  468. if (spl_load_simple_fit_skip_processing())
  469. return 0;
  470. /* find the node holding the images information */
  471. images = fdt_path_offset(fit, FIT_IMAGES_PATH);
  472. if (images < 0) {
  473. debug("%s: Cannot find /images node: %d\n", __func__, images);
  474. return -1;
  475. }
  476. #ifdef CONFIG_SPL_FPGA_SUPPORT
  477. node = spl_fit_get_image_node(fit, images, "fpga", 0);
  478. if (node >= 0) {
  479. /* Load the image and set up the spl_image structure */
  480. ret = spl_load_fit_image(info, sector, fit, base_offset, node,
  481. spl_image);
  482. if (ret) {
  483. printf("%s: Cannot load the FPGA: %i\n", __func__, ret);
  484. return ret;
  485. }
  486. debug("FPGA bitstream at: %x, size: %x\n",
  487. (u32)spl_image->load_addr, spl_image->size);
  488. ret = fpga_load(0, (const void *)spl_image->load_addr,
  489. spl_image->size, BIT_FULL);
  490. if (ret) {
  491. printf("%s: Cannot load the image to the FPGA\n",
  492. __func__);
  493. return ret;
  494. }
  495. puts("FPGA image loaded from FIT\n");
  496. node = -1;
  497. }
  498. #endif
  499. /*
  500. * Find the U-Boot image using the following search order:
  501. * - start at 'firmware' (e.g. an ARM Trusted Firmware)
  502. * - fall back 'kernel' (e.g. a Falcon-mode OS boot
  503. * - fall back to using the first 'loadables' entry
  504. */
  505. if (node < 0)
  506. node = spl_fit_get_image_node(fit, images, FIT_FIRMWARE_PROP,
  507. 0);
  508. #ifdef CONFIG_SPL_OS_BOOT
  509. if (node < 0)
  510. node = spl_fit_get_image_node(fit, images, FIT_KERNEL_PROP, 0);
  511. #endif
  512. if (node < 0) {
  513. debug("could not find firmware image, trying loadables...\n");
  514. node = spl_fit_get_image_node(fit, images, "loadables", 0);
  515. /*
  516. * If we pick the U-Boot image from "loadables", start at
  517. * the second image when later loading additional images.
  518. */
  519. index = 1;
  520. }
  521. if (node < 0) {
  522. debug("%s: Cannot find u-boot image node: %d\n",
  523. __func__, node);
  524. return -1;
  525. }
  526. /* Load the image and set up the spl_image structure */
  527. ret = spl_load_fit_image(info, sector, fit, base_offset, node,
  528. spl_image);
  529. if (ret)
  530. return ret;
  531. /*
  532. * For backward compatibility, we treat the first node that is
  533. * as a U-Boot image, if no OS-type has been declared.
  534. */
  535. if (!spl_fit_image_get_os(fit, node, &spl_image->os))
  536. debug("Image OS is %s\n", genimg_get_os_name(spl_image->os));
  537. #if !defined(CONFIG_SPL_OS_BOOT)
  538. else
  539. spl_image->os = IH_OS_U_BOOT;
  540. #endif
  541. /*
  542. * Booting a next-stage U-Boot may require us to append the FDT.
  543. * We allow this to fail, as the U-Boot image might embed its FDT.
  544. */
  545. if (spl_image->os == IH_OS_U_BOOT) {
  546. ret = spl_fit_append_fdt(spl_image, info, sector, fit,
  547. images, base_offset);
  548. if (!IS_ENABLED(CONFIG_OF_EMBED) && ret < 0)
  549. return ret;
  550. }
  551. firmware_node = node;
  552. /* Now check if there are more images for us to load */
  553. for (; ; index++) {
  554. uint8_t os_type = IH_OS_INVALID;
  555. node = spl_fit_get_image_node(fit, images, "loadables", index);
  556. if (node < 0)
  557. break;
  558. /*
  559. * if the firmware is also a loadable, skip it because
  560. * it already has been loaded. This is typically the case with
  561. * u-boot.img generated by mkimage.
  562. */
  563. if (firmware_node == node)
  564. continue;
  565. ret = spl_load_fit_image(info, sector, fit, base_offset, node,
  566. &image_info);
  567. if (ret < 0)
  568. continue;
  569. if (!spl_fit_image_get_os(fit, node, &os_type))
  570. debug("Loadable is %s\n", genimg_get_os_name(os_type));
  571. if (os_type == IH_OS_U_BOOT) {
  572. spl_fit_append_fdt(&image_info, info, sector,
  573. fit, images, base_offset);
  574. spl_image->fdt_addr = image_info.fdt_addr;
  575. }
  576. /*
  577. * If the "firmware" image did not provide an entry point,
  578. * use the first valid entry point from the loadables.
  579. */
  580. if (spl_image->entry_point == FDT_ERROR &&
  581. image_info.entry_point != FDT_ERROR)
  582. spl_image->entry_point = image_info.entry_point;
  583. /* Record our loadables into the FDT */
  584. if (spl_image->fdt_addr)
  585. spl_fit_record_loadable(fit, images, index,
  586. spl_image->fdt_addr,
  587. &image_info);
  588. }
  589. /*
  590. * If a platform does not provide CONFIG_SYS_UBOOT_START, U-Boot's
  591. * Makefile will set it to 0 and it will end up as the entry point
  592. * here. What it actually means is: use the load address.
  593. */
  594. if (spl_image->entry_point == FDT_ERROR || spl_image->entry_point == 0)
  595. spl_image->entry_point = spl_image->load_addr;
  596. spl_image->flags |= SPL_FIT_FOUND;
  597. #ifdef CONFIG_IMX_HAB
  598. board_spl_fit_post_load((ulong)fit, size);
  599. #endif
  600. return 0;
  601. }