Skip to content

Commit

Permalink
ukify: Support building UKIs with multiple embedded DeviceTrees
Browse files Browse the repository at this point in the history
Add support for building UKIs with multiple DeviceTrees, each embedded
in its own .dtb section.
  • Loading branch information
diogoivo authored and diogo-ivo committed Oct 20, 2023
1 parent 901ead4 commit e629f67
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/ukify/ukify.py
Expand Up @@ -324,7 +324,7 @@ class UKI:
sections: list[Section] = dataclasses.field(default_factory=list, init=False)

def add_section(self, section):
if section.name in [s.name for s in self.sections]:
if section.name in [s.name for s in self.sections] and section.name != '.dtb':
raise ValueError(f'Duplicate section {section.name}')

self.sections += [section]
Expand Down Expand Up @@ -605,7 +605,7 @@ def pe_add_sections(uki: UKI, output: str):
# the one from the kernel to it. It should be small enough to fit in the existing section, so just
# swap the data.
for i, s in enumerate(pe.sections):
if s.Name.rstrip(b"\x00").decode() == section.name:
if s.Name.rstrip(b"\x00").decode() == section.name and section.name != '.dtb':
if new_section.Misc_VirtualSize > s.SizeOfRawData:
raise PEError(f'Not enough space in existing section {section.name} to append new data.')

Expand Down Expand Up @@ -775,7 +775,7 @@ def make_uki(opts):
# name, content, measure?
('.osrel', opts.os_release, True ),
('.cmdline', opts.cmdline, True ),
('.dtb', opts.devicetree, True ),
*(('.dtb', dtb, True) for dtb in opts.devicetree),
('.uname', opts.uname, True ),
('.splash', opts.splash, True ),
('.pcrpkey', pcrpkey, True ),
Expand Down Expand Up @@ -1205,6 +1205,7 @@ def config_example(self) -> tuple[Optional[str], Optional[str], Optional[str]]:
'--devicetree',
metavar = 'PATH',
type = pathlib.Path,
action = 'append',
help = 'Device Tree file [.dtb section]',
config_key = 'UKI/DeviceTree',
),
Expand Down

0 comments on commit e629f67

Please sign in to comment.