summaryrefslogtreecommitdiffstats
path: root/common/bootm.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-02-25 13:28:54 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2016-02-25 13:29:05 +0100
commitfc5af2afc5d538c6d5820188043893fc1be40565 (patch)
tree8e64b7d4361be05340eaed5823174f4cd1ef4e85 /common/bootm.c
parent051b39f683662207d22d274975bf53758989907d (diff)
downloadbarebox-fc5af2afc5d538c6d5820188043893fc1be40565.tar.gz
bootm: Fix booting uImages
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@pengutronix.de>
Diffstat (limited to 'common/bootm.c')
-rw-r--r--common/bootm.c18
1 files 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)