-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
driver: Add driver for Dediprog SPI-flash emulator #1483
Open
sjg20
wants to merge
1
commit into
labgrid-project:master
Choose a base branch
from
sjg20:push2-sf
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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})' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
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: | ||
serial (str): serial number of the em100 device, e.g. DP025143 | ||
chip (str): SPI-flash chip to emulate, e.g. W25Q64CV | ||
""" | ||
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: | ||
serial (str): serial number of the em100 device, e.g. DP025143 | ||
chip (str): SPI-flash chip to emulate, e.g. W25Q64CV | ||
""" | ||
serial = attr.ib(validator=attr.validators.instance_of(str)) | ||
chip = attr.ib(validator=attr.validators.instance_of(str)) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps
model: Dediprog EM100-PRO
could be mandatory & checked in case of different models added in future?