Re: [U-Boot] [PATCH v2 26/31] binman: Support listing an image

2019-07-17 Thread sjg
Add support for listing the entries in an image. This relies on the image
having an FDT map.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Adjust the test to not rely on lz4 compression version
- Allow listing subsets of the image
- Change list command from 'list' to 'ls'
- Deal with travis's old lz4 version by skipping tests as necessary
- Move patch 'Add a comment about CBFS test structure' to earlier series
- Move patch 'Allow cbfstool to be optional with tests' to earlier series
- Update output from 'list' command
- Update test to use _DoReadFileRealDtb() helper

 tools/binman/README   |  44 +++-
 tools/binman/cmdline.py   |   6 ++
 tools/binman/control.py   |  35 ++
 tools/binman/ftest.py |  82 ++
 tools/binman/image.py | 150 ++
 tools/binman/test/130_list_fdtmap.dts |  36 +++
 6 files changed, 352 insertions(+), 1 deletion(-)
 create mode 100644 tools/binman/test/130_list_fdtmap.dts

Applied to u-boot-dm, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 26/31] binman: Support listing an image

2019-07-08 Thread Simon Glass
Add support for listing the entries in an image. This relies on the image
having an FDT map.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Adjust the test to not rely on lz4 compression version
- Allow listing subsets of the image
- Change list command from 'list' to 'ls'
- Deal with travis's old lz4 version by skipping tests as necessary
- Move patch 'Add a comment about CBFS test structure' to earlier series
- Move patch 'Allow cbfstool to be optional with tests' to earlier series
- Update output from 'list' command
- Update test to use _DoReadFileRealDtb() helper

 tools/binman/README   |  44 +++-
 tools/binman/cmdline.py   |   6 ++
 tools/binman/control.py   |  35 ++
 tools/binman/ftest.py |  82 ++
 tools/binman/image.py | 150 ++
 tools/binman/test/130_list_fdtmap.dts |  36 +++
 6 files changed, 352 insertions(+), 1 deletion(-)
 create mode 100644 tools/binman/test/130_list_fdtmap.dts

diff --git a/tools/binman/README b/tools/binman/README
index 9860633792f..146e0fd470a 100644
--- a/tools/binman/README
+++ b/tools/binman/README
@@ -490,6 +490,49 @@ see README.entries. This is generated from the source code 
using:
binman entry-docs >tools/binman/README.entries
 
 
+Listing images
+--
+
+It is possible to list the entries in an existing firmware image created by
+binman, provided that there is an 'fdtmap' entry in the image. For example:
+
+$ binman ls -i image.bin
+Name  Image-pos  Size  Entry-typeOffset  Uncomp-size
+--
+main-section  c00  section0
+  u-boot  0 4  u-boot 0
+  section 5fc  section4
+cbfs100   400  cbfs   0
+  u-boot138 4  u-boot38
+  u-boot-dtb180   108  u-boot-dtb80  3b5
+u-boot-dtb  500   1ff  u-boot-dtb   400  3b5
+  fdtmap6fc   381  fdtmap   6fc
+  image-header  bf8 8  image-header bf8
+
+This shows the hierarchy of the image, the position, size and type of each
+entry, the offset of each entry within its parent and the uncompressed size if
+the entry is compressed.
+
+It is also possible to list just some files in an image, e.g.
+
+$ binman ls -i image.bin section/cbfs
+Name  Image-pos  Size  Entry-type  Offset  Uncomp-size
+
+cbfs100   400  cbfs 0
+  u-boot138 4  u-boot  38
+  u-boot-dtb180   108  u-boot-dtb  80  3b5
+
+or with wildcards:
+
+$ binman ls -i image.bin "*cb*" "*head*"
+Name  Image-pos  Size  Entry-typeOffset  Uncomp-size
+--
+cbfs100   400  cbfs   0
+  u-boot138 4  u-boot38
+  u-boot-dtb180   108  u-boot-dtb80  3b5
+  image-header  bf8 8  image-header bf8
+
+
 Hashing Entries
 ---
 
@@ -825,7 +868,6 @@ Some ideas:
 - Add an option to decode an image into the constituent binaries
 - Support building an image for a board (-b) more completely, with a
   configurable build directory
-- Support listing files in images
 - Support logging of binman's operations, with different levels of verbosity
 - Support updating binaries in an image (with no size change / repacking)
 - Support updating binaries in an image (with repacking)
diff --git a/tools/binman/cmdline.py b/tools/binman/cmdline.py
index a002105fc77..508232eabb5 100644
--- a/tools/binman/cmdline.py
+++ b/tools/binman/cmdline.py
@@ -65,6 +65,12 @@ controlled by a description in the board device tree.'''
 entry_parser = subparsers.add_parser('entry-docs',
 help='Write out entry documentation (see README.entries)')
 
+list_parser = subparsers.add_parser('ls', help='List files in an image')
+list_parser.add_argument('-i', '--image', type=str, required=True,
+ help='Image filename to list')
+list_parser.add_argument('paths', type=str, nargs='*',
+ help='Paths within file to list (wildcard)')
+
 test_parser = subparsers.add_parser('test', help='Run tests')
 test_parser.add_argument('-P', '--processes', type=int,
 help='set number of processes to use for running tests')
diff --git a/tools/binman/control.py b/tools/binman/control.py
index 35faf115062..813c8b1bf9e 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -67,6 +67,37 @@ def WriteEntryDocs(modules, test_missing=None):
 fro