summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-04-06 11:51:00 -0400
committerTom Rini <trini@konsulko.com>2022-04-06 11:51:00 -0400
commit88b6b33253ce4443f23e54ef5424eeb90482ae75 (patch)
tree53172e01fd260c3e8c612429a7893b44a5953f90 /tools
parent59bffec43a657598b194b9eb30dc01eec06078c7 (diff)
parentd23f29084018a3aa5ca6399a08c12eb7617ffa55 (diff)
Merge branch '2022-04-06-assorted-updates'
- Add DM_PMIC support to TPS65217 and migrate some platforms to it. - mkimage verification fixes - DM rST fix, add missing flag when linking u-boot-elf.o
Diffstat (limited to 'tools')
-rw-r--r--tools/mkimage.c41
-rw-r--r--tools/rkcommon.c4
2 files changed, 45 insertions, 0 deletions
diff --git a/tools/mkimage.c b/tools/mkimage.c
index b46216fdc59..be58e565463 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -341,6 +341,44 @@ static void process_args(int argc, char **argv)
usage("Missing output filename");
}
+static void verify_image(const struct image_type_params *tparams)
+{
+ struct stat sbuf;
+ void *ptr;
+ int ifd;
+
+ ifd = open(params.imagefile, O_RDONLY | O_BINARY);
+ if (ifd < 0) {
+ fprintf(stderr, "%s: Can't open %s: %s\n",
+ params.cmdname, params.imagefile,
+ strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+
+ if (fstat(ifd, &sbuf) < 0) {
+ fprintf(stderr, "%s: Can't stat %s: %s\n",
+ params.cmdname, params.imagefile, strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ params.file_size = sbuf.st_size;
+
+ ptr = mmap(0, params.file_size, PROT_READ, MAP_SHARED, ifd, 0);
+ if (ptr == MAP_FAILED) {
+ fprintf(stderr, "%s: Can't map %s: %s\n",
+ params.cmdname, params.imagefile, strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+
+ if (tparams->verify_header((unsigned char *)ptr, params.file_size, &params) != 0) {
+ fprintf(stderr, "%s: Failed to verify header of %s\n",
+ params.cmdname, params.imagefile);
+ exit(EXIT_FAILURE);
+ }
+
+ (void)munmap(ptr, params.file_size);
+ (void)close(ifd);
+}
+
int main(int argc, char **argv)
{
int ifd = -1;
@@ -703,6 +741,9 @@ int main(int argc, char **argv)
exit (EXIT_FAILURE);
}
+ if (tparams->verify_header)
+ verify_image(tparams);
+
exit (EXIT_SUCCESS);
}
diff --git a/tools/rkcommon.c b/tools/rkcommon.c
index 29f2676c19d..ff62c75caad 100644
--- a/tools/rkcommon.c
+++ b/tools/rkcommon.c
@@ -450,6 +450,10 @@ int rkcommon_verify_header(unsigned char *buf, int size,
struct spl_info *img_spl_info, *spl_info;
int ret;
+ /* spl_hdr is abandon on header_v2 */
+ if ((*(uint32_t *)buf) == RK_MAGIC_V2)
+ return 0;
+
ret = rkcommon_parse_header(buf, &header0, &img_spl_info);
/* If this is the (unimplemented) RC4 case, then rewrite the result */