[U-Boot,31/53] binman: Write the original input fdtmap to a file
diff mbox series

Message ID 20190720182416.183626-32-sjg@chromium.org
State Accepted
Commit 96b6c506ca162b97ece5a59c0d2619173e6bfad8
Delegated to: Simon Glass
Headers show
Series
  • binman: Support replacing entries in an existing image
Related show

Commit Message

Simon Glass July 20, 2019, 6:23 p.m. UTC
When reading an image in, write its fdtmap to a file in the output
directory. This is useful for debugging. Update the 'ls' command to set up
the output directory; otherwise it will fail.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/binman/control.py | 6 +++++-
 tools/binman/image.py   | 5 ++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

Comments

Simon Glass July 29, 2019, 9:22 p.m. UTC | #1
When reading an image in, write its fdtmap to a file in the output
directory. This is useful for debugging. Update the 'ls' command to set up
the output directory; otherwise it will fail.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/binman/control.py | 6 +++++-
 tools/binman/image.py   | 5 ++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

Applied to u-boot-dm, thanks!

Patch
diff mbox series

diff --git a/tools/binman/control.py b/tools/binman/control.py
index ab94f9d4829..f9680e3948d 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -342,7 +342,11 @@  def Binman(args):
         return 0
 
     if args.cmd == 'ls':
-        ListEntries(args.image, args.paths)
+        try:
+            tools.PrepareOutputDir(None)
+            ListEntries(args.image, args.paths)
+        finally:
+            tools.FinaliseOutputDir()
         return 0
 
     if args.cmd == 'extract':
diff --git a/tools/binman/image.py b/tools/binman/image.py
index c81f7e3172e..893e8cb4cd5 100644
--- a/tools/binman/image.py
+++ b/tools/binman/image.py
@@ -94,7 +94,10 @@  class Image(section.Entry_section):
             data[pos + fdtmap.FDTMAP_HDR_LEN:pos + 256])
         dtb_size = probe_dtb.GetFdtObj().totalsize()
         fdtmap_data = data[pos:pos + dtb_size + fdtmap.FDTMAP_HDR_LEN]
-        dtb = fdt.Fdt.FromData(fdtmap_data[fdtmap.FDTMAP_HDR_LEN:])
+        fdt_data = fdtmap_data[fdtmap.FDTMAP_HDR_LEN:]
+        out_fname = tools.GetOutputFilename('fdtmap.in.dtb')
+        tools.WriteFile(out_fname, fdt_data)
+        dtb = fdt.Fdt.FromData(fdt_data, out_fname)
         dtb.Scan()
 
         # Return an Image with the associated nodes