Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions inc/fdt.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ typedef uint16_t fdt16_t;
typedef uint32_t fdt32_t;
typedef uint64_t fdt64_t;

#define NUM_IMGS 0x5
#define NUM_IMGS 0x8

#define FDT_TAGSIZE sizeof(fdt32_t)

Expand Down Expand Up @@ -320,7 +320,7 @@ const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
const char *name, int namelen, int *lenp);
const char *fdt_get_alias_namelen(const void *fdt,
const char *name, int namelen);
int parse_fdt(fdt_header_t *fit, image_block_t *images);
int parse_fdt(fdt_header_t *fit, image_block_t *images, unsigned image_slots);
int32_t fdt_ro_probe_(const void *fdt);
int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen);
int fdt_path_offset(const void *fdt, const char *path);
Expand Down
3 changes: 2 additions & 1 deletion src/cst_signer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,8 @@ static int process_fdt_images(unsigned long off, uint8_t *infile_buf,
* g_images + 1 contains all the Images from FIT:
* Image 0 (uboot@1),Image 1 (fdt@1) ,Image 2 (atf@1)
*/
err = parse_fdt(fit_img, &g_images[1]);
err = parse_fdt(fit_img, &g_images[1],
sizeof(g_images) / sizeof(g_images[0]) - 1);
if (err) {
errno = EFAULT;
fprintf(stderr, "Could not parse FIT image %s\n", strerror(EFAULT));
Expand Down
22 changes: 14 additions & 8 deletions src/fdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ int fit_image_get_load(const void *fit, int noffset, unsigned long *load)



int parse_fdt(fdt_header_t *fit, image_block_t *images)
int parse_fdt(fdt_header_t *fit, image_block_t *images, unsigned image_slots)
{
int images_noffset;
int noffset;
Expand All @@ -842,26 +842,32 @@ int parse_fdt(fdt_header_t *fit, image_block_t *images)
}

/* Process its subnodes, print out component images details */
for (ndepth = 0, count = 0,
noffset = fdt_next_node(fit, images_noffset, &ndepth);
for (ndepth = 0,
noffset = fdt_next_node(fit, images_noffset, &ndepth);
(noffset >= 0) && (ndepth > 0);
noffset = fdt_next_node(fit, noffset, &ndepth)) {
if (ndepth == 1) {
const void *data;
images->valid = true;
if (count >= image_slots) {
if (g_fdt_debug) {
printf("Can't allocate FDT node, images slots are full\n");
}
return -1;
}
images[count].valid = true;

if (g_fdt_debug) {
/*
* Direct child node of the images parent node,
* i.e. component image node.
*/
printf("%s Image %u (%s)\n", p, count++,
printf("%s Image %u (%s)\n", p, count,
fit_get_name(fit, noffset, NULL));
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
ret = fit_image_get_data_and_size(fit, noffset, &data,
&images->size);
&images[count].size);
#pragma GCC diagnostic pop
if (g_fdt_debug) {
if(ret)
Expand All @@ -870,13 +876,13 @@ int parse_fdt(fdt_header_t *fit, image_block_t *images)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
ret = fit_image_get_load(fit, noffset,
&images->load_addr);
&images[count].load_addr);
#pragma GCC diagnostic pop
if (g_fdt_debug) {
if(ret)
printf("Could not get image address\n");
}
images++;
count++;
}
}
return 0;
Expand Down