Fork of the vendor (Boundary Devices) u-boot for Reform 2, with minor tweaks. The goal is to migrate to mainstream u-boot or barebox ASAP. The main impediment so far is the 4GB RAM config.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 
 
 

110 lines
2.4 KiB

  1. /*
  2. * (C) Copyright 2014
  3. * DENX Software Engineering
  4. * Heiko Schocher <hs@denx.de>
  5. *
  6. * fit_info: print the offset and the len of a property from
  7. * node in a fit file.
  8. *
  9. * Based on:
  10. * (C) Copyright 2008 Semihalf
  11. *
  12. * (C) Copyright 2000-2004
  13. * DENX Software Engineering
  14. * Wolfgang Denk, wd@denx.de
  15. *
  16. * Updated-by: Prafulla Wadaskar <prafulla@marvell.com>
  17. * FIT image specific code abstracted from mkimage.c
  18. * some functions added to address abstraction
  19. *
  20. * All rights reserved.
  21. *
  22. * SPDX-License-Identifier: GPL-2.0+
  23. */
  24. #include "mkimage.h"
  25. #include "fit_common.h"
  26. #include <image.h>
  27. #include <u-boot/crc.h>
  28. void usage(char *cmdname)
  29. {
  30. fprintf(stderr, "Usage: %s -f fit file -n node -p property\n"
  31. " -f ==> set fit file which is used'\n"
  32. " -n ==> set node name'\n"
  33. " -p ==> set property name'\n",
  34. cmdname);
  35. exit(EXIT_FAILURE);
  36. }
  37. int main(int argc, char **argv)
  38. {
  39. int ffd = -1;
  40. struct stat fsbuf;
  41. void *fit_blob;
  42. int len;
  43. int nodeoffset; /* node offset from libfdt */
  44. const void *nodep; /* property node pointer */
  45. char *fdtfile = NULL;
  46. char *nodename = NULL;
  47. char *propertyname = NULL;
  48. char cmdname[256];
  49. int c;
  50. strncpy(cmdname, *argv, sizeof(cmdname) - 1);
  51. cmdname[sizeof(cmdname) - 1] = '\0';
  52. while ((c = getopt(argc, argv, "f:n:p:")) != -1)
  53. switch (c) {
  54. case 'f':
  55. fdtfile = optarg;
  56. break;
  57. case 'n':
  58. nodename = optarg;
  59. break;
  60. case 'p':
  61. propertyname = optarg;
  62. break;
  63. default:
  64. usage(cmdname);
  65. break;
  66. }
  67. if (!fdtfile) {
  68. fprintf(stderr, "%s: Missing fdt file\n", *argv);
  69. usage(*argv);
  70. }
  71. if (!nodename) {
  72. fprintf(stderr, "%s: Missing node name\n", *argv);
  73. usage(*argv);
  74. }
  75. if (!propertyname) {
  76. fprintf(stderr, "%s: Missing property name\n", *argv);
  77. usage(*argv);
  78. }
  79. ffd = mmap_fdt(cmdname, fdtfile, 0, &fit_blob, &fsbuf, false);
  80. if (ffd < 0) {
  81. printf("Could not open %s\n", fdtfile);
  82. exit(EXIT_FAILURE);
  83. }
  84. nodeoffset = fdt_path_offset(fit_blob, nodename);
  85. if (nodeoffset < 0) {
  86. printf("%s not found.", nodename);
  87. exit(EXIT_FAILURE);
  88. }
  89. nodep = fdt_getprop(fit_blob, nodeoffset, propertyname, &len);
  90. if (len == 0) {
  91. printf("len == 0 %s\n", propertyname);
  92. exit(EXIT_FAILURE);
  93. }
  94. printf("NAME: %s\n", fit_get_name(fit_blob, nodeoffset, NULL));
  95. printf("LEN: %d\n", len);
  96. printf("OFF: %d\n", (int)(nodep - fit_blob));
  97. (void) munmap((void *)fit_blob, fsbuf.st_size);
  98. close(ffd);
  99. exit(EXIT_SUCCESS);
  100. }