Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Commit 28308bb

Browse files
committed
Make use of standalone uboot driver
1 parent f135cf6 commit 28308bb

7 files changed

Lines changed: 39 additions & 168 deletions

File tree

packages/jumpstarter-driver-flashers/jumpstarter_driver_flashers/client.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
from jumpstarter_driver_flashers.bundle import FlasherBundleManifestV1Alpha1
2222

23-
from .uboot import UbootConsole
2423
from jumpstarter.common.exceptions import ArgumentError
2524

2625
debug_console_option = click.option("--console-debug", is_flag=True, help="Enable console debug mode")
@@ -42,6 +41,7 @@ def __post_init__(self):
4241
def set_console_debug(self, debug: bool):
4342
"""Set console debug mode"""
4443
self._console_debug = debug
44+
# TODO: also set console debug on uboot client
4545

4646
@contextmanager
4747
def busybox_shell(self):
@@ -61,12 +61,8 @@ def bootloader_shell(self):
6161
self.logger.info("Setting up flasher bundle files in exporter")
6262
self.call("setup_flasher_bundle")
6363
with self._services_up():
64-
with self.serial.pexpect() as console:
65-
if self._console_debug:
66-
console.logfile_read = sys.stdout.buffer
67-
uboot = UbootConsole(console=console, power=self.power, logger=self.logger)
68-
uboot.reboot_to_console()
69-
console.sendline("")
64+
with self.uboot.reboot_to_console():
65+
pass
7066
yield self.serial
7167

7268
def flash(
@@ -377,36 +373,37 @@ def _busybox(self):
377373
378374
This is a helper context manager that boots the device into uboot and returns a console object.
379375
"""
380-
with self.serial.pexpect() as console:
381-
if self._console_debug:
382-
console.logfile_read = sys.stdout.buffer
383-
uboot = UbootConsole(console=console, power=self.power, logger=self.logger)
384-
# make sure that the device is booted into the uboot console
385-
uboot.reboot_to_console()
376+
377+
# make sure that the device is booted into the uboot console
378+
with self.uboot.reboot_to_console():
386379
# run dhcp discovery and gather details useful for later
387-
self._dhcp_details = uboot.setup_dhcp()
380+
self._dhcp_details = self.uboot.setup_dhcp()
388381
self.logger.info(f"discovered dhcp details: {self._dhcp_details}")
389382

390383
# configure the environment necessary
391384
env = self._generate_uboot_env()
392-
uboot.set_env_dict(env)
385+
self.uboot.set_env_dict(env)
393386

394387
# load any necessary files to RAM from the tftp storage
395388
manifest = self.manifest
396389
kernel_filename = Path(manifest.get_kernel_file()).name
397390
kernel_address = manifest.get_kernel_address()
398391

399-
uboot.run_command(f"tftpboot {kernel_address} {kernel_filename}", timeout=120)
392+
self.uboot.run_command(f"tftpboot {kernel_address} {kernel_filename}", timeout=120)
400393

401394
if manifest.get_initram_file():
402395
initram_filename = Path(manifest.get_initram_file()).name
403396
initram_address = manifest.get_initram_address()
404-
uboot.run_command(f"tftpboot {initram_address} {initram_filename}", timeout=120)
397+
self.uboot.run_command(f"tftpboot {initram_address} {initram_filename}", timeout=120)
405398

406399
if manifest.get_dtb_file():
407400
dtb_filename = Path(manifest.get_dtb_file()).name
408401
dtb_address = manifest.get_dtb_address()
409-
uboot.run_command(f"tftpboot {dtb_address} {dtb_filename}", timeout=120)
402+
self.uboot.run_command(f"tftpboot {dtb_address} {dtb_filename}", timeout=120)
403+
404+
with self.serial.pexpect() as console:
405+
if self._console_debug:
406+
console.logfile_read = sys.stdout.buffer
410407

411408
self.logger.info(f"Running boot command: {manifest.spec.bootcmd}")
412409
console.send(manifest.spec.bootcmd + "\n")

packages/jumpstarter-driver-flashers/jumpstarter_driver_flashers/driver.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import anyio.to_thread
55
from jumpstarter_driver_http.driver import HttpServer
66
from jumpstarter_driver_tftp.driver import Tftp
7+
from jumpstarter_driver_uboot.driver import UbootConsole
78
from oras.provider import Registry
89

910
from .bundle import FlasherBundleManifestV1Alpha1
@@ -45,6 +46,14 @@ def __post_init__(self):
4546
"'power' instance is required for BaseFlasher either via a ref ir a direct child instance"
4647
)
4748

49+
if "uboot" not in self.children:
50+
self.children["uboot"] = UbootConsole(
51+
children={
52+
"power": self.children["power"],
53+
"serial": self.children["serial"],
54+
}
55+
)
56+
4857
# bundles that have already been downloaded in the current session
4958
self._downloaded = {}
5059
self._use_dtb = None # use default dtb unless set by client

packages/jumpstarter-driver-flashers/jumpstarter_driver_flashers/uboot.py

Lines changed: 0 additions & 134 deletions
This file was deleted.

packages/jumpstarter-driver-flashers/pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ dependencies = [
1818
"jumpstarter-driver-http",
1919
"jumpstarter-driver-tftp",
2020
"jumpstarter-driver-power",
21+
"jumpstarter-driver-uboot",
2122
]
2223

2324
[tool.hatch.version]
@@ -33,6 +34,9 @@ addopts = "--cov --cov-report=html --cov-report=xml"
3334
log_cli = true
3435
log_cli_level = "INFO"
3536
testpaths = ["jumpstarter_driver_flashers"]
37+
38+
[tool.uv.sources]
39+
jumpstarter-driver-uboot = { workspace = true }
3640
#asyncio_mode = "auto"
3741

3842
[build-system]

packages/jumpstarter-driver-opendal/jumpstarter_driver_opendal/client.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,20 @@ async def aclose(self):
4444
def fs_operator_for_path(path: PathBuf) -> tuple[PathBuf, Operator]:
4545
return Path(path).resolve(), Operator("fs", root="/")
4646

47+
4748
def operator_for_path(path: PathBuf) -> tuple[PathBuf, Operator, str]:
48-
""" Create an operator for the given path
49+
"""Create an operator for the given path
4950
Return a tuple of:
5051
- the path
5152
- the operator for the given path
5253
- the scheme of the operator.
5354
"""
54-
if type(path) is str and path.startswith(('http://', 'https://')):
55-
parsed_url = urlparse(path)
56-
operator = Operator(
57-
'http',
58-
root='/',
59-
endpoint=f"{parsed_url.scheme}://{parsed_url.netloc}"
60-
)
61-
return Path(parsed_url.path), operator, 'http'
55+
if type(path) is str and path.startswith(("http://", "https://")):
56+
parsed_url = urlparse(path)
57+
operator = Operator("http", root="/", endpoint=f"{parsed_url.scheme}://{parsed_url.netloc}")
58+
return Path(parsed_url.path), operator, "http"
6259
else:
63-
return *fs_operator_for_path(path), 'fs'
60+
return *fs_operator_for_path(path), "fs"
6461

6562

6663
@dataclass(kw_only=True)
@@ -529,12 +526,7 @@ def flash(
529526
...
530527

531528
@abstractmethod
532-
def dump(
533-
self,
534-
path: PathBuf,
535-
*,
536-
partition: str | None = None,
537-
operator: Operator | None = None):
529+
def dump(self, path: PathBuf, *, partition: str | None = None, operator: Operator | None = None):
538530
"""Dump image from DUT"""
539531
...
540532

packages/jumpstarter-driver-opendal/jumpstarter_driver_opendal/driver.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ async def copy_exporter_file(self, /, source: Path, target: str):
195195
break
196196
await dst.write(bs=data)
197197

198+
198199
class FlasherInterface(metaclass=ABCMeta):
199200
@classmethod
200201
def client(cls) -> str:

uv.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)