Drivers API¶
Drivers provide low-level hardware control and protocol implementations.
On this page:
Power Drivers — VesyncPowerDriver, CyberPowerDriver, CyberPowerPdu, HomeAssistantPowerDriver, HomeAssistantClient
Power Drivers¶
VesyncPowerDriver¶
- class adi_lg_plugins.drivers.vesyncdriver.VesyncPowerDriver(target, name)[source]¶
Bases:
Driver,PowerResetMixin,PowerProtocolVesyncPowerDriver - Driver using a Vesync Smart Outlet to control a target’s power - https://github.com/webdjoe/pyvesync. Uses pyvesync tool to control the outlet.
- on()[source]¶
Turn on all configured VeSync outlets.
This method powers on all outlets specified in the VesyncOutlet resource configuration. If multiple outlets are configured, they will all be turned on sequentially.
- Raises:
Exception – If outlet control fails or outlets are not found.
- off()[source]¶
Turn off all configured VeSync outlets.
This method powers off all outlets specified in the VesyncOutlet resource configuration. If multiple outlets are configured, they will all be turned off sequentially.
- Raises:
Exception – If outlet control fails or outlets are not found.
- reset()[source]¶
Perform a power reset cycle on all outlets.
This method turns off the outlets, waits for the configured delay period, then turns them back on. This is useful for hard-resetting hardware.
The delay duration is configured in the VesyncOutlet resource.
- Raises:
Exception – If outlet control fails.
- cycle()[source]¶
Power cycle all outlets (same as reset).
Alias for reset(). Turns off the outlets, waits for the configured delay, then turns them back on.
- Raises:
Exception – If outlet control fails.
- get()[source]¶
Get the current power state of all outlets.
- Returns:
True if all configured outlets are on, False otherwise.
- Return type:
- __init__(target, name)¶
Method generated by attrs for class VesyncPowerDriver.
- Return type:
None
CyberPowerDriver¶
- class adi_lg_plugins.drivers.cyberpowerdriver.CyberPowerDriver(target, name)[source]¶
Bases:
Driver,PowerResetMixin,PowerProtocolCyberPowerDriver - Driver using a CyberPower PDU to control a target’s power
- __init__(target, name)¶
Method generated by attrs for class CyberPowerDriver.
- Return type:
None
- on()[source]¶
Turn on the configured CyberPower PDU outlet.
Uses SNMP to send an ‘immediateOn’ command to the outlet specified in the CyberPowerOutlet resource configuration.
- Raises:
CyberPowerPduException – If SNMP communication fails.
- off()[source]¶
Turn off the configured CyberPower PDU outlet.
Uses SNMP to send an ‘immediateOff’ command to the outlet specified in the CyberPowerOutlet resource configuration.
- Raises:
CyberPowerPduException – If SNMP communication fails.
- reset()[source]¶
Perform a power reset cycle on the outlet.
This method turns off the outlet, waits for the configured delay period, then turns it back on. Useful for hard-resetting hardware.
The delay duration is configured in the CyberPowerOutlet resource.
- Raises:
CyberPowerPduException – If SNMP communication fails.
CyberPowerPdu¶
- class adi_lg_plugins.drivers.cyberpowerdriver.CyberPowerPdu(host)[source]¶
Bases:
objectClass to query & control a CyberPower PDU via SNMP.
Tested on the PDU15SWHVIEC8FNET. I don’t understand SNMP well enough to have any idea if this would be expected to work on other models.
This class is basically just a piece of copy-pasted pysnmp code and a depository for comments.
- Parameters:
host (str) – IP address or hostname of the PDU on the network
- outlet_state_oids = {'cancelPendingCommand': 7, 'delayedOff': 5, 'delayedOn': 4, 'delayedReboot': 6, 'immediateOff': 2, 'immediateOn': 1, 'immediateReboot': 3, 'outletIdentify': 8}¶
HomeAssistantPowerDriver¶
- class adi_lg_plugins.drivers.homeassistantdriver.HomeAssistantPowerDriver(target, name)[source]¶
Bases:
Driver,PowerResetMixin,PowerProtocolHomeAssistantPowerDriver - Driver using a Home Assistant switch/outlet to control a target’s power via the Home Assistant REST API.
- get()[source]¶
Get the current power state.
- Returns:
True if the switch is on, False otherwise.
- Return type:
- __init__(target, name)¶
Method generated by attrs for class HomeAssistantPowerDriver.
- Return type:
None
HomeAssistantClient¶
Shell and File Transfer¶
ADIShellDriver¶
- class adi_lg_plugins.drivers.shelldriver.ADIShellDriver(target, name, prompt, login_prompt, username, password=None, keyfile='', login_timeout=60, console_ready='', await_login_timeout=2, post_login_settle_time=0)[source]¶
Bases:
CommandMixin,Driver,CommandProtocol,FileTransferProtocolADIShellDriver - Driver to execute commands on the shell ADIShellDriver binds on top of a ConsoleProtocol.
On activation, the ADIShellDriver will look for the login prompt on the console, and login to provide shell access.
- Parameters:
prompt (regex) – the shell prompt to detect
login_prompt (regex) – the login prompt to detect
username (str) – username to login with
password (str) – password to login with
keyfile (str) – keyfile to bind mount over users authorized keys
login_timeout (int) – optional, timeout for login prompt detection
console_ready (regex) – optional, pattern used by the kernel to inform the user that a console can be activated by pressing enter.
await_login_timeout (int) – optional, time in seconds of silence that needs to pass before sending a newline to device.
post_login_settle_time (int) – optional, seconds of silence after logging in before check for a prompt. Useful when the console is interleaved with boot output which may interrupt prompt detection.
- get_status()[source]¶
Returns the status of the shell-driver. 0 means not connected/found, 1 means shell
- put_bytes(buf, remotefile)[source]¶
Upload a file to the target. Will silently overwrite the remote file if it already exists.
- put(localfile, remotefile)[source]¶
Upload a file to the target. Will silently overwrite the remote file if it already exists.
- get_bytes(remotefile)[source]¶
Download a file from the target.
- Parameters:
remotefile (str) – source filename on the target
- Returns:
(bytes) file contents
- Raises:
ExecutionError – if something went wrong
- get(remotefile, localfile)[source]¶
Download a file from the target. Will silently overwrite the local file if it already exists.
- run_script_file(scriptfile, *args, timeout=60)[source]¶
Upload a script file to the target and run it.
- Parameters:
- Returns:
str, stderr: str, return_value: int)
- Return type:
Tuple of (stdout
- Raises:
ExecutionError – if something went wrong
IOError – if the provided localfile could not be found
- get_default_interface_device_name(version=4)[source]¶
Retrieve the default route’s interface device name.
- Parameters:
version (int) – IP version
- Returns:
Name of the device of the default route
- Raises:
ExecutionError – if no or multiple routes are set up
- get_ip_addresses(device=None)[source]¶
Retrieves IP addresses for given interface name.
Note that although the return type is named IPv4Interface/IPv6Interface, it contains an IP address with the corresponding network prefix.
- Parameters:
device (str) – Name of the interface to query, defaults to default route’s device name.
- Returns:
List of IPv4Interface or IPv6Interface objects
- get_status_uboot()[source]¶
Retrieve status of the UBootDriver. 0 means inactive, 1 means active.
- Returns:
status of the driver
- Return type:
- __init__(target, name, prompt, login_prompt, username, password=None, keyfile='', login_timeout=60, console_ready='', await_login_timeout=2, post_login_settle_time=0)¶
Method generated by attrs for class ADIShellDriver.
- Return type:
None
Storage Drivers¶
MassStorageDriver¶
- class adi_lg_plugins.drivers.massstoragedriver.MassStorageDriver(target, name, partition=None, mount_label='lg_mass_storage', unmount_retries=3, unmount_retry_delay=2.0)[source]¶
Bases:
RemoteExecMixin,DriverMount and copy files to a USB mass storage device.
Supports both local-only (test runner == exporter) and remote-exporter bindings. When the bound resource is proxied from a coordinator, pmount/pumount/mkdir run on the exporter host and file copies are staged there over a single reused ssh connection (see
RemoteExecMixin).Specify partition when the bound resource points at a whole block device (e.g. /dev/sdb) rather than a specific partition; its value is the absolute partition path on the exporter host — a raw device (/dev/sdb1) or a stable symlink (/dev/disk/by-partuuid/…).
- unmount_retries¶
How many times to retry a busy
pumountbefore the lazy-unmount fallback. Each retry syncs and waitsunmount_retry_delayseconds.
- unmount_partition()[source]¶
Unmount the mass storage device partition.
A freshly-written USB mass-storage mount is frequently still busy when teardown runs (a lingering writer, udev/blkid probe, or the kernel flushing the FAT dirty bits), so a bare
pumountraces and fails withtarget is busy. On a shared CI board that stranded the place in a broken state. This retriespumounta few times (syncing + waiting between attempts) and, if the mountpoint is still busy, falls back to a lazy unmount so the device is always detached.
- copy_file(src, dst)[source]¶
Copy a local file onto the mass storage device.
- Parameters:
src – source file path on the test runner host.
dst – destination path relative to the mount point.
- update_files()[source]¶
Batch-copy files listed in mass_storage.file_updates (local-only path mapping).
- __init__(target, name, partition=None, mount_label='lg_mass_storage', unmount_retries=3, unmount_retry_delay=2.0)¶
Method generated by attrs for class MassStorageDriver.
- Return type:
None
Kuiper Drivers¶
KuiperDLDriver¶
- class adi_lg_plugins.drivers.kuiperdldriver.KuiperDLDriver(target, name)[source]¶
Bases:
DriverKuiperDLDriver - Driver to download and manage Kuiper releases and provide files to the target device.
- cache_datafile = 'cache_info.json'¶
- check_cached(release_version=None)[source]¶
Check if the specified Kuiper release version is cached locally. :param release_version: Version of the Kuiper release to check. If None, uses the version from kuiper_resource. :type release_version: str
- Returns:
True if the release is cached, False otherwise.
- Return type:
- download_release(release_version=None)[source]¶
Download the specified Kuiper release version if not already cached.
- get_full_image_path(release_version=None)[source]¶
Return the cached full SD image (.img) path for the configured release.
Downloads + extracts the release first if it isn’t cached. Caller is responsible for activating/deactivating the driver.
- add_files_to_target(filename)[source]¶
Add a file to the target device.
- Parameters:
filename (str) – Path to the file to add to the target.
- __init__(target, name)¶
Method generated by attrs for class KuiperDLDriver.
- Return type:
None
Cloudsmith Drivers¶
CloudsmithDLDriver¶
- class adi_lg_plugins.drivers.cloudsmithdldriver.CloudsmithDLDriver(target, name)[source]¶
Bases:
DriverDriver to resolve and download Cloudsmith boot artifacts.
Exposes the same
get_boot_files_from_release()/_boot_filescontract as KuiperDLDriver so it drops into the FPGA SoC boot strategies.- cache_datafile = 'cache_info.json'¶
- download_release(version=None)[source]¶
Resolve, download, and cache the boot artifact; return its local path.
- get_boot_file_path(version=None)[source]¶
Ensure the artifact is downloaded and return its local path.
- __init__(target, name)¶
Method generated by attrs for class CloudsmithDLDriver.
- Return type:
None
FPGA/JTAG Drivers¶
XilinxJTAGDriver¶
- class adi_lg_plugins.drivers.xilinxjtagdriver.XilinxJTAGDriver(target, name)[source]¶
Bases:
RemoteExecMixin,DriverProgram Xilinx FPGAs via JTAG using xsdb.
- Bindings:
- xilinxdevicejtag: XilinxDeviceJTAG resource (JTAG target IDs + bitstream/kernel paths
as seen by the host that runs xsdb).
xilinxvivado: XilinxVivadoTool resource (vivado_path / xsdb_path).
- bindings: Dict[str, Any] = {'xilinxdevicejtag': {'XilinxDeviceJTAG'}, 'xilinxvivado': {'XilinxVivadoTool'}}¶
- load_zynq_uboot(ps7_init_tcl, uboot_elf, a9_target_name='*Cortex-A9 MPCore #0', bitstream_path=None, fsbl_elf=None)[source]¶
JTAG-bootstrap U-Boot on a Zynq-7000 device.
The board can be in any boot state — xsdb will
rst -systemfirst to clear residual DDR/PS state before sourcing the board-specificps7_init.tcl. Used for SD-card recovery when BootROM cannot load FSBL from a corrupted card.The
a9_target_namefilter is used instead of an integer target index because Zynq-7000 xsdb target ordering shifts when the PL is loaded; the name-pattern form matches Xilinx’s generated wrappers and is stable across Vivado versions.
- load_and_run_elf(elf_path, a9_target_name='*Cortex-A9 MPCore #0', bitstream_path=None, ps7_init_tcl=None)[source]¶
JTAG-load and start an arbitrary bare-metal ELF (e.g. no-os firmware).
Generalizes
load_zynq_uboot()to any ELF that runs directly on a Zynq core (no FSBL/U-Boot chain). The same xsdb sequence is used:connect → rst -system → [fpga] → [ps7_init] → dow elf → con. The optionalbitstream_pathprograms the PL first (required when the firmware touches FPGA-fabric peripherals), andps7_init_tclruns the board PS init — both are produced by the no-os build’s HDL.xsa.Paths are resolved to absolute before being embedded in the xsdb TCL: xsdb runs the script from its own working directory (not the caller’s), so a relative
dow/fpga -fpath would fail to open.
- stop_zynq_cpu(a9_target_name='*Cortex-A9 MPCore #0')[source]¶
Halt the A9 #0 core — used between failed bootstrap attempts.
- Parameters:
a9_target_name (str)
- Return type:
None
- load_zynqmp_uboot(psu_init_tcl, spl_elf, bitstream_path=None, a53_target_name='*Cortex-A53*#0*', apu_release_rst_value='0x380E', dcc_log_path=None, settle_ms=12000, jtag_url='TCP:127.0.0.1:3121')[source]¶
JTAG-bootstrap Xilinx “mini” U-Boot SPL on a ZynqMP (UltraScale+).
This is the UltraScale+ counterpart of
load_zynq_uboot(). It is required because ZynqMP differs fundamentally from Zynq-7000:In JTAG boot mode (
BOOT_MODE_USER == 0x0) the BootROM does not load PMU firmware and the MicroBlaze PMU is not a debug target, so full U-Boot + Arm Trusted Firmware (BL31) cannot run – BL31 spins forever inipi_mb_notifywaiting on the PMU IPI mailbox.The working recovery bootstrap is the Xilinx
xilinx_zynqmp_mini_*SPL, which runs standalone in OCM at EL3 (no ATF, no PMU-FW) and exposes an ARM DCC / JTAG-UART console readable directly with xsdb.
Sequence (proven on ADRV9009-ZU11EG / ADRV2CRR-FMC):
Release the APU from reset without PMU-FW: write an AArch64
b .bootloop to RVBAR (OCM0xFFFF0000) then pokeCRF_APB.RST_FPD_APU(0xFD1A0104).apu_release_rst_valuedefaults to0x380Ewhich releases A53 #0 while holding A53 #1..3 and L2 in reset – matching the generated ZU11EG flow.(Optional) program the PL bitstream.
sourcethe board’s generatedpsu_init.tcland runpsu_init/psu_post_config/psu_ps_pl_reset_config/psu_ps_pl_isolation_removalto bring up clocks, DDR and the SD MIO mux. The psu_init path yields a clean core + DDR; an FSBL +rst -processorpath breaks debugger DDR access (EDITR timeout).Clean the A53 (
rst -processor -clear-registers),dowthe SPL ELF andcon.If
dcc_log_pathis given, capture the DCC console to that file on the xsdb host viareadjtaguart(headless;jtagterminalneeds an X server and is avoided).
- Parameters:
psu_init_tcl (str) – Path (on the xsdb host) to the board
psu_init.tcl.spl_elf (str) – Path (on the xsdb host) to
spl/u-boot-spl(mini SPL).bitstream_path (str | None) – Optional PL bitstream to program before psu_init.
a53_target_name (str) – xsdb target filter for the boot A53 core.
apu_release_rst_value (str) – value written to
0xFD1A0104to release the APU. Use0x0to release all four A53s (can destabilise later debug); prefer the board’s generated per-core value.dcc_log_path (str | None) – Optional path on the xsdb host to capture the DCC console log. Leave
Noneto skip console capture.settle_ms (int) – milliseconds to let the SPL run before stopping DCC capture / returning.
jtag_url (str)
- Return type:
None
- load_zynqmp_production_uboot(psu_init_tcl, pmufw_bin, uboot_bin, handoff_bin=None, bitstream_path=None, ddr_scrub_elf=None, bl31_bin=None, atf_handoff_bin=None, pm_config_bin=None, bl31_console_uart_base=None, bl31_console_ref_ctrl_address=None, bl31_console_reset_mask='0x2', a53_target_name='*Cortex-A53*#0*', apu_release_rst_value='0x380E', pmufw_address='0xFFDC0000', uboot_address='0x08000000', handoff_address='0x00100000', bl31_address='0xFFFEA000', pm_config_address='0x00200000', pmufw_timeout_ms=10000, ddr_scrub_settle_ms=30000, settle_ms=12000, jtag_url='TCP:127.0.0.1:3121')[source]¶
Start production U-Boot on a ZynqMP board strapped for JTAG boot.
This path is for a recovered SD card whose board cannot leave physical JTAG boot mode remotely. It reconstructs the parts of the production BootROM/FSBL chain which full U-Boot needs:
initialize the PS and DDR with the board’s generated
psu_init;optionally run an OCM-resident DDR ECC scrub before U-Boot relocates;
load PMU firmware through the physical PSU/DAP target, wake the PMU ROM, and require firmware to claim
FW_IS_PRESENT;optionally program a production PL bitstream already converted to the byte order expected by xsdb;
physically load raw U-Boot and EL3-to-EL2 handoff binaries, reset the A53 translation state, and enter the handoff at EL3.
For production U-Boot builds which issue SMC calls, pass
bl31_binandatf_handoff_bin. BL31 remains resident at EL3 and provides the Xilinx PM runtime services before entering U-Boot at EL2. For simpler U-Boot builds with no EL3 runtime dependency,handoff_binmay be a raw one-way EL3-to-EL2 trampoline instead.Loading every final payload through the PSU target avoids MMU translation faults left by a previous Linux or BL31 session.
PMU
FW_IS_PRESENTis a firmware-owned readiness indication. This method deliberately sets onlyDONT_SLEEPand fails if firmware does not assert readiness before the timeout.- Parameters:
psu_init_tcl (str)
pmufw_bin (str)
uboot_bin (str)
handoff_bin (str | None)
bitstream_path (str | None)
ddr_scrub_elf (str | None)
bl31_bin (str | None)
atf_handoff_bin (str | None)
pm_config_bin (str | None)
bl31_console_uart_base (str | None)
bl31_console_ref_ctrl_address (str | None)
bl31_console_reset_mask (str)
a53_target_name (str)
apu_release_rst_value (str)
pmufw_address (str)
uboot_address (str)
handoff_address (str)
bl31_address (str)
pm_config_address (str)
pmufw_timeout_ms (int)
ddr_scrub_settle_ms (int)
settle_ms (int)
jtag_url (str)
- Return type:
None
- load_zynqmp_recovery_linux(psu_init_tcl, trampoline_elf, kernel_image, initramfs, dtb, ddr_scrub_elf=None, bitstream_path=None, a53_target_name='*Cortex-A53*#0*', apu_release_rst_value='0x380E', trampoline_address='0x00100000', kernel_address='0x00200000', initramfs_address='0x10000000', dtb_address='0x20000000', ddr_scrub_done_address=None, ddr_scrub_settle_ms=120000, post_init_mask_writes=None, settle_ms=3000, jtag_url='TCP:127.0.0.1:3121')[source]¶
JTAG-load a RAM-rooted ZynqMP recovery Linux without BL31 or PMUFW.
Kernel, initramfs and DTB are downloaded through the physical PSU/DAP target, so stale A53 translation state cannot redirect writes. The caller-provided EL3 trampoline performs the board-specific timer/GIC setup and enters Linux at non-secure EL2.
- Parameters:
psu_init_tcl (str)
trampoline_elf (str)
kernel_image (str)
initramfs (str)
dtb (str)
ddr_scrub_elf (str | None)
bitstream_path (str | None)
a53_target_name (str)
apu_release_rst_value (str)
trampoline_address (str)
kernel_address (str)
initramfs_address (str)
dtb_address (str)
ddr_scrub_done_address (str | None)
ddr_scrub_settle_ms (int)
post_init_mask_writes (list | None)
settle_ms (int)
jtag_url (str)
- Return type:
None
- stop_zynqmp_cpu(a53_target_name='*Cortex-A53*#0*')[source]¶
Halt the ZynqMP A53 #0 core – used between failed bootstrap attempts.
- Parameters:
a53_target_name (str)
- Return type:
None
- __init__(target, name)¶
Method generated by attrs for class XilinxJTAGDriver.
- Return type:
None
Network Drivers¶
TFTPServerDriver¶
- class adi_lg_plugins.drivers.tftpserverdriver.TFTPServerDriver(target, name)[source]¶
Bases:
DriverTFTPServerDriver provides a pure Python TFTP server.
- bindings: Dict[str, Any] = {'resource': <class 'adi_lg_plugins.resources.tftpserver.TFTPServerResource'>}¶
- __init__(target, name)¶
Method generated by attrs for class TFTPServerDriver.
- Return type:
None
Utility Classes¶
- class adi_lg_plugins.drivers.kuiperdldriver.Downloader[source]¶
Utility class for downloading and verifying Kuiper Linux releases.
This class handles downloading release archives from ADI’s servers, verifying MD5 checksums, and extracting compressed archives. It supports both .xz and .zip compressed formats and displays progress bars using tqdm.
The Downloader is used internally by KuiperDLDriver but can also be used standalone via the kuiperdl CLI tool.
Example
>>> dl = Downloader() >>> rel = dl.releases("2023_R2_P1") >>> dl.download(rel["link"], rel["zipname"]) >>> dl.check(rel["zipname"], rel["zipmd5"]) >>> dl.extract(rel["zipname"], rel["imgname"])
- class adi_lg_plugins.drivers.imageextractor.IMGFileExtractor(img_path, logger=None)[source]¶
Extract files from disk image (.img) files using pytsk3.
This utility class provides methods to inspect partitions, list files, and extract individual files or directories from disk image files without mounting them. It’s primarily used by KuiperDLDriver to extract boot files from Kuiper Linux release images.
- Parameters:
img_path (str) – Path to the disk image file.
logger (Logger, optional) – Logger instance for debug output. If None, prints to stdout.
Example
>>> extractor = IMGFileExtractor("kuiper.img") >>> partitions = extractor.get_partitions() >>> fs = extractor.open_filesystem(partitions[0]["start"]) >>> extractor.extract_file(fs, "/Image", "./output/Image") >>> extractor.close()
- class adi_lg_plugins.drivers.cloudsmithdldriver.Downloader[source]¶
Streaming downloader with retry + sha256 verification.
Copied from KuiperDLDriver’s Downloader (kept independent). Only the pieces needed for individual-file downloads are retained: a retrying session and a streaming
downloadthat returns the sha256 digest.
- adi_lg_plugins.drivers.cloudsmithdldriver.get_latest_bootfiles(owner, repo, fpga_carrier=None, daughter_card=None, vfilter=None, vnot=None, filename=None, token=None, pin=None)[source]¶
Resolve the matching Cloudsmith package, returning the raw package dict.
Without
pinthe newest matching package (byuploaded_at) is returned; withpinthe package whoseversionequalspinis returned. The returned dict carriescdn_url,checksumsversionanduploaded_atplus a parsed_infoentry.
- adi_lg_plugins.drivers.cloudsmithdldriver.parse_version_info(version_str, tags, repo=None)[source]¶
Parse a Cloudsmith version string into structured metadata.
Returns
None(rather than raising) for unparseable strings, ignored systems, or unknown carriers, so one unexpected package never crashes resolution.
Software Installer¶
SoftwareInstallerDriver¶
- class adi_lg_plugins.drivers.softwareinstaller.SoftwareInstallerDriver(target, name)[source]¶
Bases:
DriverSoftwareInstallerDriver - Driver to install software, clone repos, copy directories, and run builds/tests on a DUT.
- bindings: Dict[str, Any] = {'command': <class 'labgrid.protocol.commandprotocol.CommandProtocol'>, 'file_transfer': <class 'labgrid.protocol.filetransferprotocol.FileTransferProtocol'>}¶
- install_package(package_name, update=False)[source]¶
Installs a package using the detected package manager.
- __init__(target, name)¶
Method generated by attrs for class SoftwareInstallerDriver.
- Return type:
None