1 // SPDX-License-Identifier: GPL-2.0+
4 * DENX Software Engineering
5 * Heiko Schocher <hs@denx.de>
7 * fit_info: print the offset and the len of a property from
11 * (C) Copyright 2008 Semihalf
13 * (C) Copyright 2000-2004
14 * DENX Software Engineering
15 * Wolfgang Denk, wd@denx.de
17 * Updated-by: Prafulla Wadaskar <prafulla@marvell.com>
18 * FIT image specific code abstracted from mkimage.c
19 * some functions added to address abstraction
21 * All rights reserved.
25 #include "fit_common.h"
27 #include <u-boot/crc.h>
29 void usage(char *cmdname)
31 fprintf(stderr, "Usage: %s -f fit file -n node -p property\n"
32 " -f ==> set fit file which is used'\n"
33 " -n ==> set node name'\n"
34 " -p ==> set property name'\n",
39 int main(int argc, char **argv)
45 int nodeoffset; /* node offset from libfdt */
46 const void *nodep; /* property node pointer */
48 char *nodename = NULL;
49 char *propertyname = NULL;
53 strncpy(cmdname, *argv, sizeof(cmdname) - 1);
54 cmdname[sizeof(cmdname) - 1] = '\0';
55 while ((c = getopt(argc, argv, "f:n:p:")) != -1)
64 propertyname = optarg;
72 fprintf(stderr, "%s: Missing fdt file\n", *argv);
76 fprintf(stderr, "%s: Missing node name\n", *argv);
80 fprintf(stderr, "%s: Missing property name\n", *argv);
83 ffd = mmap_fdt(cmdname, fdtfile, 0, &fit_blob, &fsbuf, false, false);
86 printf("Could not open %s\n", fdtfile);
90 nodeoffset = fdt_path_offset(fit_blob, nodename);
92 printf("%s not found.", nodename);
95 nodep = fdt_getprop(fit_blob, nodeoffset, propertyname, &len);
97 printf("len == 0 %s\n", propertyname);
101 printf("NAME: %s\n", fit_get_name(fit_blob, nodeoffset, NULL));
102 printf("LEN: %d\n", len);
103 printf("OFF: %d\n", (int)(nodep - fit_blob));
104 (void) munmap((void *)fit_blob, fsbuf.st_size);