To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 7fc81060 authored by Roman Trüb's avatar Roman Trüb
Browse files

added support to parse ITM synchronization packets

parent 2f5c82d6
......@@ -244,6 +244,21 @@ class SwoParser():
ret += "\n globalTs: {}".format(self.globalTs)
return ret
class SynchronizationPkt(SwoPkt):
'''Synchronization Packet generated by ITM, as defined in ARMv7-M Reference Manual (at least 5 0x00 bytes followed by a 0x80 byte)
'''
def __init__(self, header, globalTs=None):
super().__init__(header, globalTs)
def isComplete(self):
# sync packet is recognized with last byte only -> always complete when instantiated
return True
def __str__(self):
ret = "SynchronizationPkt"
ret += "\n globalTs: {}".format(self.globalTs)
return ret
def addSwoByte(self, swoByte, globalTs=None):
"""
......@@ -252,7 +267,8 @@ class SwoParser():
NOTE: SWO bytes need to be inserted in the correct sequence (as outputted by the SWO port)
Returns: (packet, newSyncEpoch)
packet: Parsed packet object if provided swoByte leads to the completion of a packet, None otherwise
newSyncEpoch: True if a new sync epoch started (i.e. sync packet received and first non-zero byte added), False otherwise
newSyncEpoch: True if a new sync epoch started (i.e. sync packet received and first non-zero byte added), False otherwise; NOTE: here, sync packet refers to 0x00 bytes when MCU is in reset mode, not real ITM synchronization packets as defined in ARMv7-M reference manual
parseError: Errors occurred when parsing the SWO byte stream
"""
retPkt = None
newSyncEpoch = False
......@@ -265,16 +281,23 @@ class SwoParser():
# process sync packet (to sync to packet in byte stream)
if self._processingSyncPkt:
# read all zeros until get an 0x80, then we are in sync (Synchronization packet)
# NOTE: dpp2lora bytestream does not contain required single-bit in Synchronization packet
# NOTE: dpp2lora byte stream can contain two type of sync packets
# * reset-sync-packet: multiple 0x00 bytes without single-bit byte (0x80) at the end
# * ITM-sync-packet: 5 or more 0x00 bytes followed by a single-bit byte (0x80) at the end
if swoByte == 0:
return retPkt, newSyncEpoch, parseError
# elif swoByte == 0x08:
# return retPkt, newSyncEpoch
elif swoByte == 0x80:
# got a 128 (0x80) byte (last byte of ITM-sync-packet), current byte is NOT processed, no new sync epoch is started
retPkt = type(self).SynchronizationPkt(header=0, globalTs=globalTs)
self._processingSyncPkt = False
return retPkt, newSyncEpoch, parseError
else:
# got a non-0 byte -> sync pkt finished, current byte is processed and interpreted as header
# got a non-0 byte -> reset-sync-pkt finished, current byte is processed and interpreted as header, new sync epoch is started
self._processingSyncPkt = False
newSyncEpoch = True
# no return here, current byte is processed!
# parse packets with content
if len(self._currentPkt) == 0:
......@@ -375,6 +398,10 @@ def processDatatraceOutput(input_file, cpuSpeed, prescaler=None, loopdelay=None)
dfOverflowList = []
for i, pktList in enumerate(syncEpochList):
print('INFO: Sync Epoch {}'.format(i))
# remove ITM-sync-packets
pktList = [pkt for pkt in pktList if type(pkt) != SwoParser.SynchronizationPkt]
# split localTs epochs
batchList = splitEpochs(pktList)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment