summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonghoon Shin <dhs.shine@gmail.com>2017-02-03 11:09:55 +0900
committerDonghoon Shin <dhs.shine@gmail.com>2017-02-03 11:09:57 +0900
commit995ac11edbe873add500e35d6c231a96d11945d7 (patch)
tree5cf0de91fe65642e1b76168611d4af7c165d6583
parenta8019291e80ab2ca2ff449b8ca3837c4fa867a42 (diff)
downloadlitmus-995ac11edbe873add500e35d6c231a96d11945d7.tar.gz
litmus-995ac11edbe873add500e35d6c231a96d11945d7.tar.bz2
litmus-995ac11edbe873add500e35d6c231a96d11945d7.zip
Add workarounds for non-standlaone devices
Reopen uart if it has some issues
-rw-r--r--litmus/device/device.py36
-rw-r--r--litmus/device/devicestandalone.py8
2 files changed, 34 insertions, 10 deletions
diff --git a/litmus/device/device.py b/litmus/device/device.py
index 811f14c..3478ac6 100644
--- a/litmus/device/device.py
+++ b/litmus/device/device.py
@@ -141,6 +141,8 @@ class device(object):
try:
self.off(1)
self._cutter.on(powercut_delay)
+ self._uart.close()
+ self._uart.open()
self._wait_uart_shell_login_prompt()
self._login_uart_shell()
self._set_sdb_deviceid()
@@ -456,10 +458,25 @@ class device(object):
if self._uart.isOpen():
self._uart.close()
+ def _close_open_uart(self):
+ """docstring for close_open_uart"""
+ retrycnt = 0
+ while retrycnt < 10:
+ retrycnt += 1
+ try:
+ self._uart.close()
+ self._uart.open()
+ except:
+ time.sleep(0.1)
+
def _thread_for_enter_download_mode(self, cmd, count):
"""docstring for thread_for_enter_download_mode"""
for loop in range(count*20):
+ try:
self._uart.write(self._enterkey)
+ except serial.SerialException as err:
+ logging.debug(err)
+ self._close_open_uart()
time.sleep(0.05)
self._uart.write(cmd)
for loop in range(2):
@@ -497,7 +514,7 @@ class device(object):
for l in filenames:
cmd += ' {}'.format(l)
logging.debug(cmd)
- ret = call(cmd.split(), timeout=600)
+ ret = call(cmd, shell=True, timeout=600)
if ret:
raise Exception('Thor error.')
@@ -524,20 +541,19 @@ class device(object):
def _heimdall(self, filenames, busaddr, devaddr, partition_bin_mappings):
"""docstring for _heimdall"""
filenames = convert_single_item_to_list(filenames)
- tar_cmd = ['tar', 'xvfz']
+ tar_cmd = 'tar xvfz'
for l in filenames:
- tar_cmd.append(l)
+ tar_cmd += ' {}'.format(l)
logging.debug(tar_cmd)
- call(tar_cmd, timeout=30)
+ call(tar_cmd, shell=True, timeout=30)
- heimdall_cmd = ['heimdall', 'flash', '--usbbus', busaddr,
- '--usbdevaddr', devaddr]
+ heimdall_cmd = 'heimdall flash --usbbus {0} --usbdevaddr {1}'.format(busaddr, devaddr)
for key, elem in partition_bin_mappings.items():
- heimdall_cmd.append('--{}'.format(key))
- heimdall_cmd.append(elem)
+ heimdall_cmd += ' --{}'.format(key)
+ heimdall_cmd += ' {}'.format(elem)
logging.debug(heimdall_cmd)
- ret = call(heimdall_cmd, timeout=600)
+ ret = call(heimdall_cmd, shell=True, timeout=600)
if ret:
raise Exception('Heimdall error.')
@@ -648,7 +664,7 @@ class device(object):
def sdb_root_on(self):
"""docstring for sdb_root_on"""
- logging.debug('=================sdb root on for {}================='
+ logging.debug('=================sdb root on for {}=================='
.format(self.get_name()))
call('sdb -s {} root on'.format(self.get_id()).split(), timeout=10)
time.sleep(0.5)
diff --git a/litmus/device/devicestandalone.py b/litmus/device/devicestandalone.py
index 99ed73f..130b9f0 100644
--- a/litmus/device/devicestandalone.py
+++ b/litmus/device/devicestandalone.py
@@ -37,6 +37,11 @@ class devicestandalone(device):
else:
self._id = self._find_device_id()
+ if 'usbid' in kwargs:
+ self._usbid = kwargs['usbid']
+ else:
+ self._usbid = None
+
self._manager = kwargs['manager']
def _release(self):
@@ -130,7 +135,10 @@ class devicestandalone(device):
self.run_cmd('reboot -f download', timeout=20)
time.sleep(waiting)
if flasher == 'lthor':
+ if self._usbid == None:
busid = self._find_usb_busid()
+ else:
+ busid = self._usbid
self._release_global_lock()
self._lthor(filenames=filenames, busid=busid)
elif flasher == 'heimdall':