[PATCH] bootm: Fix booting uImages

Sascha Hauer s.hauer at pengutronix.de
Thu Feb 25 04:32:57 PST 2016


This fixes:
0a37e22d (bootm: use names instead of numbers for image parts)

This commit switches to strings for the image numbers for better FIT
image support (which uses names instead of numbers). These strings
may be NULL when no image number is given. They are used uninitialzed
in several places. Introduce a wrapper function to convert the string
into a number. Check for NULL here in which case we return 0 which
is the correct value.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 common/bootm.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 7d00f8e..6d22aab 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -75,6 +75,13 @@ static const char * const bootm_verify_names[] = {
 	[BOOTM_VERIFY_SIGNATURE] = "signature",
 };
 
+static int uimage_part_num(const char *partname)
+{
+	if (!partname)
+		return 0;
+	return simple_strtoul(partname, NULL, 0);
+}
+
 /*
  * bootm_load_os() - load OS to RAM
  *
@@ -109,7 +116,7 @@ int bootm_load_os(struct image_data *data, unsigned long load_address)
 	if (data->os) {
 		int num;
 
-		num = simple_strtoul(data->os_part, NULL, 0);
+		num = uimage_part_num(data->os_part);
 
 		data->os_res = uimage_load_to_sdram(data->os,
 			num, load_address);
@@ -224,7 +231,7 @@ int bootm_load_initrd(struct image_data *data, unsigned long load_address)
 			return ret;
 		}
 
-		num = simple_strtoul(data->initrd_part, NULL, 0);
+		num = uimage_part_num(data->initrd_part);
 
 		data->initrd_res = uimage_load_to_sdram(data->initrd,
 			num, load_address);
@@ -258,7 +265,7 @@ static int bootm_open_oftree_uimage(struct image_data *data, size_t *size,
 {
 	enum filetype ft;
 	const char *oftree = data->oftree_file;
-	int num = simple_strtoul(data->oftree_part, NULL, 0);
+	int num = uimage_part_num(data->oftree_part);
 	struct uimage_handle *of_handle;
 	int release = 0;
 
@@ -407,8 +414,7 @@ int bootm_get_os_size(struct image_data *data)
 	int ret;
 
 	if (data->os)
-		return uimage_get_size(data->os,
-				       simple_strtoul(data->os_part, NULL, 0));
+		return uimage_get_size(data->os, uimage_part_num(data->os_part));
 	if (data->os_fit)
 		return data->os_fit->kernel_size;
 
@@ -574,7 +580,7 @@ int bootm_boot(struct bootm_data *bootm_data)
 			data->os_file);
 	if (os_type == filetype_uimage &&
 			data->os->header.ih_type == IH_TYPE_MULTI)
-		printf(", multifile image %s", data->os_part);
+		printf(", multifile image %d", uimage_part_num(data->os_part));
 	printf("\n");
 
 	if (data->os_address == UIMAGE_SOME_ADDRESS)
-- 
2.7.0




More information about the barebox mailing list