diff options
author | Tom Rini <trini@ti.com> | 2014-04-17 14:33:25 -0400 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2014-04-17 14:33:25 -0400 |
commit | 0f507779ca00d90cdd4bcc8252630370339b7ea6 (patch) | |
tree | a91a89ac67dcbd42c8a4357501d155a129fa1e5a /tools/fit_info.c | |
parent | 0f605c1501f6e82553e9affc6e17876a85db408c (diff) | |
parent | ece0d370144fdecb6f3ed5738ffe96f5b12f9e96 (diff) | |
download | u-boot-imx-0f507779ca00d90cdd4bcc8252630370339b7ea6.zip u-boot-imx-0f507779ca00d90cdd4bcc8252630370339b7ea6.tar.gz u-boot-imx-0f507779ca00d90cdd4bcc8252630370339b7ea6.tar.bz2 |
Merge branch 'next'
Diffstat (limited to 'tools/fit_info.c')
-rw-r--r-- | tools/fit_info.c | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/tools/fit_info.c b/tools/fit_info.c new file mode 100644 index 0000000..50f3c8e --- /dev/null +++ b/tools/fit_info.c @@ -0,0 +1,96 @@ +/* + * (C) Copyright 2014 + * DENX Software Engineering + * Heiko Schocher <hs@denx.de> + * + * fit_info: print the offset and the len of a property from + * node in a fit file. + * + * Based on: + * (C) Copyright 2008 Semihalf + * + * (C) Copyright 2000-2004 + * DENX Software Engineering + * Wolfgang Denk, wd@denx.de + * + * Updated-by: Prafulla Wadaskar <prafulla@marvell.com> + * FIT image specific code abstracted from mkimage.c + * some functions added to address abstraction + * + * All rights reserved. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include "mkimage.h" +#include "fit_common.h" +#include <image.h> +#include <u-boot/crc.h> + +void usage(char *cmdname) +{ + fprintf(stderr, "Usage: %s -f fit file -n node -p property\n" + " -f ==> set fit file which is used'\n" + " -n ==> set node name'\n" + " -p ==> set property name'\n", + cmdname); + exit(EXIT_FAILURE); +} + +int main(int argc, char **argv) +{ + int ffd = -1; + struct stat fsbuf; + void *fit_blob; + int len; + int nodeoffset; /* node offset from libfdt */ + const void *nodep; /* property node pointer */ + char *fdtfile = NULL; + char *nodename = NULL; + char *propertyname = NULL; + char cmdname[50]; + int c; + + strcpy(cmdname, *argv); + while ((c = getopt(argc, argv, "f:n:p:")) != -1) + switch (c) { + case 'f': + fdtfile = optarg; + break; + case 'n': + nodename = optarg; + break; + case 'p': + propertyname = optarg; + break; + default: + usage(cmdname); + break; + } + + ffd = mmap_fdt(cmdname, fdtfile, &fit_blob, &fsbuf, 0); + + if (ffd < 0) { + printf("Could not open %s\n", fdtfile); + exit(EXIT_FAILURE); + } + + nodeoffset = fdt_path_offset(fit_blob, nodename); + if (nodeoffset < 0) { + printf("%s not found.", nodename); + exit(EXIT_FAILURE); + } + nodep = fdt_getprop(fit_blob, nodeoffset, propertyname, &len); + if (len == 0) { + printf("len == 0 %s\n", propertyname); + exit(EXIT_FAILURE); + } + + printf("NAME: %s\n", fit_get_name(fit_blob, nodeoffset, NULL)); + printf("LEN: %d\n", len); + printf("OFF: %d\n", (int)(nodep - fit_blob)); + (void) munmap((void *)fit_blob, fsbuf.st_size); + + close(ffd); + exit(EXIT_SUCCESS); +} |