Skip to content

Commit aaddb2f

Browse files
Merge branch 'master' into colorama_version
2 parents 74c3e2e + b73bad3 commit aaddb2f

File tree

4 files changed

+27
-64
lines changed

4 files changed

+27
-64
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def read(fname):
4646
install_requires=[
4747
"PySerial>=3.0",
4848
"requests",
49-
"pyOCD==0.12.0",
49+
"pyocd==0.14.0",
5050
"intelhex",
5151
"future",
5252
"PrettyTable>=0.7.2",

src/mbed_os_tools/test/host_tests_plugins/module_copy_pyocd.py

Lines changed: 7 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,10 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
from intelhex import IntelHex
17-
import itertools
1816
import os
19-
from pyOCD.board import MbedBoard
20-
2117
from .host_test_plugins import HostTestPluginBase
22-
23-
24-
def _enum_continguous_addr_start_end(addr_list):
25-
"""Generator to get contiguous address ranges with start and end address"""
26-
for _, b in itertools.groupby(enumerate(addr_list), lambda x_y: x_y[1] - x_y[0]):
27-
b = list(b)
28-
yield b[0][1], b[-1][1]
18+
from pyocd.core.helpers import ConnectHelper
19+
from pyocd.flash.loader import FileProgrammer
2920

3021

3122
class HostTestPluginCopyMethod_pyOCD(HostTestPluginBase):
@@ -48,7 +39,6 @@ def setup(self, *args, **kwargs):
4839

4940
def execute(self, capability, *args, **kwargs):
5041
"""! Executes capability by name
51-
5242
@param capability Capability name
5343
@param args Additional arguments
5444
@param kwargs Additional arguments
@@ -67,7 +57,7 @@ def execute(self, capability, *args, **kwargs):
6757

6858
target_id = kwargs['target_id']
6959
image_path = os.path.normpath(kwargs['image_path'])
70-
with MbedBoard.chooseBoard(board_id=target_id) as board:
60+
with ConnectHelper.session_with_chosen_probe(unique_id=target_id, resume_on_disconnect=False) as session:
7161
# Performance hack!
7262
# Eventually pyOCD will know default clock speed
7363
# per target
@@ -81,51 +71,11 @@ def execute(self, capability, *args, **kwargs):
8171
test_clock = 1000000
8272

8373
# Configure link
84-
board.link.set_clock(test_clock)
85-
board.link.set_deferred_transfer(True)
86-
87-
# Collect address, data pairs for programming
88-
program_list = []
89-
extension = os.path.splitext(image_path)[1]
90-
if extension == '.bin':
91-
# Binary file format
92-
memory_map = board.target.getMemoryMap()
93-
rom_region = memory_map.getBootMemory()
94-
with open(image_path, "rb") as file_handle:
95-
program_data = file_handle.read()
96-
program_list.append((rom_region.start, program_data))
97-
elif extension == '.hex':
98-
# Intel hex file format
99-
ihex = IntelHex(image_path)
100-
addresses = ihex.addresses()
101-
addresses.sort()
102-
for start, end in _enum_continguous_addr_start_end(addresses):
103-
size = end - start + 1
104-
data = ihex.tobinarray(start=start, size=size)
105-
data = bytearray(data)
106-
program_list.append((start, data))
107-
else:
108-
# Unsupported
109-
raise Exception("Unsupported file format %s" % extension)
110-
111-
# Program data
112-
flash_builder = board.flash.getFlashBuilder()
113-
for addr, data in program_list:
114-
flash_builder.addData(addr, list(bytearray(data)))
115-
flash_builder.program()
116-
117-
# Read back and verify programming was successful
118-
for addr, data in program_list:
119-
read_data = board.target.readBlockMemoryUnaligned8(addr,
120-
len(data))
121-
read_data = bytearray(read_data)
122-
if bytes(data) != bytes(read_data):
123-
raise Exception("Flash programming error - failed to "
124-
"program address 0x%x size %s" %
125-
(addr, len(data)))
74+
session.probe.set_clock(test_clock)
12675

127-
# Cleanup
128-
board.uninit(resume=False)
76+
# Program the file
77+
programmer = FileProgrammer(session)
78+
programmer.program(image_path)
12979

13080
return True
13181

src/mbed_os_tools/test/host_tests_plugins/module_reset_pyocd.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15-
from pyOCD.board import MbedBoard
15+
1616
from .host_test_plugins import HostTestPluginBase
17+
from pyocd.core.helpers import ConnectHelper
18+
1719

1820
class HostTestPluginResetMethod_pyOCD(HostTestPluginBase):
1921

@@ -26,6 +28,10 @@ class HostTestPluginResetMethod_pyOCD(HostTestPluginBase):
2628

2729
def __init__(self):
2830
"""! ctor
31+
@details We can check module version by referring to version attribute
32+
import pkg_resources
33+
print pkg_resources.require("mbed-host-tests")[0].version
34+
'2.7'
2935
"""
3036
HostTestPluginBase.__init__(self)
3137

@@ -36,7 +42,6 @@ def setup(self, *args, **kwargs):
3642

3743
def execute(self, capability, *args, **kwargs):
3844
"""! Executes capability by name
39-
4045
@param capability Capability name
4146
@param args Additional arguments
4247
@param kwargs Additional arguments
@@ -52,10 +57,10 @@ def execute(self, capability, *args, **kwargs):
5257
if kwargs['target_id']:
5358
if capability == 'pyocd':
5459
target_id = kwargs['target_id']
55-
with MbedBoard.chooseBoard(board_id=target_id) as board:
56-
board.target.reset()
57-
board.target.resume()
58-
board.uninit(resume=False)
60+
with ConnectHelper.session_with_chosen_probe(unique_id=target_id,
61+
resume_on_disconnect=False) as session:
62+
session.target.reset()
63+
session.target.resume()
5964
result = True
6065
return result
6166

src/mbed_os_tools/test/host_tests_runner/host_test_default.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,14 @@ def process_code_coverage(key, value, timestamp):
427427
self.logger.prn_inf("%s received"% (key))
428428
callbacks__exit_event_queue = True
429429
break
430+
elif key == '__timeout_set':
431+
# Dynamic timeout set
432+
timeout_duration = int(value) # New timeout
433+
self.logger.prn_inf("setting timeout to: %d sec"% int(value))
434+
elif key == '__timeout_adjust':
435+
# Dynamic timeout adjust
436+
timeout_duration = timeout_duration + int(value) # adjust time
437+
self.logger.prn_inf("adjusting timeout with %d sec (now %d)" % (int(value), timeout_duration))
430438
elif key in callbacks:
431439
# Handle callback
432440
callbacks[key](key, value, timestamp)

0 commit comments

Comments
 (0)