[U-Boot] [PATCH v3 5/5] spl: fit: Add booting OS first

2017-08-15 Thread York Sun
If CONFIG_SPL_OS_BOOT is enabled, boot OS if kernel image is found
in FIT structure.

Signed-off-by: York Sun 
Reviewed-by: Tom Rini 

---
This presums the kernel image doesn't exist in a FIT image intended for
U-Boot. If kernel image normally co-exists with U-Boot and other images
and user intends to boot U-Boot, this patch needs to rewrite to favor
"loadables" over either "firmware" or "kernel" so user can select which
image to boot.

Changes in v3:
Update doc/uImage.FIT/multi_spl.its to explain the priority of booting image.

Changes in v2:
Split from previous patch, rebased on top of "SPL: FIT: allow loading
multiple images" by Andre Przywara.

 common/spl/spl_fit.c | 60 ++--
 doc/uImage.FIT/multi_spl.its |  7 ++
 2 files changed, 48 insertions(+), 19 deletions(-)

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 9449a22..49ccf1c 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -222,13 +222,16 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
ulong size;
unsigned long count;
struct spl_image_info image_info;
-   int node, images, ret;
+   bool boot_os = false;
+   int node = -1;
+   int images, ret;
int base_offset, align_len = ARCH_DMA_MINALIGN - 1;
int index = 0;
 
/*
-* Figure out where the external images start. This is the base for the
-* data-offset properties in each image.
+* For FIT with external data, figure out where the external images
+* start. This is the base for the data-offset properties in each
+* image.
 */
size = fdt_totalsize(fit);
size = (size + 3) & ~3;
@@ -247,6 +250,9 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
 *
 * In fact the FIT has its own load address, but we assume it cannot
 * be before CONFIG_SYS_TEXT_BASE.
+*
+* For FIT with data embedded, data is loaded as part of FIT image.
+* For FIT with external data, data is not loaded in this step.
 */
fit = (void *)((CONFIG_SYS_TEXT_BASE - size - info->bl_len -
align_len) & ~align_len);
@@ -264,8 +270,17 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
return -1;
}
 
+#ifdef CONFIG_SPL_OS_BOOT
+   /* Find OS image first */
+   node = spl_fit_get_image_node(fit, images, FIT_KERNEL_PROP, 0);
+   if (node < 0)
+   debug("No kernel image.\n");
+   else
+   boot_os = true;
+#endif
/* find the U-Boot image */
-   node = spl_fit_get_image_node(fit, images, "firmware", 0);
+   if (node < 0)
+   node = spl_fit_get_image_node(fit, images, "firmware", 0);
if (node < 0) {
debug("could not find firmware image, trying loadables...\n");
node = spl_fit_get_image_node(fit, images, "loadables", 0);
@@ -287,24 +302,31 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
if (ret)
return ret;
 
+#ifdef CONFIG_SPL_OS_BOOT
+   if (!fit_image_get_os(fit, node, &spl_image->os))
+   debug("Image OS is %s\n", genimg_get_os_name(spl_image->os));
+#else
spl_image->os = IH_OS_U_BOOT;
+#endif
 
-   /* Figure out which device tree the board wants to use */
-   node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP, 0);
-   if (node < 0) {
-   debug("%s: cannot find FDT node\n", __func__);
-   return node;
-   }
+   if (!boot_os) {
+   /* Figure out which device tree the board wants to use */
+   node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP, 0);
+   if (node < 0) {
+   debug("%s: cannot find FDT node\n", __func__);
+   return node;
+   }
 
-   /*
-* Read the device tree and place it after the image.
-* Align the destination address to ARCH_DMA_MINALIGN.
-*/
-   image_info.load_addr = spl_image->load_addr + spl_image->size;
-   ret = spl_load_fit_image(info, sector, fit, base_offset, node,
-&image_info);
-   if (ret < 0)
-   return ret;
+   /*
+* Read the device tree and place it after the image.
+* Align the destination address to ARCH_DMA_MINALIGN.
+*/
+   image_info.load_addr = spl_image->load_addr + spl_image->size;
+   ret = spl_load_fit_image(info, sector, fit, base_offset, node,
+&image_info);
+   if (ret < 0)
+   return ret;
+   }
 
/* Now check if there are more images for us to load */
for (; ; index++) {
diff --git a/doc/uImage.FIT/multi_spl.its b/doc/uImage.FIT/multi_spl.its
index e5551d4..d43563d 100644
--- a/doc/uImage.FIT/multi_spl.it

Re: [U-Boot] [PATCH v3 5/5] spl: fit: Add booting OS first

2017-08-26 Thread Simon Glass
On 15 August 2017 at 12:14, York Sun  wrote:
> If CONFIG_SPL_OS_BOOT is enabled, boot OS if kernel image is found
> in FIT structure.
>
> Signed-off-by: York Sun 
> Reviewed-by: Tom Rini 
>
> ---
> This presums the kernel image doesn't exist in a FIT image intended for
> U-Boot. If kernel image normally co-exists with U-Boot and other images
> and user intends to boot U-Boot, this patch needs to rewrite to favor
> "loadables" over either "firmware" or "kernel" so user can select which
> image to boot.
>
> Changes in v3:
> Update doc/uImage.FIT/multi_spl.its to explain the priority of booting image.
>
> Changes in v2:
> Split from previous patch, rebased on top of "SPL: FIT: allow loading
> multiple images" by Andre Przywara.
>
>  common/spl/spl_fit.c | 60 
> ++--
>  doc/uImage.FIT/multi_spl.its |  7 ++
>  2 files changed, 48 insertions(+), 19 deletions(-)

Reviewed-by: Simon Glass 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 5/5] spl: fit: Add booting OS first

2017-09-12 Thread York Sun
On 08/15/2017 11:15 AM, York Sun wrote:
> If CONFIG_SPL_OS_BOOT is enabled, boot OS if kernel image is found
> in FIT structure.
> 
> Signed-off-by: York Sun 
> Reviewed-by: Tom Rini 
> 
> ---
> This presums the kernel image doesn't exist in a FIT image intended for
> U-Boot. If kernel image normally co-exists with U-Boot and other images
> and user intends to boot U-Boot, this patch needs to rewrite to favor
> "loadables" over either "firmware" or "kernel" so user can select which
> image to boot.
> 
> Changes in v3:
> Update doc/uImage.FIT/multi_spl.its to explain the priority of booting image.
> 
> Changes in v2:
> Split from previous patch, rebased on top of "SPL: FIT: allow loading
> multiple images" by Andre Przywara.

Applied to fsl-qoriq master.

York
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot