Skip to content

Commit

Permalink
uboot-mediatek: fix determine the size of an uImage.FIT using 'imsz' …
Browse files Browse the repository at this point in the history
…or 'imszb'.

It must read the entire image for previous code of 'imsz' or 'imszb'.

Signed-off-by: Jianhui Zhao <[email protected]>
Suggested-by: Chuanhong Guo <[email protected]>
(cherry picked from commit 3bbc1d5)
  • Loading branch information
zhaojh329 authored and dangowrt committed Oct 31, 2023
1 parent 89184b1 commit 1157b8c
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
{
--- a/boot/image-fit.c
+++ b/boot/image-fit.c
@@ -2051,6 +2051,49 @@ static const char *fit_get_image_type_pr
@@ -2051,6 +2051,47 @@ static const char *fit_get_image_type_pr
return "unknown";
}

Expand All @@ -93,11 +93,8 @@
+ max_size = hdrsize;
+
+ images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH);
+ if (images_noffset < 0) {
+ printf("Can't find images parent node '%s' (%s)\n",
+ FIT_IMAGES_PATH, fdt_strerror(images_noffset));
+ return 0;
+ }
+ if (images_noffset < 0)
+ goto out;
+
+ for (ndepth = 0,
+ noffset = fdt_next_node(fit, images_noffset, &ndepth);
Expand All @@ -106,14 +103,15 @@
+ if (ndepth == 1) {
+ ret = fit_image_get_data_and_size(fit, noffset, &data, &data_size);
+ if (ret)
+ return 0;
+ goto out;
+
+ img_total = data_size + (data - fit);
+
+ max_size = (max_size > img_total) ? max_size : img_total;
+ }
+ }
+
+out:
+ return max_size;
+}
+
Expand Down

0 comments on commit 1157b8c

Please sign in to comment.