mirror of
https://xff.cz/git/u-boot/
synced 2025-09-03 09:42:22 +02:00
binman: Allow missing Intel blobs
Update the Intel blob entries to support missing binaries. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
@@ -55,6 +55,12 @@ class Entry_intel_descriptor(Entry_blob_ext):
|
|||||||
return super().Pack(offset)
|
return super().Pack(offset)
|
||||||
|
|
||||||
def GetOffsets(self):
|
def GetOffsets(self):
|
||||||
|
info = {}
|
||||||
|
if self.missing:
|
||||||
|
# Return zero offsets so that these entries get placed somewhere
|
||||||
|
if self.HasSibling('intel-me'):
|
||||||
|
info['intel-me'] = [0, None]
|
||||||
|
return info
|
||||||
offset = self.data.find(FD_SIGNATURE)
|
offset = self.data.find(FD_SIGNATURE)
|
||||||
if offset == -1:
|
if offset == -1:
|
||||||
self.Raise('Cannot find Intel Flash Descriptor (FD) signature')
|
self.Raise('Cannot find Intel Flash Descriptor (FD) signature')
|
||||||
@@ -66,7 +72,6 @@ class Entry_intel_descriptor(Entry_blob_ext):
|
|||||||
|
|
||||||
# Set the offset for ME (Management Engine) and IFWI (Integrated
|
# Set the offset for ME (Management Engine) and IFWI (Integrated
|
||||||
# Firmware Image), for now, since the others are not used.
|
# Firmware Image), for now, since the others are not used.
|
||||||
info = {}
|
|
||||||
if self.HasSibling('intel-me'):
|
if self.HasSibling('intel-me'):
|
||||||
info['intel-me'] = [self._regions[REGION_ME].base,
|
info['intel-me'] = [self._regions[REGION_ME].base,
|
||||||
self._regions[REGION_ME].size]
|
self._regions[REGION_ME].size]
|
||||||
|
@@ -84,7 +84,7 @@ class Entry_intel_ifwi(Entry_blob_ext):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def ObtainContents(self):
|
def ObtainContents(self):
|
||||||
"""Get the contects for the IFWI
|
"""Get the contents for the IFWI
|
||||||
|
|
||||||
Unfortunately we cannot create anything from scratch here, as Intel has
|
Unfortunately we cannot create anything from scratch here, as Intel has
|
||||||
tools which create precursor binaries with lots of data and settings,
|
tools which create precursor binaries with lots of data and settings,
|
||||||
@@ -97,13 +97,21 @@ class Entry_intel_ifwi(Entry_blob_ext):
|
|||||||
After that we delete the OBBP sub-partition and add each of the files
|
After that we delete the OBBP sub-partition and add each of the files
|
||||||
that we want in the IFWI file, one for each sub-entry of the IWFI node.
|
that we want in the IFWI file, one for each sub-entry of the IWFI node.
|
||||||
"""
|
"""
|
||||||
self._pathname = tools.GetInputFilename(self._filename)
|
self._pathname = tools.GetInputFilename(self._filename,
|
||||||
|
self.section.GetAllowMissing())
|
||||||
|
# Allow the file to be missing
|
||||||
|
if not self._pathname:
|
||||||
|
self.SetContents(b'')
|
||||||
|
self.missing = True
|
||||||
|
return True
|
||||||
for entry in self._ifwi_entries.values():
|
for entry in self._ifwi_entries.values():
|
||||||
if not entry.ObtainContents():
|
if not entry.ObtainContents():
|
||||||
return False
|
return False
|
||||||
return self._BuildIfwi()
|
return self._BuildIfwi()
|
||||||
|
|
||||||
def ProcessContents(self):
|
def ProcessContents(self):
|
||||||
|
if self.missing:
|
||||||
|
return True
|
||||||
orig_data = self.data
|
orig_data = self.data
|
||||||
self._BuildIfwi()
|
self._BuildIfwi()
|
||||||
same = orig_data == self.data
|
same = orig_data == self.data
|
||||||
@@ -121,5 +129,6 @@ class Entry_intel_ifwi(Entry_blob_ext):
|
|||||||
|
|
||||||
def WriteSymbols(self, section):
|
def WriteSymbols(self, section):
|
||||||
"""Write symbol values into binary files for access at run time"""
|
"""Write symbol values into binary files for access at run time"""
|
||||||
for entry in self._ifwi_entries.values():
|
if not self.missing:
|
||||||
entry.WriteSymbols(self)
|
for entry in self._ifwi_entries.values():
|
||||||
|
entry.WriteSymbols(self)
|
||||||
|
@@ -442,8 +442,8 @@ class Entry_section(Entry):
|
|||||||
if not entry:
|
if not entry:
|
||||||
self._Raise("Unable to set offset/size for unknown entry '%s'" %
|
self._Raise("Unable to set offset/size for unknown entry '%s'" %
|
||||||
name)
|
name)
|
||||||
entry.SetOffsetSize(self._skip_at_start + offset if offset else None,
|
entry.SetOffsetSize(self._skip_at_start + offset if offset is not None
|
||||||
size)
|
else None, size)
|
||||||
|
|
||||||
def GetEntryOffsets(self):
|
def GetEntryOffsets(self):
|
||||||
"""Handle entries that want to set the offset/size of other entries
|
"""Handle entries that want to set the offset/size of other entries
|
||||||
|
@@ -160,8 +160,7 @@ class TestFunctional(unittest.TestCase):
|
|||||||
tools.ReadFile(cls.ElfTestFile('u_boot_ucode_ptr')))
|
tools.ReadFile(cls.ElfTestFile('u_boot_ucode_ptr')))
|
||||||
|
|
||||||
# Intel flash descriptor file
|
# Intel flash descriptor file
|
||||||
with open(cls.TestFile('descriptor.bin'), 'rb') as fd:
|
cls._SetupDescriptor()
|
||||||
TestFunctional._MakeInputFile('descriptor.bin', fd.read())
|
|
||||||
|
|
||||||
shutil.copytree(cls.TestFile('files'),
|
shutil.copytree(cls.TestFile('files'),
|
||||||
os.path.join(cls._indir, 'files'))
|
os.path.join(cls._indir, 'files'))
|
||||||
@@ -507,6 +506,11 @@ class TestFunctional(unittest.TestCase):
|
|||||||
TestFunctional._MakeInputFile('tpl/u-boot-tpl',
|
TestFunctional._MakeInputFile('tpl/u-boot-tpl',
|
||||||
tools.ReadFile(cls.ElfTestFile(src_fname)))
|
tools.ReadFile(cls.ElfTestFile(src_fname)))
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _SetupDescriptor(cls):
|
||||||
|
with open(cls.TestFile('descriptor.bin'), 'rb') as fd:
|
||||||
|
TestFunctional._MakeInputFile('descriptor.bin', fd.read())
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def TestFile(cls, fname):
|
def TestFile(cls, fname):
|
||||||
return os.path.join(cls._binman_dir, 'test', fname)
|
return os.path.join(cls._binman_dir, 'test', fname)
|
||||||
@@ -933,11 +937,14 @@ class TestFunctional(unittest.TestCase):
|
|||||||
|
|
||||||
def testPackX86RomMeNoDesc(self):
|
def testPackX86RomMeNoDesc(self):
|
||||||
"""Test that an invalid Intel descriptor entry is detected"""
|
"""Test that an invalid Intel descriptor entry is detected"""
|
||||||
TestFunctional._MakeInputFile('descriptor.bin', b'')
|
try:
|
||||||
with self.assertRaises(ValueError) as e:
|
TestFunctional._MakeInputFile('descriptor.bin', b'')
|
||||||
self._DoTestFile('031_x86_rom_me.dts')
|
with self.assertRaises(ValueError) as e:
|
||||||
self.assertIn("Node '/binman/intel-descriptor': Cannot find Intel Flash Descriptor (FD) signature",
|
self._DoTestFile('031_x86_rom_me.dts')
|
||||||
str(e.exception))
|
self.assertIn("Node '/binman/intel-descriptor': Cannot find Intel Flash Descriptor (FD) signature",
|
||||||
|
str(e.exception))
|
||||||
|
finally:
|
||||||
|
self._SetupDescriptor()
|
||||||
|
|
||||||
def testPackX86RomBadDesc(self):
|
def testPackX86RomBadDesc(self):
|
||||||
"""Test that the Intel requires a descriptor entry"""
|
"""Test that the Intel requires a descriptor entry"""
|
||||||
@@ -3394,6 +3401,26 @@ class TestFunctional(unittest.TestCase):
|
|||||||
self.assertRegex(err, "Image 'main-section'.*missing.*: "
|
self.assertRegex(err, "Image 'main-section'.*missing.*: "
|
||||||
"blob-ext blob-ext2")
|
"blob-ext blob-ext2")
|
||||||
|
|
||||||
|
def testPackX86RomMeMissingDesc(self):
|
||||||
|
"""Test that an missing Intel descriptor entry is allowed"""
|
||||||
|
pathname = os.path.join(self._indir, 'descriptor.bin')
|
||||||
|
os.remove(pathname)
|
||||||
|
with test_util.capture_sys_output() as (stdout, stderr):
|
||||||
|
self._DoTestFile('031_x86_rom_me.dts', allow_missing=True)
|
||||||
|
err = stderr.getvalue()
|
||||||
|
self.assertRegex(err,
|
||||||
|
"Image 'main-section'.*missing.*: intel-descriptor")
|
||||||
|
|
||||||
|
def testPackX86RomMissingIfwi(self):
|
||||||
|
"""Test that an x86 ROM with Integrated Firmware Image can be created"""
|
||||||
|
self._SetupIfwi('fitimage.bin')
|
||||||
|
pathname = os.path.join(self._indir, 'fitimage.bin')
|
||||||
|
os.remove(pathname)
|
||||||
|
with test_util.capture_sys_output() as (stdout, stderr):
|
||||||
|
self._DoTestFile('111_x86_rom_ifwi.dts', allow_missing=True)
|
||||||
|
err = stderr.getvalue()
|
||||||
|
self.assertRegex(err, "Image 'main-section'.*missing.*: intel-ifwi")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Reference in New Issue
Block a user