Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions doc/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,35 @@ NetworkDediprogFlasher
A :any:`NetworkDediprogFlasher` describes a `DediprogFlasher`_ resource
available on a remote computer.

SFEmulator
~~~~~~~~~~
A :any:`SFEmulator` resource is used to configure the parameters for a
SPI-flash emulator. This allows a DUT's SPI flash to be replaced or
overridden with a USB-connected emulator, which is much faster to load than
reprogramming the DUT's actual SPI flash.

So far only the Dediprog EM100-PRO is supported, so model must be set to
'Dediprog EM100-PRO'.

Arguments:
- serial (str): Serial number of the device
- chip (str): SPI-flash chip to emulate

.. code-block:: yaml

SFEmulator:
model: Dediprog EM100-PRO
serial: DP025143
chip: W25Q64CV

Used by:
- `SFEmulatorDriver`_

NetworkSFEmulator
~~~~~~~~~~~~~~~~~
A :any:`NetworkSFEmulator` describes a `SFEmulator`_ available on a
remote computer.

XenaManager
~~~~~~~~~~~
A :any:`XenaManager` resource describes a *Xena Manager* instance which is the
Expand Down Expand Up @@ -3479,6 +3508,15 @@ devices. It is assumed that the device flashing is an exporter wired, via a
*Dediprog SF100 SPI NOR Flash Programmer* for instance, to the device being
flashed.

SFEmulatorDriver
~~~~~~~~~~~~~~~~
The :any:`SFEmulatorDriver` is used to emulate a SPI-flash device on the DUT.

Binds to:
flasher:
- `SFEmulator`_
- `NetworkSFEmulator`_

XenaDriver
~~~~~~~~~~
The :any:`XenaDriver` allows to use Xena networking test equipment.
Expand Down
1 change: 1 addition & 0 deletions labgrid/driver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@
LAAUSBGadgetMassStorageDriver, LAAUSBDriver, \
LAAButtonDriver, LAALedDriver, LAATempDriver, LAAWattDriver, \
LAAProviderDriver
from .sfemulatordriver import SFEmulatorDriver
57 changes: 57 additions & 0 deletions labgrid/driver/sfemulatordriver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import attr
from .common import Driver
from ..factory import target_factory
from ..step import step
from ..util.helper import processwrapper
from ..util.managedfile import ManagedFile

@target_factory.reg_driver
@attr.s(eq=False)
class SFEmulatorDriver(Driver):
"""Provides access to em100 features

Args:
bindings (dict): driver to use with
_proc (subprocess.Popen): Process running em100 (used only in trace
mode)
_trace (str): Filename of trace file, if enabled
_thread (Thread): Thread which monitors the subprocess for errors
"""
bindings = {
'emul': {'SFEmulator', 'NetworkSFEmulator'},
}
trace = attr.ib(default=False, validator=attr.validators.instance_of(bool))

def __attrs_post_init__(self):
super().__attrs_post_init__()
if self.target.env:
self.tool = self.target.env.config.get_tool('em100')
else:
self.tool = 'em100'
self._trace = None
self._thread = None

@Driver.check_active
@step(title='write_image', args=['filename'])
def write_image(self, filename):
'''Write an image to the SPI-flash emulator

Args:
filename (str): Filename to write
'''
mf = ManagedFile(filename, self.emul)
mf.sync_to_resource()
cmd = self.emul.command_prefix + [
self.tool,
'-x', str(self.emul.serial),
'-s',
'-p', 'LOW',
'-c', self.emul.chip,
'-d', mf.get_remote_path(),
'-r',
]

processwrapper.check_output(cmd)

def __str__(self):
return f'SFEmulatorDriver({self.emul.serial})'
20 changes: 20 additions & 0 deletions labgrid/remote/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,26 @@ def _get_params(self):
exports["YKUSHPowerPort"] = YKUSHPowerPortExport


@attr.s(eq=False)
class SFEmulatorExport(ResourceExport):
"""ResourceExport for SFEmulator devices"""

def __attrs_post_init__(self):
super().__attrs_post_init__()
local_cls_name = self.cls
self.data["cls"] = f"Network{local_cls_name}"
from ..resource import sfemulator

local_cls = getattr(sfemulator, local_cls_name)
self.local = local_cls(target=None, name=None, **self.local_params)

def _get_params(self):
return {"host": self.host, **self.local_params}


exports["SFEmulator"] = SFEmulatorExport


class Exporter:
def __init__(self, config) -> None:
"""Set up internal datastructures on successful connection:
Expand Down
1 change: 1 addition & 0 deletions labgrid/resource/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@
from .laa import LAASerialPort, LAAPowerPort, LAAUSBGadgetMassStorage, \
LAAUSBPort, LAAButtonPort, \
LAALed, LAATempSensor, LAAWattMeter, LAAProvider
from .sfemulator import SFEmulator, NetworkSFEmulator
38 changes: 38 additions & 0 deletions labgrid/resource/sfemulator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import attr

from ..factory import target_factory
from .common import NetworkResource, Resource


@target_factory.reg_resource
@attr.s(eq=False)
class SFEmulator(Resource):
""""This resource describes a Dediprog em100 SPI-Flash Emulator

This provides serial consoles along with reset control

Args:
model (str): module of the emulator (must be 'Dediprog EM100-PRO')
serial (str): serial number of the em100 device, e.g. DP025143
chip (str): SPI-flash chip to emulate, e.g. W25Q64CV
"""
model = attr.ib(validator=attr.validators.instance_of(str))
serial = attr.ib(validator=attr.validators.instance_of(str))
chip = attr.ib(validator=attr.validators.instance_of(str))


@target_factory.reg_resource
@attr.s(eq=False)
class NetworkSFEmulator(NetworkResource):
""""This resource describes a remote Dediprog em100 SPI-Flash Emulator

This provides serial consoles along with reset control

Args:
model (str): module of the emulator (must be 'Dediprog EM100-PRO')
serial (str): serial number of the em100 device, e.g. DP025143
chip (str): SPI-flash chip to emulate, e.g. W25Q64CV
"""
model = attr.ib(validator=attr.validators.instance_of(str))
serial = attr.ib(validator=attr.validators.instance_of(str))
chip = attr.ib(validator=attr.validators.instance_of(str))
Loading