1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-02 01:02:19 +02:00

binman: Support listing an image

Add support for listing the entries in an image. This relies on the image
having an FDT map.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2019-07-08 14:25:48 -06:00
parent 8beb11ea6e
commit 61f564d15f
6 changed files with 352 additions and 1 deletions

View File

@@ -67,6 +67,37 @@ def WriteEntryDocs(modules, test_missing=None):
from entry import Entry
Entry.WriteDocs(modules, test_missing)
def ListEntries(image_fname, entry_paths):
"""List the entries in an image
This decodes the supplied image and displays a table of entries from that
image, preceded by a header.
Args:
image_fname: Image filename to process
entry_paths: List of wildcarded paths (e.g. ['*dtb*', 'u-boot*',
'section/u-boot'])
"""
image = Image.FromFile(image_fname)
entries, lines, widths = image.GetListEntries(entry_paths)
num_columns = len(widths)
for linenum, line in enumerate(lines):
if linenum == 1:
# Print header line
print('-' * (sum(widths) + num_columns * 2))
out = ''
for i, item in enumerate(line):
width = -widths[i]
if item.startswith('>'):
width = -width
item = item[1:]
txt = '%*s ' % (width, item)
out += txt
print(out.rstrip())
def Binman(args):
"""The main control code for binman
@@ -87,6 +118,10 @@ def Binman(args):
command.Run(pager, fname)
return 0
if args.cmd == 'ls':
ListEntries(args.image, args.paths)
return 0
# Try to figure out which device tree contains our image description
if args.dt:
dtb_fname = args.dt