summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorNick Sanders <nsanders@chromium.org>2018-07-26 02:31:10 +0000
committerchrome-bot <chrome-bot@chromium.org>2018-07-26 04:07:16 -0700
commit3793a83cbd7349b07453cc5a44674f9e7bc856f3 (patch)
treee275f6b023dc0014a2ca4e12b2ae557dcd6c0031 /extra
parent5110f15fa238acd2e67844531904108245517cbb (diff)
downloadchrome-ec-3793a83cbd7349b07453cc5a44674f9e7bc856f3.tar.gz
Revert "ec-devutils: update pyusb to 1.0.2"
This reverts commit 7d26ae49bffcf269df82df7d0fee00e8c3341166. pyusb 1.0.2 fails under load and locks up the usb endpoint. BUG=b:111658037, chromium:865482 TEST=while RES=$(dut-control ec_uart_en spi1_buf_en ); do echo ${RES}; done CQ-DEPEND=CL:1149509 Original change's description: > ec-devutils: update pyusb to 1.0.2 > > Pyusb interface has changed yet again. Patch calls to get_string > and usb.core.find. Modify ordering of detetch kernel driver > and avoid rereferencing endpoints. > > BRANCH=None > BUG=b:110907544 > TEST=emerge ec-devutils, run powerlog, usb_console, servo_updater > > CQ-DEPEND=CL:1119632 > > Signed-off-by: Nick Sanders <nsanders@chromium.org> > > Change-Id: I33df474ce3bb57d2e11c9f384ac013b51d210843 > Reviewed-on: https://chromium-review.googlesource.com/1125354 > Commit-Ready: Nick Sanders <nsanders@chromium.org> > Tested-by: Nick Sanders <nsanders@chromium.org> > Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Bug: b:110907544 Change-Id: I04f015b4924e7fee76ab0f1734267e8e2d14faaa Reviewed-on: https://chromium-review.googlesource.com/1150963 Commit-Ready: Nick Sanders <nsanders@chromium.org> Tested-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Nick Sanders <nsanders@chromium.org>
Diffstat (limited to 'extra')
-rw-r--r--extra/tigertool/ecusb/stm32uart.py1
-rw-r--r--extra/tigertool/ecusb/stm32usb.py25
-rwxr-xr-xextra/usb_power/powerlog.py3
-rwxr-xr-xextra/usb_serial/console.py3
-rwxr-xr-xextra/usb_updater/fw_update.py5
5 files changed, 13 insertions, 24 deletions
diff --git a/extra/tigertool/ecusb/stm32uart.py b/extra/tigertool/ecusb/stm32uart.py
index 21fcbd2cc2..459ca8e90f 100644
--- a/extra/tigertool/ecusb/stm32uart.py
+++ b/extra/tigertool/ecusb/stm32uart.py
@@ -73,7 +73,6 @@ class Suart(object):
if self._tx_thread:
self._tx_thread.join(2)
self._tx_thread = None
- self._susb.close()
def run_rx_thread(self):
"""Background loop to pass data from USB to pty."""
diff --git a/extra/tigertool/ecusb/stm32usb.py b/extra/tigertool/ecusb/stm32usb.py
index 3d3627e8ab..b8ffb2765e 100644
--- a/extra/tigertool/ecusb/stm32usb.py
+++ b/extra/tigertool/ecusb/stm32usb.py
@@ -57,10 +57,8 @@ class Susb(object):
def _find_device(self):
"""Set up the usb endpoint"""
# Find the stm32.
- dev_g = usb.core.find(idVendor=self._vendor, idProduct=self._product,
+ dev_list = usb.core.find(idVendor=self._vendor, idProduct=self._product,
find_all=True)
- dev_list = list(dev_g)
-
if not dev_list:
raise SusbError('USB device not found')
@@ -68,7 +66,7 @@ class Susb(object):
dev = None
if self._serialname:
for d in dev_list:
- dev_serial = usb.util.get_string(d, d.iSerialNumber)
+ dev_serial = usb.util.get_string(d, 256, d.iSerialNumber)
if dev_serial == self._serialname:
dev = d
break
@@ -81,20 +79,12 @@ class Susb(object):
raise SusbError('USB device %04x:%04x not found' % (
self._vendor, self._product))
- # Detach raiden.ko if it is loaded. CCD endpoints support either a kernel
- # module driver that produces a ttyUSB, or direct endpoint access, but
- # can't do both at the same time.
- if dev.is_kernel_driver_active(self._interface) is True:
- dev.detach_kernel_driver(self._interface)
-
# If we can't set configuration, it's already been set.
try:
dev.set_configuration()
- except usb.core.USBError as e:
+ except usb.core.USBError:
pass
- self._dev = dev
-
# Get an endpoint instance.
cfg = dev.get_active_configuration()
intf = usb.util.find_descriptor(cfg, bInterfaceNumber=self._interface)
@@ -103,6 +93,12 @@ class Susb(object):
raise SusbError('Interface %04x:%04x - 0x%x not found' % (
self._vendor, self._product, self._interface))
+ # Detach raiden.ko if it is loaded. CCD endpoints support either a kernel
+ # module driver that produces a ttyUSB, or direct endpoint access, but
+ # can't do both at the same time.
+ if dev.is_kernel_driver_active(intf.bInterfaceNumber) is True:
+ dev.detach_kernel_driver(intf.bInterfaceNumber)
+
read_ep_number = intf.bInterfaceNumber + self.READ_ENDPOINT
read_ep = usb.util.find_descriptor(intf, bEndpointAddress=read_ep_number)
self._read_ep = read_ep
@@ -110,6 +106,3 @@ class Susb(object):
write_ep_number = intf.bInterfaceNumber + self.WRITE_ENDPOINT
write_ep = usb.util.find_descriptor(intf, bEndpointAddress=write_ep_number)
self._write_ep = write_ep
-
- def close(self):
- usb.util.dispose_resources(self._dev)
diff --git a/extra/usb_power/powerlog.py b/extra/usb_power/powerlog.py
index a8fcae9c9d..82950100f2 100755
--- a/extra/usb_power/powerlog.py
+++ b/extra/usb_power/powerlog.py
@@ -159,8 +159,7 @@ class Spower(object):
self._board = board
# Find the stm32.
- dev_g = usb.core.find(idVendor=vendor, idProduct=product, find_all=True)
- dev_list = list(dev_g)
+ dev_list = usb.core.find(idVendor=vendor, idProduct=product, find_all=True)
if dev_list is None:
raise Exception("Power", "USB device not found")
diff --git a/extra/usb_serial/console.py b/extra/usb_serial/console.py
index e3288b8593..2494c59c79 100755
--- a/extra/usb_serial/console.py
+++ b/extra/usb_serial/console.py
@@ -71,8 +71,7 @@ class Susb():
SusbError: An error accessing Susb object
"""
# Find the device.
- dev_g = usb.core.find(idVendor=vendor, idProduct=product, find_all=True)
- dev_list = list(dev_g)
+ dev_list = usb.core.find(idVendor=vendor, idProduct=product, find_all=True)
if dev_list is None:
raise SusbError("USB device not found")
diff --git a/extra/usb_updater/fw_update.py b/extra/usb_updater/fw_update.py
index 8a73070ccf..367c0cad14 100755
--- a/extra/usb_updater/fw_update.py
+++ b/extra/usb_updater/fw_update.py
@@ -67,8 +67,7 @@ class Supdate(object):
vendor = self._brdcfg['vid']
product = self._brdcfg['pid']
- dev_g = usb.core.find(idVendor=vendor, idProduct=product, find_all=True)
- dev_list = list(dev_g)
+ dev_list = usb.core.find(idVendor=vendor, idProduct=product, find_all=True)
if dev_list is None:
raise Exception("Update", "USB device not found")
@@ -76,7 +75,7 @@ class Supdate(object):
dev = None
if serialname:
for d in dev_list:
- if usb.util.get_string(d, d.iSerialNumber) == serialname:
+ if usb.util.get_string(d, 256, d.iSerialNumber) == serialname:
dev = d
break
if dev is None: