Skip to contentSkip to conversation

SPL: FIT: Fix some omissions of SPL_LOAD_FIT_FULL and bootm

PATCH Superseded Alexandru Gagniuc 2 participants 17 messages Mar 11, 2021 – Apr 14, 2021

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover SPL: FIT: Fix some omissions of SPL_LOAD_FIT_FULL and bootm

Although this series focuses on SPL_LOAD_FIT_FULL, some of the fixes will also apply to bootm, as they are sharing significant amounts of code.

Originally SPL_LOAD_FIT_FULL could not start either a linux FIT or a u-boot image. It didn't even take FIT images generated automatically by mkimage, as part of the u-boot build!!! The goal is to at the very least, be able to boot autogenerated mkimage FITs.

This brings us much more in line with SPL_LOAD_FIT, and the documentation. It's not perfect, and the fpga 'compatible =' support is still not implemented. That's all I currently have time for before someone notices I'm working on u-boot again.

Alexandru Gagniuc (6):
spl: LOAD_FIT_FULL: Fix selection of the "fdt" node
spl: LOAD_FIT_FULL: Do not hard-code os to IH_OS_U_BOOT
spl: LOAD_FIT_FULL: Relocate FDT for u-boot payloads
spl: LOAD_FIT_FULL: Support 'kernel' and 'firmware' properties
image-fit: Accept IH_TYPE_FIRMWARE in fit_image_load() as valid
image-fit: Accept OP-TEE images when booting a FIT

 common/image-fit.c |  4 ++++
 common/spl/spl.c   | 40 +++++++++++++++++++++++++++++++++-------
 2 files changed, 37 insertions(+), 7 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/6 spl: LOAD_FIT_FULL: Fix selection of the "fdt" node

The correct FDT to use is described by the "fdt" property of the configuration node. When the fit_unamep argument to fit_image_load() is "fdt", we get the "/images/fdt" node. This is incorrect, as it ignores the "fdt" property of the config node, and in most cases, the "/images/fdt" node doesn't exist.

When the 'fit_unamep' argument is NULL, fit_image_load() uses the IH_TYPE_FLATDT value to read the config property "fdt", which points to the correct FDT node(s).

fit_image_load() should probably be split into a function that reads an image by name, and one that reads an image by config reference. I don't make those decisions, I just point out the craziness.

---
 common/spl/spl.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
common/spl/spl.c +1 -3
index e3d84082f4..986cfbc6fd 100644
@@ -201,7 +201,6 @@ static int spl_load_fit_image(struct spl_image_info *spl_image,
 {
 	bootm_headers_t images;
 	const char *fit_uname_config = NULL;
-	const char *fit_uname_fdt = FIT_FDT_PROP;
 	const char *uname;
 	ulong fw_data = 0, dt_data = 0, img_data = 0;
 	ulong fw_len = 0, dt_len = 0, img_len = 0;
@@ -230,8 +229,7 @@ static int spl_load_fit_image(struct spl_image_info *spl_image,
 #ifdef CONFIG_SPL_FIT_SIGNATURE
 	images.verify = 1;
 #endif
-	ret = fit_image_load(&images, (ulong)header,
-		       &fit_uname_fdt, &fit_uname_config,
+	ret = fit_image_load(&images, (ulong)header, NULL, &fit_uname_config,
 		       IH_ARCH_DEFAULT, IH_TYPE_FLATDT, -1,
 		       FIT_LOAD_OPTIONAL, &dt_data, &dt_len);
 	if (ret >= 0)
Signature · 1 line
2.26.2
#2 lore raw

PATCH 1/6 spl: LOAD_FIT_FULL: Fix selection of the "fdt" node

Hi Alexandru,

Quoted 3 lines · Alexandru Gagniuc

The correct FDT to use is described by the "fdt" property of the configuration node. When the fit_unamep argument to fit_image_load()

fit_unamep (and below

Quoted 11 lines

is "fdt", we get the "/images/fdt" node. This is incorrect, as it ignores the "fdt" property of the config node, and in most cases, the "/images/fdt" node doesn't exist.

When the 'fit_unamep' argument is NULL, fit_image_load() uses the IH_TYPE_FLATDT value to read the config property "fdt", which points to the correct FDT node(s).

fit_image_load() should probably be split into a function that reads an image by name, and one that reads an image by config reference. I don't make those decisions, I just point out the craziness.

Somewhere you need to add a simple sentence explaining what your change does.

Quoted 6 lines
---
 common/spl/spl.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
Quoted 25 lines
common/spl/spl.c +1 -4
index e3d84082f4..986cfbc6fd 100644
@@ -201,7 +201,6 @@ static int spl_load_fit_image(struct spl_image_info *spl_image,
 {
        bootm_headers_t images;
        const char *fit_uname_config = NULL;
-       const char *fit_uname_fdt = FIT_FDT_PROP;
        const char *uname;
        ulong fw_data = 0, dt_data = 0, img_data = 0;
        ulong fw_len = 0, dt_len = 0, img_len = 0;
@@ -230,8 +229,7 @@ static int spl_load_fit_image(struct spl_image_info *spl_image,
 #ifdef CONFIG_SPL_FIT_SIGNATURE
        images.verify = 1;
 #endif
-       ret = fit_image_load(&images, (ulong)header,
-                      &fit_uname_fdt, &fit_uname_config,
+       ret = fit_image_load(&images, (ulong)header, NULL, &fit_uname_config,
                       IH_ARCH_DEFAULT, IH_TYPE_FLATDT, -1,
                       FIT_LOAD_OPTIONAL, &dt_data, &dt_len);
        if (ret >= 0)
--

2.26.2

#3 lore raw

PATCH 2/6 spl: LOAD_FIT_FULL: Do not hard-code os to IH_OS_U_BOOT

In reply to Alexandru Gagniuc

The information on the OS should be contained in the FIT, as the self-explanatory "os" property of a node under /images. Hard-coding this to U_BOOT might send us down the wrong path later in the boot process.

---
 common/spl/spl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
common/spl/spl.c +3 -2
index 986cfbc6fd..8f6c8dba6f 100644
@@ -220,8 +220,9 @@ static int spl_load_fit_image(struct spl_image_info *spl_image,
 	spl_image->size = fw_len;
 	spl_image->entry_point = fw_data;
 	spl_image->load_addr = fw_data;
-	spl_image->os = IH_OS_U_BOOT;
-	spl_image->name = "U-Boot";
+	if (!fit_image_get_os(header, ret, &spl_image->os))
+		spl_image->os = IH_OS_INVALID;
+	spl_image->name = genimg_get_os_name(spl_image->os);
 
 	debug(SPL_TPL_PROMPT "payload image: %32s load addr: 0x%lx size: %d\n",
 	      spl_image->name, spl_image->load_addr, spl_image->size);
Signature · 1 line
2.26.2
#4 lore raw

PATCH 2/6 spl: LOAD_FIT_FULL: Do not hard-code os to IH_OS_U_BOOT

Quoted 16 lines · Alexandru Gagniuc

The information on the OS should be contained in the FIT, as the self-explanatory "os" property of a node under /images. Hard-coding this to U_BOOT might send us down the wrong path later in the boot process.

---
 common/spl/spl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
common/spl/spl.c +0 -0
index 986cfbc6fd..8f6c8dba6f 100644

common/spl/spl.c static int spl_load_fit_image(struct spl_image_info *spl_image, · line 223

Quoted 4 lines
common/spl/spl.c +0 -1
@@ -220,8 +220,9 @@ static int spl_load_fit_image(struct spl_image_info *spl_image,
        spl_image->size = fw_len;
        spl_image->entry_point = fw_data;
        spl_image->load_addr = fw_data;
-       spl_image->os = IH_OS_U_BOOT;

Again I wonder about the code-size impact of this. Should it depend on Kconfig?

Quoted 10 lines
common/spl/spl.c +3 -2
-       spl_image->name = "U-Boot";
+       if (!fit_image_get_os(header, ret, &spl_image->os))
+               spl_image->os = IH_OS_INVALID;
+       spl_image->name = genimg_get_os_name(spl_image->os);
 
        debug(SPL_TPL_PROMPT "payload image: %32s load addr: 0x%lx size: %d\n",
              spl_image->name, spl_image->load_addr, spl_image->size);
--

2.26.2

Regards,
Simon

author
#5 lore raw

PATCH 2/6 spl: LOAD_FIT_FULL: Do not hard-code os to IH_OS_U_BOOT

Quoted 12 lines · Simon Glass
Quoted 11 lines · Alexandru Gagniuc

The information on the OS should be contained in the FIT, as the self-explanatory "os" property of a node under /images. Hard-coding this to U_BOOT might send us down the wrong path later in the boot process.

---
  common/spl/spl.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
Quoted 10 lines

common/spl/spl.c static int spl_load_fit_image(struct spl_image_info *spl_image, · line 223

Quoted 9 lines
common/spl/spl.c +0 -1
index 986cfbc6fd..8f6c8dba6f 100644
@@ -220,8 +220,9 @@ static int spl_load_fit_image(struct spl_image_info *spl_image,
         spl_image->size = fw_len;
         spl_image->entry_point = fw_data;
         spl_image->load_addr = fw_data;
-       spl_image->os = IH_OS_U_BOOT;

+8 bytes. Down in the noise

Alex

Quoted 14 lines
Quoted 10 lines
common/spl/spl.c +3 -2
-       spl_image->name = "U-Boot";
+       if (!fit_image_get_os(header, ret, &spl_image->os))
+               spl_image->os = IH_OS_INVALID;
+       spl_image->name = genimg_get_os_name(spl_image->os);
 
         debug(SPL_TPL_PROMPT "payload image: %32s load addr: 0x%lx size: %d\n",
               spl_image->name, spl_image->load_addr, spl_image->size);
--

2.26.2

Regards,
Simon

#6 lore raw

PATCH 2/6 spl: LOAD_FIT_FULL: Do not hard-code os to IH_OS_U_BOOT

Quoted 11 lines · Alex G.
Quoted 7 lines · Simon Glass
Quoted 6 lines · Alexandru Gagniuc

The information on the OS should be contained in the FIT, as the self-explanatory "os" property of a node under /images. Hard-coding this to U_BOOT might send us down the wrong path later in the boot process.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
---
  common/spl/spl.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
#7 lore raw

PATCH 3/6 spl: LOAD_FIT_FULL: Relocate FDT for u-boot payloads

In reply to Alexandru Gagniuc

U-Boot expects the FDT to be located right after the _end linker symbol (see fdtdec.c: board_fdt_blob_setup())

The "basic" LOAD_FIT path is aware of this limitation, and relocates the FDT at the expected location. Guessing the expected location probably only works reliably on 32-bit arm, and it feels like a hack. One proposal would be to pass the FDT address to u-boot (e.g. using 'r2' on arm platforms).

The variable is named "fdt_hack" to remind future contributors that, "hey! we should fix the underlying problem". However, that is beyond the scope of this patch.

---
 common/spl/spl.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
common/spl/spl.c +11 -1
index 8f6c8dba6f..e63f05bb33 100644
@@ -201,6 +201,7 @@ static int spl_load_fit_image(struct spl_image_info *spl_image,
 {
 	bootm_headers_t images;
 	const char *fit_uname_config = NULL;
+	uintptr_t fdt_hack;
 	const char *uname;
 	ulong fw_data = 0, dt_data = 0, img_data = 0;
 	ulong fw_len = 0, dt_len = 0, img_len = 0;
@@ -233,9 +234,18 @@ static int spl_load_fit_image(struct spl_image_info *spl_image,
 	ret = fit_image_load(&images, (ulong)header, NULL, &fit_uname_config,
 		       IH_ARCH_DEFAULT, IH_TYPE_FLATDT, -1,
 		       FIT_LOAD_OPTIONAL, &dt_data, &dt_len);
-	if (ret >= 0)
+	if (ret >= 0) {
 		spl_image->fdt_addr = (void *)dt_data;
 
+		if (spl_image->os == IH_OS_U_BOOT) {
+			/* HACK: U-boot expects FDT at a specific address */
+			fdt_hack = spl_image->load_addr + spl_image->size;
+			fdt_hack = (fdt_hack + 3) & ~3;
+			debug("Relocating FDT to %p\n", spl_image->fdt_addr);
+			memcpy((void *)fdt_hack, spl_image->fdt_addr, dt_len);
+		}
+	}
+
 	conf_noffset = fit_conf_get_node((const void *)header,
 					 fit_uname_config);
 	if (conf_noffset <= 0)
Signature · 1 line
2.26.2
#8 lore raw

PATCH 3/6 spl: LOAD_FIT_FULL: Relocate FDT for u-boot payloads

Hi Alexandru,

Quoted 9 lines · Alexandru Gagniuc

U-Boot expects the FDT to be located right after the _end linker symbol (see fdtdec.c: board_fdt_blob_setup())

The "basic" LOAD_FIT path is aware of this limitation, and relocates the FDT at the expected location. Guessing the expected location probably only works reliably on 32-bit arm, and it feels like a hack. One proposal would be to pass the FDT address to u-boot (e.g. using 'r2' on arm platforms).

We could do that, but the current behaviour is OK. It is required that you can joined U-Boot and its FDT and get a valid image.

Quoted 4 lines

The variable is named "fdt_hack" to remind future contributors that, "hey! we should fix the underlying problem". However, that is beyond the scope of this patch.

I think it is fine to require it be after U-Boot, in fact that is defined by U-Boot. So I don't think you need to think of it as a hack.

Quoted 20 lines
---
 common/spl/spl.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
common/spl/spl.c +1 -0
index 8f6c8dba6f..e63f05bb33 100644
@@ -201,6 +201,7 @@ static int spl_load_fit_image(struct spl_image_info *spl_image,
 {
        bootm_headers_t images;
        const char *fit_uname_config = NULL;
+       uintptr_t fdt_hack;
        const char *uname;
        ulong fw_data = 0, dt_data = 0, img_data = 0;
        ulong fw_len = 0, dt_len = 0, img_len = 0;
@@ -233,9 +234,18 @@ static int spl_load_fit_image(struct spl_image_info *spl_image,
        ret = fit_image_load(&images, (ulong)header, NULL, &fit_uname_config,

common/spl/spl.c static int spl_load_fit_image(struct spl_image_info *spl_image, · line 243

Quoted 10 lines
common/spl/spl.c +5 -1
                       IH_ARCH_DEFAULT, IH_TYPE_FLATDT, -1,
                       FIT_LOAD_OPTIONAL, &dt_data, &dt_len);
-       if (ret >= 0)
+       if (ret >= 0) {
                spl_image->fdt_addr = (void *)dt_data;
 
+               if (spl_image->os == IH_OS_U_BOOT) {
+                       /* HACK: U-boot expects FDT at a specific address */
+                       fdt_hack = spl_image->load_addr + spl_image->size;
+                       fdt_hack = (fdt_hack + 3) & ~3;

I don't think this is needed and it just confuses things. If U-Boot is not an aligned sign, it can't boot because the DT ends up in the wrong place. The build system makes sure this doesn't happen.

Quoted 11 lines
common/spl/spl.c +5 -1
+                       debug("Relocating FDT to %p\n", spl_image->fdt_addr);
+                       memcpy((void *)fdt_hack, spl_image->fdt_addr, dt_len);
+               }
+       }
+
        conf_noffset = fit_conf_get_node((const void *)header,
                                         fit_uname_config);
        if (conf_noffset <= 0)
--

2.26.2

Regards,
Simon

author
#9 lore raw

PATCH 3/6 spl: LOAD_FIT_FULL: Relocate FDT for u-boot payloads

Quoted 22 lines · Simon Glass

Hi Alexandru,

Quoted 20 lines
common/spl/spl.c +2 -1
index 8f6c8dba6f..e63f05bb33 100644
@@ -201,6 +201,7 @@ static int spl_load_fit_image(struct spl_image_info *spl_image,
  {
         bootm_headers_t images;
         const char *fit_uname_config = NULL;
+       uintptr_t fdt_hack;
         const char *uname;
         ulong fw_data = 0, dt_data = 0, img_data = 0;
         ulong fw_len = 0, dt_len = 0, img_len = 0;
@@ -233,9 +234,18 @@ static int spl_load_fit_image(struct spl_image_info *spl_image,
         ret = fit_image_load(&images, (ulong)header, NULL, &fit_uname_config,
                        IH_ARCH_DEFAULT, IH_TYPE_FLATDT, -1,
                        FIT_LOAD_OPTIONAL, &dt_data, &dt_len);
-       if (ret >= 0)
+       if (ret >= 0) {
                 spl_image->fdt_addr = (void *)dt_data;
 
Quoted 8 lines

common/spl/spl.c static int spl_load_fit_image(struct spl_image_info *spl_image, · line 243

Quoted 4 lines
common/spl/spl.c +4 -0
+               if (spl_image->os == IH_OS_U_BOOT) {
+                       /* HACK: U-boot expects FDT at a specific address */
+                       fdt_hack = spl_image->load_addr + spl_image->size;
+                       fdt_hack = (fdt_hack + 3) & ~3;

I don't think this is needed and it just confuses things. If U-Boot is not an aligned sign, it can't boot because the DT ends up in the wrong place. The build system makes sure this doesn't happen.

The correct alignment for an FDT is 8 bytes. For a while, this alignment was implemented [1], and that worked fine with everything but u-boot.

Now to the build system argument. I don't think It's wise the assume the conventions of the SPL build and of the u-boot build are the same. Even assuming the branch building the SPL is perfect, the FIT image could have been built from a buggy u-boot branch, or even assembled manually outside the u-boot build.

Consequently, we can't assume the FIT image will have a spl_image->size of the correct alignment. Thus, aligning things by hand is quite necessary.

The problem with [1] is that it broke booting u-boot with FIT. It had to be reverted [2]. There was a lengthy email discussion about, where I included an example of the failure [3]. Now, wish the actual problem could be fixed, but I don't have the bandwidth. The best I can do is document the problem.

Alex

[1]
https://source.denx.de/u-boot/u-boot/-/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
[2]
https://source.denx.de/u-boot/u-boot/-/commit/5675ed7cb645f5ec13958726992daeeed16fd114
[3] https://lists.denx.de/pipermail/u-boot/2020-October/430058.html

#10 lore raw

PATCH 4/6 spl: LOAD_FIT_FULL: Support 'kernel' and 'firmware' properties

In reply to Alexandru Gagniuc

The 'firmware' property of a config node takes precedence over the 'kernel' property. 'standalone' is deprecated. However, give users a couple of releases where 'standalone' still works, but warns loudly.

---
 common/spl/spl.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
common/spl/spl.c +18 -1
index e63f05bb33..da4751b4ac 100644
@@ -214,7 +214,24 @@ static int spl_load_fit_image(struct spl_image_info *spl_image,
 	ret = fit_image_load(&images, (ulong)header,
 			     NULL, &fit_uname_config,
 			     IH_ARCH_DEFAULT, IH_TYPE_STANDALONE, -1,
-			     FIT_LOAD_REQUIRED, &fw_data, &fw_len);
+			     FIT_LOAD_OPTIONAL, &fw_data, &fw_len);
+	if (ret >= 0) {
+		printf("DEPRECATED: 'standalone = ' property.");
+		printf("Please use either 'firmware =' or 'kernel ='\n");
+	} else {
+		ret = fit_image_load(&images, (ulong)header, NULL,
+				     &fit_uname_config, IH_ARCH_DEFAULT,
+				     IH_TYPE_FIRMWARE, -1, FIT_LOAD_OPTIONAL,
+				     &fw_data, &fw_len);
+	}
+
+	if (ret < 0) {
+		ret = fit_image_load(&images, (ulong)header, NULL,
+				     &fit_uname_config, IH_ARCH_DEFAULT,
+				     IH_TYPE_KERNEL, -1, FIT_LOAD_OPTIONAL,
+				     &fw_data, &fw_len);
+	}
+
 	if (ret < 0)
 		return ret;
 
Signature · 1 line
2.26.2
#11 lore raw

PATCH 4/6 spl: LOAD_FIT_FULL: Support 'kernel' and 'firmware' properties

HI Alexandru,

Quoted 25 lines · Alexandru Gagniuc

The 'firmware' property of a config node takes precedence over the 'kernel' property. 'standalone' is deprecated. However, give users a couple of releases where 'standalone' still works, but warns loudly.

---
 common/spl/spl.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
common/spl/spl.c +6 -1
index e63f05bb33..da4751b4ac 100644
@@ -214,7 +214,24 @@ static int spl_load_fit_image(struct spl_image_info *spl_image,
        ret = fit_image_load(&images, (ulong)header,
                             NULL, &fit_uname_config,
                             IH_ARCH_DEFAULT, IH_TYPE_STANDALONE, -1,
-                            FIT_LOAD_REQUIRED, &fw_data, &fw_len);
+                            FIT_LOAD_OPTIONAL, &fw_data, &fw_len);
+       if (ret >= 0) {
+               printf("DEPRECATED: 'standalone = ' property.");
+               printf("Please use either 'firmware =' or 'kernel ='\n");
+       } else {
+               ret = fit_image_load(&images, (ulong)header, NULL,

common/spl/spl.c static int spl_load_fit_image(struct spl_image_info *spl_image, · line 232

Quoted 10 lines
common/spl/spl.c +10 -0
+                                    &fit_uname_config, IH_ARCH_DEFAULT,
+                                    IH_TYPE_FIRMWARE, -1, FIT_LOAD_OPTIONAL,
+                                    &fw_data, &fw_len);
+       }
+
+       if (ret < 0) {
+               ret = fit_image_load(&images, (ulong)header, NULL,
+                                    &fit_uname_config, IH_ARCH_DEFAULT,
+                                    IH_TYPE_KERNEL, -1, FIT_LOAD_OPTIONAL,
+                                    &fw_data, &fw_len);

Should this only be for Falcon mode?

Quoted 8 lines
common/spl/spl.c +2 -1
+       }
+
        if (ret < 0)
                return ret;
 
--

2.26.2

Regards,
Simon

author
#12 lore raw

PATCH 4/6 spl: LOAD_FIT_FULL: Support 'kernel' and 'firmware' properties

Quoted 32 lines · Simon Glass

HI Alexandru,

Quoted 29 lines · Alexandru Gagniuc

The 'firmware' property of a config node takes precedence over the 'kernel' property. 'standalone' is deprecated. However, give users a couple of releases where 'standalone' still works, but warns loudly.

---
  common/spl/spl.c | 19 ++++++++++++++++++-
  1 file changed, 18 insertions(+), 1 deletion(-)
common/spl/spl.c +10 -1
index e63f05bb33..da4751b4ac 100644
@@ -214,7 +214,24 @@ static int spl_load_fit_image(struct spl_image_info *spl_image,
         ret = fit_image_load(&images, (ulong)header,
                              NULL, &fit_uname_config,
                              IH_ARCH_DEFAULT, IH_TYPE_STANDALONE, -1,
-                            FIT_LOAD_REQUIRED, &fw_data, &fw_len);
+                            FIT_LOAD_OPTIONAL, &fw_data, &fw_len);
+       if (ret >= 0) {
+               printf("DEPRECATED: 'standalone = ' property.");
+               printf("Please use either 'firmware =' or 'kernel ='\n");
+       } else {
+               ret = fit_image_load(&images, (ulong)header, NULL,
+                                    &fit_uname_config, IH_ARCH_DEFAULT,
+                                    IH_TYPE_FIRMWARE, -1, FIT_LOAD_OPTIONAL,
+                                    &fw_data, &fw_len);
+       }
Quoted 8 lines

common/spl/spl.c static int spl_load_fit_image(struct spl_image_info *spl_image, · line 232

Quoted 6 lines
common/spl/spl.c +6 -0
+
+       if (ret < 0) {
+               ret = fit_image_load(&images, (ulong)header, NULL,
+                                    &fit_uname_config, IH_ARCH_DEFAULT,
+                                    IH_TYPE_KERNEL, -1, FIT_LOAD_OPTIONAL,
+                                    &fw_data, &fw_len);

Should this only be for Falcon mode?

I don't know. Falcon mode relies on u-boot proper preparing an FDT and saving it to storage. Then the falcon boot reads the kernel image, and the "raw" FDT (see "spl export").

On the one hand, yes, because falcon mode loads kernels directly. On the other hand, no, because we're not using this prepared FDT.

There's a distinction between falcon mode and kernel boot from FIT. And it's very muddy. I'm hoping that people will stop using falcon mode with legacy images. Then and only then, we won't have to make this distinction.

Alex

Quoted 13 lines
Quoted 9 lines
common/spl/spl.c +2 -1
+       }
+
         if (ret < 0)
                 return ret;
 
--

2.26.2

Regards,
Simon

#13 lore raw

PATCH 5/6 image-fit: Accept IH_TYPE_FIRMWARE in fit_image_load() as valid

In reply to Alexandru Gagniuc

Consider the following FIT:

	images {
		whipple {};
	};
	configurations {
		conf-1 {
			firmware = "whipple";
		};
	};

Getting the 'firmware' image with fit_image_load() is not possible, as it doesn't understand 'firmware =' properties. Although one could pass IH_TYPE_FIRMWARE for 'image_type', this needs to be converted to a "firmware" string for FDT lookup -- exactly what this change does.

---
 common/image-fit.c | 2 ++
 1 file changed, 2 insertions(+)
common/image-fit.c +2 -0
index 28b3d2b191..8cd1621a18 100644
@@ -1955,6 +1955,8 @@ static const char *fit_get_image_type_property(int type)
 		return FIT_FDT_PROP;
 	case IH_TYPE_KERNEL:
 		return FIT_KERNEL_PROP;
+	case IH_TYPE_FIRMWARE:
+		return FIT_FIRMWARE_PROP;
 	case IH_TYPE_RAMDISK:
 		return FIT_RAMDISK_PROP;
 	case IH_TYPE_X86_SETUP:
Signature · 1 line
2.26.2
#14 lore raw

PATCH 5/6 image-fit: Accept IH_TYPE_FIRMWARE in fit_image_load() as valid

Quoted 17 lines · Alexandru Gagniuc

Consider the following FIT:

        images {
                whipple {};
        };
        configurations {
                conf-1 {
                        firmware = "whipple";
                };
        };

Getting the 'firmware' image with fit_image_load() is not possible, as it doesn't understand 'firmware =' properties. Although one could pass IH_TYPE_FIRMWARE for 'image_type', this needs to be converted to a "firmware" string for FDT lookup -- exactly what this change does.

Quoted 4 lines
---
 common/image-fit.c | 2 ++
 1 file changed, 2 insertions(+)
Quoted 17 lines
common/image-fit.c +2 -1
index 28b3d2b191..8cd1621a18 100644
@@ -1955,6 +1955,8 @@ static const char *fit_get_image_type_property(int type)
                return FIT_FDT_PROP;
        case IH_TYPE_KERNEL:
                return FIT_KERNEL_PROP;
+       case IH_TYPE_FIRMWARE:
+               return FIT_FIRMWARE_PROP;
        case IH_TYPE_RAMDISK:
                return FIT_RAMDISK_PROP;
        case IH_TYPE_X86_SETUP:
--

2.26.2

#15 lore raw

PATCH 6/6 image-fit: Accept OP-TEE images when booting a FIT

In reply to Alexandru Gagniuc

OP-TEE images are normally packaged with

	type = "tee;
	os = "tee";

However, fit_image_load() thinks that is somehow invalid. however if they were declared as type = "kernel", os = "linux", fit_image_load() would happily accept them and allow the boot to continue. There is no technical limitation to excluding "tee".

Allowing "tee" images is useful in a boot flow where OP-TEE is executed before linux.

In fact, I think it's unintuitive for a "load"ing function to also do parsing and contain a bunch ad-hoc heuristics that only its caller might know. But I don't make the rules, I just write fixes. In more polite terms: refactoring the fit_image API is beyond the scope of this change.

---
 common/image-fit.c | 2 ++
 1 file changed, 2 insertions(+)
common/image-fit.c +2 -0
index 8cd1621a18..31cb73a870 100644
@@ -2089,6 +2089,7 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
 	bootstage_mark(bootstage_id + BOOTSTAGE_SUB_CHECK_ALL);
 	type_ok = fit_image_check_type(fit, noffset, image_type) ||
 		  fit_image_check_type(fit, noffset, IH_TYPE_FIRMWARE) ||
+		  fit_image_check_type(fit, noffset, IH_TYPE_TEE) ||
 		  (image_type == IH_TYPE_KERNEL &&
 		   fit_image_check_type(fit, noffset, IH_TYPE_KERNEL_NOLOAD));
 
@@ -2096,6 +2097,7 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
 		image_type == IH_TYPE_FPGA ||
 		fit_image_check_os(fit, noffset, IH_OS_LINUX) ||
 		fit_image_check_os(fit, noffset, IH_OS_U_BOOT) ||
+		fit_image_check_os(fit, noffset, IH_OS_TEE) ||
 		fit_image_check_os(fit, noffset, IH_OS_OPENRTOS) ||
 		fit_image_check_os(fit, noffset, IH_OS_EFI) ||
 		fit_image_check_os(fit, noffset, IH_OS_VXWORKS);
Signature · 1 line
2.26.2
#16 lore raw

PATCH 6/6 image-fit: Accept OP-TEE images when booting a FIT

Quoted 19 lines · Alexandru Gagniuc

OP-TEE images are normally packaged with

        type = "tee;
        os = "tee";

However, fit_image_load() thinks that is somehow invalid. however if they were declared as type = "kernel", os = "linux", fit_image_load() would happily accept them and allow the boot to continue. There is no technical limitation to excluding "tee".

Allowing "tee" images is useful in a boot flow where OP-TEE is executed before linux.

In fact, I think it's unintuitive for a "load"ing function to also do parsing and contain a bunch ad-hoc heuristics that only its caller might know. But I don't make the rules, I just write fixes. In more polite terms: refactoring the fit_image API is beyond the scope of this change.

Quoted 4 lines
---
 common/image-fit.c | 2 ++
 1 file changed, 2 insertions(+)