# Creates binary images from input files controlled by a description
#
+from __future__ import print_function
+
from collections import OrderedDict
import os
import sys
# output into a file in our output directly. Then scan it for use
# in binman.
dtb_fname = fdt_util.EnsureCompiled(dtb_fname)
- fname = tools.GetOutputFilename('u-boot-out.dtb')
- with open(dtb_fname) as infd:
- with open(fname, 'wb') as outfd:
- outfd.write(infd.read())
+ fname = tools.GetOutputFilename('u-boot.dtb.out')
+ tools.WriteFile(fname, tools.ReadFile(dtb_fname))
dtb = fdt.FdtScan(fname)
node = _FindBinmanNode(dtb)
if options.image:
skip = []
- for name, image in images.iteritems():
- if name not in options.image:
- del images[name]
+ new_images = OrderedDict()
+ for name, image in images.items():
+ if name in options.image:
+ new_images[name] = image
+ else:
skip.append(name)
- if skip:
- print 'Skipping images: %s\n' % ', '.join(skip)
+ images = new_images
+ if skip and options.verbosity >= 2:
+ print('Skipping images: %s' % ', '.join(skip))
state.Prepare(images, dtb)
# without changing the device-tree size, thus ensuring that our
# entry offsets remain the same.
for image in images.values():
+ image.ExpandEntries()
if options.update_fdt:
image.AddMissingProperties()
image.ProcessFdt(dtb)
# completed and written, but that does not seem important.
image.GetEntryContents()
image.GetEntryOffsets()
- image.PackEntries()
- image.CheckSize()
- image.CheckEntries()
+ try:
+ image.PackEntries()
+ image.CheckSize()
+ image.CheckEntries()
+ except Exception as e:
+ if options.map:
+ fname = image.WriteMap()
+ print("Wrote map file '%s' to show errors" % fname)
+ raise
image.SetImagePos()
if options.update_fdt:
image.SetCalculatedProperties()