binman: Skip node generation for images read from files
PATCH v2 1/1 binman: Skip node generation for images read from files
From: Jan Kiszka <[email protected]>
We can and should run the node generator only when creating a new image. When we read it back, there is no need to generate nodes - they already exits, and binman does not dive that deep into the image - and there is no way to provide the required fdt-list. So forward the mode from the image to every Entry object it contains so that Entry_fit can simply skip generator nodes when reading them from an fdtmap.
This unbreaks all read-backs of images that contain generator nodes in their fdtmap.
---
Changes in v2:
- more verbose commit log
tools/binman/entry.py | 5 ++++- tools/binman/etype/fit.py | 2 +- tools/binman/etype/section.py | 4 ++-- tools/binman/image.py | 7 ++++--- 4 files changed, 11 insertions(+), 7 deletions(-)
tools/binman/entry.py +4 -1
@@ -75,7 +75,7 @@ class Entry(object): available. This is mainly used for testing. external: True if this entry contains an external binary blob """ - def __init__(self, section, etype, node, name_prefix=''): + def __init__(self, section, etype, node, name_prefix='', generate=None): # Put this here to allow entry-docs and help to work without libfdt global state from binman import state
@@ -105,6 +105,9 @@ class Entry(object): self.external = False self.allow_missing = False self.allow_fake = False + if generate == None: + generate = section.generate if section else True + self.generate = generate @staticmethod def FindEntryClass(etype, expanded):
tools/binman/etype/fit.py +1 -1
@@ -193,7 +193,7 @@ class Entry_fit(Entry): # the FIT (e.g. "/images/kernel/u-boot"), so don't call # fsw.add_node() or _AddNode() for it. pass - elif subnode.name.startswith('@'): + elif self.generate and subnode.name.startswith('@'): if self._fdts: # Generate notes for each FDT for seq, fdt_fname in enumerate(self._fdts):
tools/binman/etype/section.py +2 -2
@@ -154,9 +154,9 @@ class Entry_section(Entry): available. This is set by the `SetAllowMissing()` method, if `--allow-missing` is passed to binman. """ - def __init__(self, section, etype, node, test=False): + def __init__(self, section, etype, node, test=False, generate=None): if not test: - super().__init__(section, etype, node) + super().__init__(section, etype, node, generate=generate) self._entries = OrderedDict() self._pad_byte = 0 self._sort = False
tools/binman/image.py +4 -3
@@ -69,8 +69,9 @@ class Image(section.Entry_section): version which does not support all the entry types. """ def __init__(self, name, node, copy_to_orig=True, test=False, - ignore_missing=False, use_expanded=False, missing_etype=False): - super().__init__(None, 'section', node, test=test) + ignore_missing=False, use_expanded=False, missing_etype=False, + generate=True): + super().__init__(None, 'section', node, test=test, generate=generate) self.copy_to_orig = copy_to_orig self.name = 'main-section' self.image_name = name
@@ -130,7 +131,7 @@ class Image(section.Entry_section): # Return an Image with the associated nodes root = dtb.GetRoot() image = Image('image', root, copy_to_orig=False, ignore_missing=True, - missing_etype=True) + missing_etype=True, generate=False) image.image_node = fdt_util.GetString(root, 'image-node', 'image') image.fdtmap_dtb = dtb
Signature · 1 line
2.31.1
Hi Jan,
Quoted 16 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
We can and should run the node generator only when creating a new image. When we read it back, there is no need to generate nodes - they already exits, and binman does not dive that deep into the image - and there is no way to provide the required fdt-list. So forward the mode from the image to every Entry object it contains so that
Entry_fitcan simply skip generator nodes when reading them from an fdtmap.This unbreaks all read-backs of images that contain generator nodes in their fdtmap.
Signed-off-by Jan Kiszka <[email protected]>---
Quoted 8 lines
Changes in v2:
- more verbose commit logtools/binman/entry.py | 5 ++++- tools/binman/etype/fit.py | 2 +- tools/binman/etype/section.py | 4 ++-- tools/binman/image.py | 7 ++++--- 4 files changed, 11 insertions(+), 7 deletions(-)
Did you miss my other comments and a test?
Quoted 79 lines
tools/binman/entry.py +4
-1@@ -75,7 +75,7 @@ class Entry(object): available. This is mainly used for testing. external: True if this entry contains an external binary blob """ - def __init__(self, section, etype, node, name_prefix=''): + def __init__(self, section, etype, node, name_prefix='', generate=None): # Put this here to allow entry-docs and help to work without libfdt global state from binman import state@@ -105,6 +105,9 @@ class Entry(object): self.external = False self.allow_missing = False self.allow_fake = False + if generate == None: + generate = section.generate if section else True + self.generate = generate @staticmethod def FindEntryClass(etype, expanded):tools/binman/etype/fit.py +1
-1@@ -193,7 +193,7 @@ class Entry_fit(Entry): # the FIT (e.g. "/images/kernel/u-boot"), so don't call # fsw.add_node() or _AddNode() for it. pass - elif subnode.name.startswith('@'): + elif self.generate and subnode.name.startswith('@'): if self._fdts: # Generate notes for each FDT for seq, fdt_fname in enumerate(self._fdts):tools/binman/etype/section.py +2
-2@@ -154,9 +154,9 @@ class Entry_section(Entry): available. This is set by the `SetAllowMissing()` method, if `--allow-missing` is passed to binman. """ - def __init__(self, section, etype, node, test=False): + def __init__(self, section, etype, node, test=False, generate=None): if not test: - super().__init__(section, etype, node) + super().__init__(section, etype, node, generate=generate) self._entries = OrderedDict() self._pad_byte = 0 self._sort = Falsetools/binman/image.py +4
-4@@ -69,8 +69,9 @@ class Image(section.Entry_section): version which does not support all the entry types. """ def __init__(self, name, node, copy_to_orig=True, test=False, - ignore_missing=False, use_expanded=False, missing_etype=False): - super().__init__(None, 'section', node, test=test) + ignore_missing=False, use_expanded=False, missing_etype=False, + generate=True): + super().__init__(None, 'section', node, test=test, generate=generate) self.copy_to_orig = copy_to_orig self.name = 'main-section' self.image_name = name@@ -130,7 +131,7 @@ class Image(section.Entry_section): # Return an Image with the associated nodes root = dtb.GetRoot() image = Image('image', root, copy_to_orig=False, ignore_missing=True, - missing_etype=True) + missing_etype=True, generate=False) image.image_node = fdt_util.GetString(root, 'image-node', 'image') image.fdtmap_dtb = dtb --
Quoted 1 line
2.31.1
Regards,
Simon
Quoted 22 lines · Simon Glass
Hi Jan,
Quoted 19 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
We can and should run the node generator only when creating a new image. When we read it back, there is no need to generate nodes - they already exits, and binman does not dive that deep into the image - and there is no way to provide the required fdt-list. So forward the mode from the image to every Entry object it contains so that
Entry_fitcan simply skip generator nodes when reading them from an fdtmap.This unbreaks all read-backs of images that contain generator nodes in their fdtmap.
Signed-off-by Jan Kiszka <[email protected]>---
Changes in v2:
- more verbose commit log
Quoted 8 lines
Quoted 5 lines
tools/binman/entry.py | 5 ++++- tools/binman/etype/fit.py | 2 +- tools/binman/etype/section.py | 4 ++-- tools/binman/image.py | 7 ++++--- 4 files changed, 11 insertions(+), 7 deletions(-)Did you miss my other comments and a test?
Sorry, I indeed the other comments on the code - after ignoring the one about a test case. ENOTIME.
Jan
Quoted 83 lines
Quoted 79 lines
tools/binman/entry.py +4
-1@@ -75,7 +75,7 @@ class Entry(object): available. This is mainly used for testing. external: True if this entry contains an external binary blob """ - def __init__(self, section, etype, node, name_prefix=''): + def __init__(self, section, etype, node, name_prefix='', generate=None): # Put this here to allow entry-docs and help to work without libfdt global state from binman import state@@ -105,6 +105,9 @@ class Entry(object): self.external = False self.allow_missing = False self.allow_fake = False + if generate == None: + generate = section.generate if section else True + self.generate = generate @staticmethod def FindEntryClass(etype, expanded):tools/binman/etype/fit.py +1
-1@@ -193,7 +193,7 @@ class Entry_fit(Entry): # the FIT (e.g. "/images/kernel/u-boot"), so don't call # fsw.add_node() or _AddNode() for it. pass - elif subnode.name.startswith('@'): + elif self.generate and subnode.name.startswith('@'): if self._fdts: # Generate notes for each FDT for seq, fdt_fname in enumerate(self._fdts):tools/binman/etype/section.py +2
-2@@ -154,9 +154,9 @@ class Entry_section(Entry): available. This is set by the `SetAllowMissing()` method, if `--allow-missing` is passed to binman. """ - def __init__(self, section, etype, node, test=False): + def __init__(self, section, etype, node, test=False, generate=None): if not test: - super().__init__(section, etype, node) + super().__init__(section, etype, node, generate=generate) self._entries = OrderedDict() self._pad_byte = 0 self._sort = Falsetools/binman/image.py +4
-4@@ -69,8 +69,9 @@ class Image(section.Entry_section): version which does not support all the entry types. """ def __init__(self, name, node, copy_to_orig=True, test=False, - ignore_missing=False, use_expanded=False, missing_etype=False): - super().__init__(None, 'section', node, test=test) + ignore_missing=False, use_expanded=False, missing_etype=False, + generate=True): + super().__init__(None, 'section', node, test=test, generate=generate) self.copy_to_orig = copy_to_orig self.name = 'main-section' self.image_name = name@@ -130,7 +131,7 @@ class Image(section.Entry_section): # Return an Image with the associated nodes root = dtb.GetRoot() image = Image('image', root, copy_to_orig=False, ignore_missing=True, - missing_etype=True) + missing_etype=True, generate=False) image.image_node = fdt_util.GetString(root, 'image-node', 'image') image.fdtmap_dtb = dtb --Quoted 1 line
2.31.1
Regards,
Simon
Signature · 2 lines
Siemens AG, Technology Competence Center Embedded Linux