binman: Allow entry types to override FDT contents

At present the contents of an FDT (for each phase) are fixed,
determined by the build and provided to Binman as input files.

Provide a means for entry types to provide their own FDT, so that it can
be processed, if needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2024-07-20 11:49:44 +01:00
parent 2e3697b954
commit daed9b42b4
3 changed files with 18 additions and 2 deletions

View file

@ -1386,3 +1386,15 @@ features to produce new behaviours.
def UpdateSignatures(self, privatekey_fname, algo, input_fname): def UpdateSignatures(self, privatekey_fname, algo, input_fname):
self.Raise('Updating signatures is not supported with this entry type') self.Raise('Updating signatures is not supported with this entry type')
def FdtContents(self, fdt_etype):
"""Get the contents of an FDT for a particular phase
Args:
fdt_etype (str): Filename of the phase of the FDT to return, e.g.
'u-boot-tpl-dtb'
Returns:
bytes: Contents of requested FDT
"""
return self.section.FdtContents(fdt_etype)

View file

@ -41,12 +41,12 @@ class Entry_blob_dtb(Entry_blob):
def ObtainContents(self, fake_size=0): def ObtainContents(self, fake_size=0):
"""Get the device-tree from the list held by the 'state' module""" """Get the device-tree from the list held by the 'state' module"""
self._filename = self.GetDefaultFilename() self._filename = self.GetDefaultFilename()
self._pathname, _ = state.GetFdtContents(self.GetFdtEtype()) self._pathname, _ = self.FdtContents(self.GetFdtEtype())
return super().ReadBlobContents() return super().ReadBlobContents()
def ProcessContents(self): def ProcessContents(self):
"""Re-read the DTB contents so that we get any calculated properties""" """Re-read the DTB contents so that we get any calculated properties"""
_, indata = state.GetFdtContents(self.GetFdtEtype()) _, indata = self.FdtContents(self.GetFdtEtype())
if self.compress == 'zstd' and self.prepend != 'length': if self.compress == 'zstd' and self.prepend != 'length':
self.Raise('The zstd compression requires a length header') self.Raise('The zstd compression requires a length header')

View file

@ -425,3 +425,7 @@ class Image(section.Entry_section):
super().AddBintools(bintools) super().AddBintools(bintools)
self.bintools = bintools self.bintools = bintools
return bintools return bintools
def FdtContents(self, fdt_etype):
"""This base-class implementation simply calls the state function"""
return state.GetFdtContents(fdt_etype)