From 1f338e00fa81e72380c788163fc3c63939bf5eea Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 25 Sep 2019 08:11:11 -0600 Subject: binman: Allow selection of logging verbosity Support a new BINMAN_VERBOSE option to the build, to allow passing the -v flag to binman. Signed-off-by: Simon Glass Reviewed-by: Bin Meng Tested-by: Bin Meng --- tools/binman/README | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tools') diff --git a/tools/binman/README b/tools/binman/README index b4f6392ab7..8e0f0a8c55 100644 --- a/tools/binman/README +++ b/tools/binman/README @@ -934,6 +934,12 @@ BINMAN_DEBUG=1 to your build: make sandbox_defconfig make BINMAN_DEBUG=1 +To enable verbose logging from binman, base BINMAN_VERBOSE to your build, which +adds a -v option to the call to binman: + + make sandbox_defconfig + make BINMAN_VERBOSE=5 + History / Credits ----------------- -- cgit From 7bc4f0f88327bcd3c2daafe969f049dcfab41b00 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 15 Sep 2019 18:10:36 -0600 Subject: binman: Allow verbose output with all commands At present the verbose flag only works for the 'build' command. This is not intended, nor is it useful. Update the code to support the verbose flag and make use of a command exception handler. Signed-off-by: Simon Glass Reviewed-by: Bin Meng [bmeng: rebase the patch against u-boot-x86/next to get it applied cleanly] Signed-off-by: Bin Meng --- tools/binman/control.py | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) (limited to 'tools') diff --git a/tools/binman/control.py b/tools/binman/control.py index 9e7587864c..cb51bc2dd4 100644 --- a/tools/binman/control.py +++ b/tools/binman/control.py @@ -468,29 +468,23 @@ def Binman(args): command.Run(pager, fname) return 0 - if args.cmd == 'ls': + if args.cmd in ['ls', 'extract', 'replace']: try: + tout.Init(args.verbosity) tools.PrepareOutputDir(None) - ListEntries(args.image, args.paths) - finally: - tools.FinaliseOutputDir() - return 0 - - if args.cmd == 'extract': - try: - tools.PrepareOutputDir(None) - ExtractEntries(args.image, args.filename, args.outdir, args.paths, - not args.uncompressed) - finally: - tools.FinaliseOutputDir() - return 0 - - if args.cmd == 'replace': - try: - tools.PrepareOutputDir(None) - ReplaceEntries(args.image, args.filename, args.indir, args.paths, - do_compress=not args.compressed, - allow_resize=not args.fix_size, write_map=args.map) + if args.cmd == 'ls': + ListEntries(args.image, args.paths) + + if args.cmd == 'extract': + ExtractEntries(args.image, args.filename, args.outdir, args.paths, + not args.uncompressed) + + if args.cmd == 'replace': + ReplaceEntries(args.image, args.filename, args.indir, args.paths, + do_compress=not args.compressed, + allow_resize=not args.fix_size, write_map=args.map) + except: + raise finally: tools.FinaliseOutputDir() return 0 -- cgit From 4e185e8dd7aa3ff7618d228ebfaffb507a569c07 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 25 Sep 2019 08:56:20 -0600 Subject: binman: Add a base implementation of Entry.ReadChildData() At present this function is not present in the Entry base class so it is hard to find the documentation for it. Move the docs from the section class and expand it a little. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- tools/binman/entry.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tools') diff --git a/tools/binman/entry.py b/tools/binman/entry.py index 6a2c6e0d92..f2f1b967a4 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -717,6 +717,22 @@ features to produce new behaviours. data = self.section.ReadChildData(self, decomp) return data + def ReadChildData(self, child, decomp=True): + """Read the data for a particular child + + This reads data from the parent and extracts the piece that relates to + the given child. + + Args: + child: Child to read (must be valid) + decomp: True to decompress any compressed data before returning it; + False to return the raw, uncompressed data + + Returns: + Data for the child (bytes) + """ + pass + def LoadData(self, decomp=True): data = self.ReadData(decomp) self.contents_size = len(data) -- cgit From 2d553c006d46653f3e0367cc5bfe36a9c7128eb5 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 25 Sep 2019 08:56:21 -0600 Subject: binman: Handle reading data for end-at-4gb sections Some x86 sections have special offsets which currently result in empty data being returned from the 'extract' command. Fix this by taking account of the skip-at-start property. Add a little more debugging while we are here. Signed-off-by: Simon Glass Acked-by: Bin Meng --- tools/binman/entry.py | 6 ++++-- tools/binman/etype/section.py | 16 +++++----------- tools/binman/image.py | 2 ++ 3 files changed, 11 insertions(+), 13 deletions(-) (limited to 'tools') diff --git a/tools/binman/entry.py b/tools/binman/entry.py index f2f1b967a4..fe8e1dd8a5 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -714,17 +714,19 @@ features to produce new behaviours. """ # Use True here so that we get an uncompressed section to work from, # although compressed sections are currently not supported + tout.Debug("ReadChildData section '%s', entry '%s'" % + (self.section.GetPath(), self.GetPath())) data = self.section.ReadChildData(self, decomp) return data def ReadChildData(self, child, decomp=True): - """Read the data for a particular child + """Read the data for a particular child entry This reads data from the parent and extracts the piece that relates to the given child. Args: - child: Child to read (must be valid) + child: Child entry to read data for (must be valid) decomp: True to decompress any compressed data before returning it; False to return the raw, uncompressed data diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py index 5d34fc546a..8179daf562 100644 --- a/tools/binman/etype/section.py +++ b/tools/binman/etype/section.py @@ -500,18 +500,12 @@ class Entry_section(Entry): return data def ReadChildData(self, child, decomp=True): - """Read the data for a particular child entry - - Args: - child: Child entry to read data for - decomp: True to return uncompressed data, False to leave the data - compressed if it is compressed - - Returns: - Data contents of entry - """ + tout.Debug("ReadChildData for child '%s'" % child.GetPath()) parent_data = self.ReadData(True) - data = parent_data[child.offset:child.offset + child.size] + offset = child.offset - self._skip_at_start + tout.Debug("Extract for child '%s': offset %#x, skip_at_start %#x, result %#x" % + (child.GetPath(), child.offset, self._skip_at_start, offset)) + data = parent_data[offset:offset + child.size] if decomp: indata = data data = tools.Decompress(indata, child.compress) diff --git a/tools/binman/image.py b/tools/binman/image.py index 7b39a1ddce..2beab7fd4d 100644 --- a/tools/binman/image.py +++ b/tools/binman/image.py @@ -201,6 +201,8 @@ class Image(section.Entry_section): return entry def ReadData(self, decomp=True): + tout.Debug("Image '%s' ReadData(), size=%#x" % + (self.GetPath(), len(self._data))) return self._data def GetListEntries(self, entry_paths): -- cgit From 0b7ebee38e5d9167360bc756fcfb72af8badc74f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 25 Sep 2019 08:56:22 -0600 Subject: binman: Take account of skip-at-start with image-header The image-header currently sets it offset assuming that skip-at-start is zero. This does not work on x86 where offsets end at 4GB. Add in this value so that the offset is correct. Signed-off-by: Simon Glass Acked-by: Bin Meng --- tools/binman/etype/image_header.py | 1 + 1 file changed, 1 insertion(+) (limited to 'tools') diff --git a/tools/binman/etype/image_header.py b/tools/binman/etype/image_header.py index 4b69eda1a2..b9327dd799 100644 --- a/tools/binman/etype/image_header.py +++ b/tools/binman/etype/image_header.py @@ -100,6 +100,7 @@ class Entry_image_header(Entry): offset = offset else: offset = image_size - IMAGE_HEADER_LEN + offset += self.section.GetStartOffset() return Entry.Pack(self, offset) def ProcessContents(self): -- cgit