3 @@ -259,6 +259,67 @@ U_BOOT_CMD(
4 /* iminfo - print header info for a requested image */
5 /*******************************************************************/
6 #if defined(CONFIG_CMD_IMI)
7 +#if defined(CONFIG_FIT)
8 +#define SECTOR_SHIFT 9
9 +static int image_totalsize(struct cmd_tbl *cmdtp, int flag, int argc,
10 + char *const argv[], short int in_blocks)
18 + addr = simple_strtoul(argv[1], NULL, 16);
20 + addr = image_load_addr;
22 + fit = (void *)map_sysmem(addr, 0);
23 + tsize = fit_get_totalsize(fit);
28 + bsize = (tsize >> SECTOR_SHIFT) + ((tsize & ((1 << SECTOR_SHIFT) - 1))?1:0);
31 + snprintf(buf, sizeof(buf), "%x", tsize);
33 + snprintf(buf, sizeof(buf), "%x", bsize);
36 + return env_set(argv[2], buf);
38 + printf("%s\n", buf);
43 +static int do_imsz(struct cmd_tbl *cmdtp, int flag, int argc,
46 + return image_totalsize(cmdtp, flag, argc, argv, 0);
49 +static int do_imszb(struct cmd_tbl *cmdtp, int flag, int argc,
52 + return image_totalsize(cmdtp, flag, argc, argv, 1);
56 + imsz, CONFIG_SYS_MAXARGS, 1, do_imsz,
57 + "get image total size (in bytes)",
58 + "addr [maxhdrlen] [varname]\n"
62 + imszb, CONFIG_SYS_MAXARGS, 1, do_imszb,
63 + "get image total size (in blocks)",
64 + "addr [maxhdrlen] [varname]\n"
68 static int do_iminfo(struct cmd_tbl *cmdtp, int flag, int argc,
71 --- a/boot/image-fit.c
72 +++ b/boot/image-fit.c
73 @@ -2051,6 +2051,47 @@ static const char *fit_get_image_type_pr
77 +size_t fit_get_totalsize(const void *fit)
79 + int ret, ndepth, noffset, images_noffset;
80 + size_t data_size, hdrsize, img_total, max_size = 0;
83 + ret = fdt_check_header(fit);
85 + debug("Wrong FIT format: not a flattened device tree (err=%d)\n",
90 + hdrsize = fdt_totalsize(fit);
92 + /* take care of simple FIT with internal images */
95 + images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH);
96 + if (images_noffset < 0)
100 + noffset = fdt_next_node(fit, images_noffset, &ndepth);
101 + (noffset >= 0) && (ndepth > 0);
102 + noffset = fdt_next_node(fit, noffset, &ndepth)) {
104 + ret = fit_image_get_data_and_size(fit, noffset, &data, &data_size);
108 + img_total = data_size + (data - fit);
110 + max_size = (max_size > img_total) ? max_size : img_total;
118 int fit_image_load(struct bootm_headers *images, ulong addr,
119 const char **fit_unamep, const char **fit_uname_configp,
120 int arch, int ph_type, int bootstage_id,
121 --- a/include/image.h
122 +++ b/include/image.h
123 @@ -1047,6 +1047,7 @@ int fit_parse_subimage(const char *spec,
124 ulong *addr, const char **image_name);
126 int fit_get_subimage_count(const void *fit, int images_noffset);
127 +size_t fit_get_totalsize(const void *fit);
128 void fit_print_contents(const void *fit);
129 void fit_image_print(const void *fit, int noffset, const char *p);