from __future__ import print_function
from collections import OrderedDict
+from sets import Set
import sys
import fdt_util
entry.SetPrefix(self._name_prefix)
self._entries[node.name] = entry
+ def GetFdtSet(self):
+ """Get the set of device tree files used by this image"""
+ fdt_set = Set()
+ for entry in self._entries.values():
+ fdt_set.update(entry.GetFdtSet())
+ return fdt_set
+
def SetOffset(self, offset):
self._offset = offset
if skip:
print 'Skipping images: %s\n' % ', '.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
have_importlib = False
import os
+from sets import Set
import sys
import fdt_util
def GetDefaultFilename(self):
return None
+ def GetFdtSet(self):
+ """Get the set of device trees used by this entry
+
+ Returns:
+ Set containing the filename from this entry, if it is a .dtb, else
+ an empty set
+ """
+ fname = self.GetDefaultFilename()
+ # It would be better to use isinstance(self, Entry_blob_dtb) here but
+ # we cannot access Entry_blob_dtb
+ if fname and fname.endswith('.dtb'):
+ return Set([fname])
+ return Set()
+
def AddMissingProperties(self):
"""Add new properties to the device tree as needed for this entry"""
for prop in ['offset', 'size', 'image-pos']:
self._filename = filename
self._section = bsection.Section('main-section', self._node)
+ def GetFdtSet(self):
+ """Get the set of device tree files used by this image"""
+ return self._section.GetFdtSet()
+
def AddMissingProperties(self):
"""Add properties that are not present in the device tree
# Arguments passed to binman to provide arguments to entries
entry_args = {}
+# True to use fake device-tree files for testing (see U_BOOT_DTB_DATA in
+# ftest.py)
+use_fake_dtb = True
+
# Set of all device tree files references by images
fdt_set = Set()
"""
return entry_args.get(name)
-def Prepare(dtb):
+def Prepare(images, dtb):
"""Get device tree files ready for use
This sets up a set of device tree files that can be retrieved by GetFdts().
At present there is only one, that for U-Boot proper.
Args:
+ images: List of images being used
dtb: Main dtb
"""
global fdt_set, fdt_subset, fdt_files, main_dtb
main_dtb = dtb
fdt_files.clear()
fdt_files['u-boot.dtb'] = dtb
- fdt_set = Set()
fdt_subset = Set()
+ if not use_fake_dtb:
+ for image in images.values():
+ fdt_subset.update(image.GetFdtSet())
+ fdt_subset.discard('u-boot.dtb')
+ for other_fname in fdt_subset:
+ infile = tools.GetInputFilename(other_fname)
+ other_fname_dtb = fdt_util.EnsureCompiled(infile)
+ out_fname = tools.GetOutputFilename('%s.out' %
+ os.path.split(other_fname)[1])
+ tools.WriteFile(out_fname, tools.ReadFile(other_fname_dtb))
+ other_dtb = fdt.FdtScan(out_fname)
+ fdt_files[other_fname] = other_dtb
def GetFdts():
"""Yield all device tree files being used by binman