Skip to contentSkip to conversation

common: spl_fit: Allow firmware image if no loadables

PATCH Superseded Abel Vesa 2 participants 3 messages Mar 10, 2019

lore
Share & tools
lore

Abel Vesa

author
#0 lore raw

PATCH v2 1/1 common: spl_fit: Allow firmware image if no loadables

If CONFIG_SPL_OS_BOOT and FIT_IMAGE_TINY are enabled, the os will not be set to anything and therefore will remain as IH_OS_INVALID. What's needed here is to have IH_OS_U_BOOT as default. And since using the mkimage oneline command (that is, no its file), the loadables can't be specified, so we allow firmware as a fallback.

---

Changes since v1:
* added braces to get rid of the build warning

 common/spl/spl_fit.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
common/spl/spl_fit.c +7 -3
index db43626..bfcf71a 100644
@@ -478,11 +478,15 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
 
 	/* Now check if there are more images for us to load */
 	for (; ; index++) {
-		uint8_t os_type = IH_OS_INVALID;
+		uint8_t os_type = IH_OS_U_BOOT;
 
 		node = spl_fit_get_image_node(fit, images, "loadables", index);
-		if (node < 0)
-			break;
+		if (node < 0) {
+			node = spl_fit_get_image_node(fit, images,
+						      "firmware", index);
+			if (node < 0)
+				break;
+		}
 
 		ret = spl_load_fit_image(info, sector, fit, base_offset, node,
 					 &image_info);
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/1 common: spl_fit: Allow firmware image if no loadables

Quoted 7 lines · Abel Vesa

If CONFIG_SPL_OS_BOOT and FIT_IMAGE_TINY are enabled, the os will not be set to anything and therefore will remain as IH_OS_INVALID. What's needed here is to have IH_OS_U_BOOT as default. And since using the mkimage oneline command (that is, no its file), the loadables can't be specified, so we allow firmware as a fallback.

Wouldn't it make more sense to fix the mkimage ?

Quoted 15 lines

---

Changes since v1:
* added braces to get rid of the build warning

 common/spl/spl_fit.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
common/spl/spl_fit.c +0 -0
index db43626..bfcf71a 100644

common/spl/spl_fit.c int spl_load_simple_fit(struct spl_image_info *spl_image, · line 481

Quoted 5 lines
common/spl/spl_fit.c +1 -1
@@ -478,11 +478,15 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
 
 	/* Now check if there are more images for us to load */
 	for (; ; index++) {
-		uint8_t os_type = IH_OS_INVALID;
+		uint8_t os_type = IH_OS_U_BOOT;

Does that mean invalid image type is then always handled as if it was U-Boot ? That looks kinda iffy.

Quoted 13 lines
common/spl/spl_fit.c +6 -2
 		node = spl_fit_get_image_node(fit, images, "loadables", index);
-		if (node < 0)
-			break;
+		if (node < 0) {
+			node = spl_fit_get_image_node(fit, images,
+						      "firmware", index);
+			if (node < 0)
+				break;
+		}
 
 		ret = spl_load_fit_image(info, sector, fit, base_offset, node,
 					 &image_info);
 
Signature · 2 lines
Best regards,
Marek Vasut
author
#2 lore raw

PATCH v2 1/1 common: spl_fit: Allow firmware image if no loadables

Quoted 11 lines · Marek Vasut
Quoted 7 lines · Abel Vesa

If CONFIG_SPL_OS_BOOT and FIT_IMAGE_TINY are enabled, the os will not be set to anything and therefore will remain as IH_OS_INVALID. What's needed here is to have IH_OS_U_BOOT as default. And since using the mkimage oneline command (that is, no its file), the loadables can't be specified, so we allow firmware as a fallback.

Wouldn't it make more sense to fix the mkimage ?

OK then, I'll add a new option to mkimage for loadables.

Quoted 16 lines
Quoted 16 lines

---

Changes since v1:
* added braces to get rid of the build warning

 common/spl/spl_fit.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
common/spl/spl_fit.c +0 -0
index db43626..bfcf71a 100644
@@ -478,11 +478,15 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
 
Quoted 8 lines

common/spl/spl_fit.c int spl_load_simple_fit(struct spl_image_info *spl_image, · line 481

Quoted 4 lines
common/spl/spl_fit.c +1 -1
 	/* Now check if there are more images for us to load */
 	for (; ; index++) {
-		uint8_t os_type = IH_OS_INVALID;
+		uint8_t os_type = IH_OS_U_BOOT;

Does that mean invalid image type is then always handled as if it was U-Boot ? That looks kinda iffy.

Hmm, fair enough. I'll do the fix in mkimage and this change won't be necessary then.

Quoted 18 lines
Quoted 13 lines
common/spl/spl_fit.c +6 -2
 		node = spl_fit_get_image_node(fit, images, "loadables", index);
-		if (node < 0)
-			break;
+		if (node < 0) {
+			node = spl_fit_get_image_node(fit, images,
+						      "firmware", index);
+			if (node < 0)
+				break;
+		}
 
 		ret = spl_load_fit_image(info, sector, fit, base_offset, node,
 					 &image_info);
 
Signature · 2 lines
Best regards,
Marek Vasut