mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-09-23 06:41:36 +02:00
binman: Convert FIT entry type to a subclass of Section entry type
The binman FIT entry type shares some code with the Section entry type. This shared code is bound to grow, since FIT entries are conceptually a variation of Section entries. Make FIT entry type a subclass of Section entry type, simplifying it a bit and providing us the features that Section implements. Also fix the subentry alignment test which now attempts to write symbols to a nonexistent SPL ELF test file by creating it first. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Avoid AddMissingProperties() and SetCalculatedProperties() with FIT: Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
4897d331f3
commit
f3078d4ea7
@ -9,11 +9,12 @@ from collections import defaultdict, OrderedDict
|
|||||||
import libfdt
|
import libfdt
|
||||||
|
|
||||||
from binman.entry import Entry, EntryArg
|
from binman.entry import Entry, EntryArg
|
||||||
|
from binman.etype.section import Entry_section
|
||||||
from dtoc import fdt_util
|
from dtoc import fdt_util
|
||||||
from dtoc.fdt import Fdt
|
from dtoc.fdt import Fdt
|
||||||
from patman import tools
|
from patman import tools
|
||||||
|
|
||||||
class Entry_fit(Entry):
|
class Entry_fit(Entry_section):
|
||||||
"""Flat Image Tree (FIT)
|
"""Flat Image Tree (FIT)
|
||||||
|
|
||||||
This calls mkimage to create a FIT (U-Boot Flat Image Tree) based on the
|
This calls mkimage to create a FIT (U-Boot Flat Image Tree) based on the
|
||||||
@ -112,15 +113,15 @@ class Entry_fit(Entry):
|
|||||||
"""
|
"""
|
||||||
Members:
|
Members:
|
||||||
_fit: FIT file being built
|
_fit: FIT file being built
|
||||||
_fit_sections: dict:
|
_entries: dict from Entry_section:
|
||||||
key: relative path to entry Node (from the base of the FIT)
|
key: relative path to entry Node (from the base of the FIT)
|
||||||
value: Entry_section object comprising the contents of this
|
value: Entry_section object comprising the contents of this
|
||||||
node
|
node
|
||||||
"""
|
"""
|
||||||
super().__init__(section, etype, node)
|
super().__init__(section, etype, node)
|
||||||
self._fit = None
|
self._fit = None
|
||||||
self._fit_sections = {}
|
|
||||||
self._fit_props = {}
|
self._fit_props = {}
|
||||||
|
|
||||||
for pname, prop in self._node.props.items():
|
for pname, prop in self._node.props.items():
|
||||||
if pname.startswith('fit,'):
|
if pname.startswith('fit,'):
|
||||||
self._fit_props[pname] = prop
|
self._fit_props[pname] = prop
|
||||||
@ -185,7 +186,7 @@ class Entry_fit(Entry):
|
|||||||
# 'data' property later.
|
# 'data' property later.
|
||||||
entry = Entry.Create(self.section, node, etype='section')
|
entry = Entry.Create(self.section, node, etype='section')
|
||||||
entry.ReadNode()
|
entry.ReadNode()
|
||||||
self._fit_sections[rel_path] = entry
|
self._entries[rel_path] = entry
|
||||||
|
|
||||||
for subnode in node.subnodes:
|
for subnode in node.subnodes:
|
||||||
if has_images and not (subnode.name.startswith('hash') or
|
if has_images and not (subnode.name.startswith('hash') or
|
||||||
@ -237,18 +238,19 @@ class Entry_fit(Entry):
|
|||||||
self._fdt = Fdt.FromData(fdt.as_bytearray())
|
self._fdt = Fdt.FromData(fdt.as_bytearray())
|
||||||
self._fdt.Scan()
|
self._fdt.Scan()
|
||||||
|
|
||||||
def ExpandEntries(self):
|
def BuildSectionData(self, required):
|
||||||
super().ExpandEntries()
|
"""Build FIT entry contents
|
||||||
for section in self._fit_sections.values():
|
|
||||||
section.ExpandEntries()
|
|
||||||
|
|
||||||
def ObtainContents(self):
|
|
||||||
"""Obtain the contents of the FIT
|
|
||||||
|
|
||||||
This adds the 'data' properties to the input ITB (Image-tree Binary)
|
This adds the 'data' properties to the input ITB (Image-tree Binary)
|
||||||
then runs mkimage to process it.
|
then runs mkimage to process it.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
required: True if the data must be present, False if it is OK to
|
||||||
|
return None
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Contents of the section (bytes)
|
||||||
"""
|
"""
|
||||||
# self._BuildInput() either returns bytes or raises an exception.
|
|
||||||
data = self._BuildInput(self._fdt)
|
data = self._BuildInput(self._fdt)
|
||||||
uniq = self.GetUniqueName()
|
uniq = self.GetUniqueName()
|
||||||
input_fname = tools.get_output_filename('%s.itb' % uniq)
|
input_fname = tools.get_output_filename('%s.itb' % uniq)
|
||||||
@ -264,14 +266,12 @@ class Entry_fit(Entry):
|
|||||||
'pad': fdt_util.fdt32_to_cpu(ext_offset.value)
|
'pad': fdt_util.fdt32_to_cpu(ext_offset.value)
|
||||||
}
|
}
|
||||||
if self.mkimage.run(reset_timestamp=True, output_fname=output_fname,
|
if self.mkimage.run(reset_timestamp=True, output_fname=output_fname,
|
||||||
**args) is not None:
|
**args) is None:
|
||||||
self.SetContents(tools.read_file(output_fname))
|
|
||||||
else:
|
|
||||||
# Bintool is missing; just use empty data as the output
|
# Bintool is missing; just use empty data as the output
|
||||||
self.record_missing_bintool(self.mkimage)
|
self.record_missing_bintool(self.mkimage)
|
||||||
self.SetContents(tools.get_bytes(0, 1024))
|
return tools.get_bytes(0, 1024)
|
||||||
|
|
||||||
return True
|
return tools.read_file(output_fname)
|
||||||
|
|
||||||
def _BuildInput(self, fdt):
|
def _BuildInput(self, fdt):
|
||||||
"""Finish the FIT by adding the 'data' properties to it
|
"""Finish the FIT by adding the 'data' properties to it
|
||||||
@ -282,12 +282,8 @@ class Entry_fit(Entry):
|
|||||||
Returns:
|
Returns:
|
||||||
New fdt contents (bytes)
|
New fdt contents (bytes)
|
||||||
"""
|
"""
|
||||||
for path, section in self._fit_sections.items():
|
for path, section in self._entries.items():
|
||||||
node = fdt.GetNode(path)
|
node = fdt.GetNode(path)
|
||||||
# Entry_section.ObtainContents() either returns True or
|
|
||||||
# raises an exception.
|
|
||||||
section.ObtainContents()
|
|
||||||
section.Pack(0)
|
|
||||||
data = section.GetData()
|
data = section.GetData()
|
||||||
node.AddData('data', data)
|
node.AddData('data', data)
|
||||||
|
|
||||||
@ -295,34 +291,16 @@ class Entry_fit(Entry):
|
|||||||
data = fdt.GetContents()
|
data = fdt.GetContents()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def CheckMissing(self, missing_list):
|
|
||||||
"""Check if any entries in this FIT have missing external blobs
|
|
||||||
|
|
||||||
If there are missing blobs, the entries are added to the list
|
|
||||||
|
|
||||||
Args:
|
|
||||||
missing_list: List of Entry objects to be added to
|
|
||||||
"""
|
|
||||||
for path, section in self._fit_sections.items():
|
|
||||||
section.CheckMissing(missing_list)
|
|
||||||
|
|
||||||
def SetAllowMissing(self, allow_missing):
|
|
||||||
for section in self._fit_sections.values():
|
|
||||||
section.SetAllowMissing(allow_missing)
|
|
||||||
|
|
||||||
def AddBintools(self, tools):
|
def AddBintools(self, tools):
|
||||||
for section in self._fit_sections.values():
|
super().AddBintools(tools)
|
||||||
section.AddBintools(tools)
|
|
||||||
self.mkimage = self.AddBintool(tools, 'mkimage')
|
self.mkimage = self.AddBintool(tools, 'mkimage')
|
||||||
|
|
||||||
def check_missing_bintools(self, missing_list):
|
def AddMissingProperties(self, have_image_pos):
|
||||||
"""Check if any entries in this section have missing bintools
|
# We don't want to interfere with any hash properties in the FIT, so
|
||||||
|
# disable this for now.
|
||||||
|
pass
|
||||||
|
|
||||||
If there are missing bintools, these are added to the list
|
def SetCalculatedProperties(self):
|
||||||
|
# We don't want to interfere with any hash properties in the FIT, so
|
||||||
Args:
|
# disable this for now.
|
||||||
missing_list: List of Bintool objects to be added to
|
pass
|
||||||
"""
|
|
||||||
super().check_missing_bintools(missing_list)
|
|
||||||
for entry in self._fit_sections.values():
|
|
||||||
entry.check_missing_bintools(missing_list)
|
|
||||||
|
@ -3850,6 +3850,7 @@ class TestFunctional(unittest.TestCase):
|
|||||||
|
|
||||||
def testFitImageSubentryAlignment(self):
|
def testFitImageSubentryAlignment(self):
|
||||||
"""Test relative alignability of FIT image subentries"""
|
"""Test relative alignability of FIT image subentries"""
|
||||||
|
self._SetupSplElf()
|
||||||
entry_args = {
|
entry_args = {
|
||||||
'test-id': TEXT_DATA,
|
'test-id': TEXT_DATA,
|
||||||
}
|
}
|
||||||
@ -5143,8 +5144,8 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
|
|||||||
data, _, _, _ = self._DoReadFileDtb('220_fit_subentry_bintool.dts',
|
data, _, _, _ = self._DoReadFileDtb('220_fit_subentry_bintool.dts',
|
||||||
entry_args=entry_args)
|
entry_args=entry_args)
|
||||||
|
|
||||||
expected = (GBB_DATA + GBB_DATA + tools.GetBytes(0, 8) +
|
expected = (GBB_DATA + GBB_DATA + tools.get_bytes(0, 8) +
|
||||||
tools.GetBytes(0, 0x2180 - 16))
|
tools.get_bytes(0, 0x2180 - 16))
|
||||||
self.assertIn(expected, data)
|
self.assertIn(expected, data)
|
||||||
|
|
||||||
def testFitSubentryMissingBintool(self):
|
def testFitSubentryMissingBintool(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user