U-Boot Driver¶
jumpstarter-driver-uboot provides functionality for interacting with the
U-Boot bootloader. This driver does not interact with the DUT directly, instead
it should be configured with backing power and serial drivers.
Installation¶
$ pip3 install --extra-index-url https://pkg.jumpstarter.dev/simple jumpstarter-driver-uboot
Configuration¶
Example configuration:
type: "jumpstarter_driver_uboot.driver.UbootConsole"
children:
power:
type: "jumpstarter_driver_power.driver.MockPower"
config: {} # omitted, power driver configuration
serial:
type: "jumpstarter_driver_pyserial.driver.PySerial"
config: # omitted, serial driver configuration
url: "loop://"
# instead of configuring the power and serial driver inline
# other drivers configured on the exporter can also be referenced
# power:
# ref: "dutlink.power"
# serial:
# ref: "dutlink.console"
config:
prompt: "=>" # the u-boot command prompt to expect, defaults to "=>"
prompt_timeout: 15 # seconds the board may take from a power cycle to the prompt, defaults to 15
interrupt: "\x1b" # sent repeatedly to stop autoboot, defaults to ESC; use the stop key of a keyed autoboot
API Reference¶
- class jumpstarter_driver_uboot.client.UbootConsoleClient¶
- attach_console(*, debug: bool = False, timeout: float | None = None) Generator[None]¶
Attach to a U-Boot that is already running
Like reboot_to_console, but without the power cycle: for a U-Boot the caller has started some other way, such as one loaded into RAM through a recovery mode. The exporter’s interrupt characters are sent until the prompt appears, for up to timeout seconds (default: the exporter’s prompt_timeout).
>>> with uboot.attach_console(): ... uboot.setup_dhcp()
- get_env(key: str, timeout: int = 5) str | None¶
Get U-Boot environment variable value
- property interrupt: str¶
Characters sent repeatedly to stop autoboot
- property prompt: str¶
U-Boot prompt to expect
- property prompt_timeout: float¶
Seconds to wait for the U-Boot prompt after power cycling the target
- reboot_to_console(*, debug: bool = False, retries: int | None = None) Generator[None]¶
Reboot to U-Boot console
Power cycle the target and wait for the U-Boot prompt, sending the exporter’s interrupt characters, for up to the exporter’s prompt_timeout. retries overrides that for this call, as a number of 0.1 s attempts.
Must be used as a context manager, other methods can only be used within the reboot_to_console context
>>> with uboot.reboot_to_console(debug=True): ... uboot.set_env("foo", "bar") ... uboot.setup_dhcp() >>> # uboot.set_env("foo", "baz") # invalid use
- run_command(cmd: str, timeout: int = 60, *, _internal_log=True) bytes¶
Run raw command in the U-Boot console
- run_command_checked(cmd: str, timeout: int = 60, check=True, tries=1) list[str]¶
Run command in the U-Boot console and check the exit code
- set_env(key: str, value: str | None, timeout: int = 5) None¶
Set U-Boot environment variable value
- set_env_dict(env: dict[str, str | None]) None¶
Set multiple U-Boot environment variable value
- setup_dhcp(timeout: int = 60) DhcpInfo¶
Setup dhcp in U-Boot