summaryrefslogtreecommitdiff
path: root/extra/tigertool/ecusb/stm32uart.py
diff options
context:
space:
mode:
authorNick Sanders <nsanders@chromium.org>2017-09-14 16:16:10 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-10-25 01:38:45 -0700
commit28a5ad1646b2994853e310354b604547950a55c0 (patch)
tree066c2af5e0b90f03dc2a92eecfa2d20c32f5bca4 /extra/tigertool/ecusb/stm32uart.py
parentc49d32a265ea76d9af55ccbcbda90e27748de1a3 (diff)
downloadchrome-ec-28a5ad1646b2994853e310354b604547950a55c0.tar.gz
servo: add usb updater
This updater combines console and firmware update commands to update both RO and RW sections of servo_v4 and servo_micro. BRANCH=None BUG=b:37513705 TEST=updated firmware Change-Id: I9f585c90f5849f8dd7c9d2e08111ffbd5770fd54 Signed-off-by: Nick Sanders <nsanders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/668156 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'extra/tigertool/ecusb/stm32uart.py')
-rw-r--r--extra/tigertool/ecusb/stm32uart.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/extra/tigertool/ecusb/stm32uart.py b/extra/tigertool/ecusb/stm32uart.py
index 3f39b23faa..459ca8e90f 100644
--- a/extra/tigertool/ecusb/stm32uart.py
+++ b/extra/tigertool/ecusb/stm32uart.py
@@ -4,6 +4,8 @@
"""Allow creation of uart/console interface via stm32 usb endpoint."""
+from __future__ import print_function
+
import os
import select
import sys
@@ -33,7 +35,7 @@ class SuartError(Exception):
class Suart(object):
"""Provide interface to stm32 serial usb endpoint."""
def __init__(self, vendor=0x18d1, product=0x501a, interface=0,
- serialname=None, ftdi_context=None):
+ serialname=None, debuglog=False):
"""Suart contstructor.
Initializes stm32 USB stream interface.
@@ -42,8 +44,8 @@ class Suart(object):
vendor: usb vendor id of stm32 device
product: usb product id of stm32 device
interface: interface number of stm32 device to use
- serialname: n/a. Defaults to None.
- ftdi_context: n/a. Defaults to None.
+ serialname: serial name to target. Defaults to None.
+ debuglog: chatty output. Defaults to False.
Raises:
SuartError: If init fails
@@ -53,6 +55,7 @@ class Suart(object):
self._ptyname = None
self._rx_thread = None
self._tx_thread = None
+ self._debuglog = debuglog
self._susb = stm32usb.Susb(vendor=vendor, product=product,
interface=interface, serialname=serialname)
self._running = False
@@ -83,6 +86,8 @@ class Suart(object):
try:
r = self._susb._read_ep.read(64, self._susb.TIMEOUT_MS)
if r:
+ if self._debuglog:
+ print(''.join([chr(x) for x in r]), end='')
os.write(self._ptym, r)
# If we miss some characters on pty disconnect, that's fine.