binman: Write the original input fdtmap to a file
authorSimon Glass <sjg@chromium.org>
Sat, 20 Jul 2019 18:23:53 +0000 (12:23 -0600)
committerSimon Glass <sjg@chromium.org>
Mon, 29 Jul 2019 15:38:06 +0000 (09:38 -0600)
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
tools/binman/image.py

index ab94f9d4829748325ee04c0b30cd8e6a350578a3..f9680e3948d2c8465d6c3e3adeeeb749c619f373 100644 (file)
@@ -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':
index c81f7e3172ec9382b954299342392720784ca586..893e8cb4cd5b93652f08a0f6395590d408bfbb98 100644 (file)
@@ -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