binman: Obtain the list of device trees from the config

We always have a device tree for U-Boot proper. But we may also have one
for SPL and TPL. Add a new Entry method to find out what DTs an entry
has, and use that list when updating DTs.

Signed-off-by: Simon Glass <sjg@chromium.org>
lime2-spi
Simon Glass 6 years ago
parent f46621d255
commit 539aece516
  1. 8
      tools/binman/bsection.py
  2. 2
      tools/binman/control.py
  3. 15
      tools/binman/entry.py
  4. 4
      tools/binman/image.py
  5. 20
      tools/binman/state.py

@ -8,6 +8,7 @@
from __future__ import print_function
from collections import OrderedDict
from sets import Set
import sys
import fdt_util
@ -92,6 +93,13 @@ class Section(object):
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

@ -137,7 +137,7 @@ def Binman(options, args):
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

@ -18,6 +18,7 @@ except:
have_importlib = False
import os
from sets import Set
import sys
import fdt_util
@ -164,6 +165,20 @@ class Entry(object):
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']:

@ -54,6 +54,10 @@ class Image:
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

@ -18,6 +18,10 @@ fdt_files = {}
# 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()
@ -85,13 +89,14 @@ def GetEntryArg(name):
"""
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
@ -107,8 +112,19 @@ def Prepare(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

Loading…
Cancel
Save