aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-03-18 20:25:03 +1300
committerSimon Glass <sjg@chromium.org>2021-03-26 17:03:09 +1300
commit5187b806175a357b9e3dca247a1cb8f62a927c03 (patch)
tree4b227abf50afac8768e401152c037c32315e7f53
parentadb67bb94ee16d6284a13320c757460c31149c73 (diff)
downloadu-boot-5187b806175a357b9e3dca247a1cb8f62a927c03.zip
u-boot-5187b806175a357b9e3dca247a1cb8f62a927c03.tar.gz
u-boot-5187b806175a357b9e3dca247a1cb8f62a927c03.tar.bz2
binman: Use standard filenames for SPL/TPL devicetree
At present, before any entry expansion is done (such as a 'files' entry expanding out to individual entries for each file it contains), we check the binman definition (i.e. '/binman' node) to find out what devicetree files are used in the images. This is a pain, since the definition may change during expansion. For example if there is no u-boot-spl-dtb entry in the definition at the start, we assume that the SPL devicetree is not used. But if an entry later expands to include this, then we don't notice. In fact the flexibility provided by the current approach of checking the definition is not really useful. We know that we can have SPL and TPL devicetrees. We know the pathname to each, so we can simply check if the files are present. If they are present, we can prepare them and update them regardless of whether they are actually used. If they are not present, we cannot prepare/update them anyway, i.e. an error will be generated. Simplify state.Prepare() so it uses a hard-coded list of devicetree files. Note that state.PrepareFromLoadedData() is left untouched, since in that case we have a complete definition from the loaded file, but cannot of course rely on the devicetree files that created it still being present. So in that case we still check the image defitions. Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r--tools/binman/state.py21
-rw-r--r--tools/patman/tools.py8
2 files changed, 16 insertions, 13 deletions
diff --git a/tools/binman/state.py b/tools/binman/state.py
index 053b4fe..84f606b 100644
--- a/tools/binman/state.py
+++ b/tools/binman/state.py
@@ -188,17 +188,16 @@ def Prepare(images, dtb):
output_fdt_info[etype] = [dtb, fname]
else:
fdt_set = {}
- for image in images.values():
- fdt_set.update(image.GetFdts())
- for etype, other in fdt_set.items():
- entry, fname = other
- infile = tools.GetInputFilename(fname)
- fname_dtb = fdt_util.EnsureCompiled(infile)
- out_fname = tools.GetOutputFilename('%s.out' %
- os.path.split(fname)[1])
- tools.WriteFile(out_fname, tools.ReadFile(fname_dtb))
- other_dtb = fdt.FdtScan(out_fname)
- output_fdt_info[etype] = [other_dtb, out_fname]
+ for etype, fname in DTB_TYPE_FNAME.items():
+ infile = tools.GetInputFilename(fname, allow_missing=True)
+ if infile and os.path.exists(infile):
+ fname_dtb = fdt_util.EnsureCompiled(infile)
+ out_fname = tools.GetOutputFilename('%s.out' %
+ os.path.split(fname)[1])
+ tools.WriteFile(out_fname, tools.ReadFile(fname_dtb))
+ other_dtb = fdt.FdtScan(out_fname)
+ output_fdt_info[etype] = [other_dtb, out_fname]
+
def PrepareFromLoadedData(image):
"""Get device tree files ready for use with a loaded image
diff --git a/tools/patman/tools.py b/tools/patman/tools.py
index 10997e4..e5f391b 100644
--- a/tools/patman/tools.py
+++ b/tools/patman/tools.py
@@ -130,8 +130,12 @@ def GetInputFilename(fname, allow_missing=False):
allow_missing: True if the filename can be missing
Returns:
- The full path of the filename, within the input directory, or
- None on error
+ fname, if indir is None;
+ full path of the filename, within the input directory;
+ None, if file is missing and allow_missing is True
+
+ Raises:
+ ValueError if file is missing and allow_missing is False
"""
if not indir or fname[:1] == '/':
return fname