Skip to content

Commit 23ceb5f

Browse files
committed
Publish raw TPIU stream to TCP port
1 parent 4c3047b commit 23ceb5f

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

pyocd/core/options.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# pyOCD debugger
22
# Copyright (c) 2018-2020 Arm Limited
3+
# Copyright (c) 2020 Patrick Huesmann
34
# SPDX-License-Identifier: Apache-2.0
45
#
56
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -136,6 +137,8 @@
136137
OptionInfo('swv_system_clock', int, None,
137138
"Frequency in Hertz of the target's system clock. Used to compute the SWO baud rate "
138139
"divider. No default."),
140+
OptionInfo('tpiu_port', int, 3443,
141+
"TCP port number for the raw TPIU stream server."),
139142
OptionInfo('telnet_port', int, 4444,
140143
"Base TCP port number for the semihosting telnet server."),
141144
OptionInfo('vector_catch', str, 'h',

pyocd/trace/swv.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# pyOCD debugger
22
# Copyright (c) 2019-2020 Arm Limited
3+
# Copyright (c) 2020 Patrick Huesmann
34
# SPDX-License-Identifier: Apache-2.0
45
#
56
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -27,6 +28,7 @@
2728
from ..core.target import Target
2829
from ..core import exceptions
2930
from ..probe.debug_probe import DebugProbe
31+
from ..utility.server import StreamServer
3032

3133
LOG = logging.getLogger(__name__)
3234

@@ -155,6 +157,10 @@ def run(self):
155157
if self._lock:
156158
self._lock.acquire()
157159

160+
tpiu_port = self._session.options.get('tpiu_port')
161+
tpiu_server = StreamServer(tpiu_port, name="TPIU", is_read_only=True) \
162+
if tpiu_port else None
163+
158164
# Stop SWO first in case the probe already had it started. Ignore if this fails.
159165
try:
160166
self._session.probe.swo_stop()
@@ -165,6 +171,8 @@ def run(self):
165171
while not self._shutdown_event.is_set():
166172
data = self._session.probe.swo_read()
167173
if data:
174+
if tpiu_server:
175+
tpiu_server.write(data)
168176
self._parser.parse(data)
169177

170178
if self._lock:
@@ -177,6 +185,9 @@ def run(self):
177185

178186
self._session.probe.swo_stop()
179187

188+
if tpiu_server:
189+
tpiu_server.stop()
190+
180191
if self._lock:
181192
self._lock.release()
182193

0 commit comments

Comments
 (0)