# Creates binary images from input files controlled by a description
#
+from __future__ import print_function
+
from collections import OrderedDict
import os
import sys
tout.Init(options.verbosity)
elf.debug = options.debug
+ state.use_fake_dtb = options.fake_dtb
try:
tools.SetInputDirs(options.indir)
tools.PrepareOutputDir(options.outdir, options.preserve)
# 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(dtb)
+ state.Prepare(images, dtb)
# Prepare the device tree by making sure that any missing
# properties are added (e.g. 'pos' and 'size'). The values of these
# 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()