Skip to content

Commit

Permalink
Merge pull request #107 from nathanchance/update-dtbs-locations
Browse files Browse the repository at this point in the history
boot-qemu.py: Handle dtb location shuffle in linux-next
  • Loading branch information
nathanchance authored Jun 22, 2023
2 parents e6bb228 + 2940648 commit 8ffe148
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions boot-qemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(self):
self.timeout = ''

self._default_kernel_path = None
self._dtb = None
self._dtbs = []
self._efi_img = None
self._efi_vars = None
self._initrd_arch = None
Expand All @@ -72,21 +72,22 @@ def __init__(self):
self._ram = '512m'

def _find_dtb(self):
if not self._dtb:
raise RuntimeError('No dtb set?')
if not self._dtbs:
raise RuntimeError('No dtbs set?')
if not self.kernel:
raise RuntimeError('Cannot locate dtb without kernel')

# If we are in a boot folder, look for them in the dts folder in it.
# Otherwise, assume there is a 'dtbs' folder in the same folder as the
# kernel image (tuxmake)
dtb_dir = 'dts' if self.kernel.parent.name == 'boot' else 'dtbs'
if not (dtb := Path(self.kernel.parent, dtb_dir, self._dtb)).exists():
raise FileNotFoundError(
f"dtb ('{self._dtb}') is required for booting but it could not be found at expected location ('{dtb}')",
)
for dtb_loc in self._dtbs:
if (dtb := Path(self.kernel.parent, dtb_dir, dtb_loc)).exists():
return dtb

return dtb
raise FileNotFoundError(
f"dtb is required for booting but it could not be found at expected locations ('{self._dtbs}')"
)

def _get_default_smp_value(self):
if not self.kernel_dir:
Expand Down Expand Up @@ -278,7 +279,7 @@ def run(self):
self.cmdline.append('nokaslr')
if self.cmdline:
self._qemu_args += ['-append', ' '.join(self.cmdline)]
if self._dtb:
if self._dtbs:
self._qemu_args += ['-dtb', self._find_dtb()]
self._qemu_args += ['-kernel', self.kernel]
self._qemu_args += ['-initrd', self._prepare_initrd()]
Expand Down Expand Up @@ -331,7 +332,9 @@ def __init__(self):

self.cmdline.append('earlycon')

self._dtb = 'aspeed-bmc-opp-palmetto.dtb'
self._dtbs = [
'aspeed/aspeed-bmc-opp-palmetto.dtb', 'aspeed-bmc-opp-palmetto.dtb'
]
self._machine = 'palmetto-bmc'


Expand All @@ -340,7 +343,9 @@ class ARMV6QEMURunner(ARMQEMURunner):
def __init__(self):
super().__init__()

self._dtb = 'aspeed-bmc-opp-romulus.dtb'
self._dtbs = [
'aspeed/aspeed-bmc-opp-romulus.dtb', 'aspeed-bmc-opp-romulus.dtb'
]
self._machine = 'romulus-bmc'


Expand Down

0 comments on commit 8ffe148

Please sign in to comment.