Skip to content
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

feat: auto-detect serial interface of sdwire #334

Merged
merged 1 commit into from
Sep 13, 2023
Merged
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
4 changes: 2 additions & 2 deletions docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,8 @@ a SD card between the DUT and host. The following settings are supported:
``/dev/sda``)

* ``serial``: string [optional]
Identifier of the sdmux/sdwire device to use (defaults to ``sdmux``). Use
``sd-mux-ctrl`` to list available devices.
Identifier of the sdmux/sdwire device to use. Use ``sd-mux-ctrl`` to list
available devices. When not specified, the first device is auto-detected.

``usbf`` driver settings
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
14 changes: 11 additions & 3 deletions mtda/storage/samsung.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,26 @@ class SamsungSdMuxStorageController(Image):
def __init__(self, mtda):
super().__init__(mtda)
self.file = "/dev/sda"
self.serial = "sdmux"
self.serial = None

""" Configure this storage controller from the provided configuration"""
def configure(self, conf):
self.mtda.debug(3, "storage.samsung.configure()")

result = None
result = True
if 'device' in conf:
self.file = conf['device']
if 'serial' in conf:
self.serial = conf['serial']

else:
try:
self.serial = subprocess.check_output([
"sd-mux-ctrl", "--device-id", "0", "--show-serial"
])
except subprocess.CalledProcessError:
result = False
self.mtda.debug(2, "storage.samsung.configure(): serial: %s" %
self.serial)
self.mtda.debug(3, "storage.samsung.configure(): %s" % str(result))
return result

Expand Down
Loading