aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlper Nebi Yasak <alpernebiyasak@gmail.com>2022-03-27 18:31:47 +0300
committerTom Rini <trini@konsulko.com>2022-04-25 10:11:05 -0400
commite736878b0865cdf963f02ec088b1df1d600ded20 (patch)
tree9e8a778380b57648defd14ad476f0faa92754ae8
parente2ce4fb9869dcedd3ecb4ad552c86e02248649df (diff)
downloadu-boot-e736878b0865cdf963f02ec088b1df1d600ded20.zip
u-boot-e736878b0865cdf963f02ec088b1df1d600ded20.tar.gz
u-boot-e736878b0865cdf963f02ec088b1df1d600ded20.tar.bz2
binman: Remove '/images/' fragment from FIT subentry paths
Binman FIT entry nodes describe their subentries in an 'images' subnode, same as how they would be written for the mkimage executable. The entry type initially manually managed its subentries keyed by their node paths relative to its base node. It was later converted to a proper section while still keeping the same keys for subentries. These subentry keys of sections are used as path fragments, so they must not contain the path separator character '/'. Otherwise, they won't be addressable by binman extract/replace commands. Change these keys from the '/images/foo' forms to the subentry node names. Extend the simple FIT tests to check for this. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
-rw-r--r--tools/binman/etype/fit.py13
-rw-r--r--tools/binman/ftest.py7
2 files changed, 15 insertions, 5 deletions
diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py
index e040771..0357198 100644
--- a/tools/binman/etype/fit.py
+++ b/tools/binman/etype/fit.py
@@ -384,7 +384,8 @@ class Entry_fit(Entry_section):
entry.ReadNode()
# The hash subnodes here are for mkimage, not binman.
entry.SetUpdateHash(False)
- self._entries[rel_path] = entry
+ image_name = rel_path[len('/images/'):]
+ self._entries[image_name] = entry
for subnode in node.subnodes:
_add_entries(base_node, depth + 1, subnode)
@@ -630,7 +631,8 @@ class Entry_fit(Entry_section):
has_images = depth == 2 and in_images
if has_images:
- entry = self._priv_entries[rel_path]
+ image_name = rel_path[len('/images/'):]
+ entry = self._priv_entries[image_name]
data = entry.GetData()
fsw.property('data', bytes(data))
@@ -643,12 +645,12 @@ class Entry_fit(Entry_section):
# fsw.add_node() or _add_node() for it.
pass
elif self.GetImage().generate and subnode.name.startswith('@'):
- entry = self._priv_entries.get(subnode_path)
+ entry = self._priv_entries.get(subnode.name)
_gen_node(base_node, subnode, depth, in_images, entry)
# This is a generator (template) entry, so remove it from
# the list of entries used by PackEntries(), etc. Otherwise
# it will appear in the binman output
- to_remove.append(subnode_path)
+ to_remove.append(subnode.name)
else:
with fsw.add_node(subnode.name):
_add_node(base_node, depth + 1, subnode)
@@ -693,7 +695,8 @@ class Entry_fit(Entry_section):
fdt = Fdt.FromData(self.GetData())
fdt.Scan()
- for path, section in self._entries.items():
+ for image_name, section in self._entries.items():
+ path = f"/images/{image_name}"
node = fdt.GetNode(path)
data_prop = node.props.get("data")
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index c9a8209..0e77358 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -3764,6 +3764,13 @@ class TestFunctional(unittest.TestCase):
self.assertEqual(len(kernel_data), int(data_sizes[0].split()[0]))
self.assertEqual(len(fdt1_data), int(data_sizes[1].split()[0]))
+ # Check if entry listing correctly omits /images/
+ image = control.images['image']
+ fit_entry = image.GetEntries()['fit']
+ subentries = list(fit_entry.GetEntries().keys())
+ expected = ['kernel', 'fdt-1']
+ self.assertEqual(expected, subentries)
+
def testSimpleFit(self):
"""Test an image with a FIT inside"""
data = self._DoReadFile('161_fit.dts')