diff --git a/CODEOWNERS b/CODEOWNERS index e8a02dcf32..e766eac362 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -374,6 +374,7 @@ /scripts/net/ @jukkar @pfl /scripts/process_gperf.py @andrewboie /scripts/gen_relocate_app.py @wentongwu +/scripts/tracing/ @wentongwu /scripts/sanity_chk/ @nashif /scripts/sanitycheck @nashif /scripts/series-push-hook.sh @erwango diff --git a/scripts/tracing/trace_capture_uart.py b/scripts/tracing/trace_capture_uart.py new file mode 100644 index 0000000000..03316cd98c --- /dev/null +++ b/scripts/tracing/trace_capture_uart.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python3 +# +# Copyright (c) 2019 Intel Corporation. +# +# SPDX-License-Identifier: Apache-2.0 +""" +Script to capture tracing data with UART backend. +""" + +import sys +import serial +import argparse + +def parse_args(): + global args + parser = argparse.ArgumentParser( + description=__doc__, + formatter_class=argparse.RawDescriptionHelpFormatter) + parser.add_argument("-d", "--serial_port", required=True, + help="serial port") + parser.add_argument("-b", "--serial_baudrate", required=True, + help="serial baudrate") + parser.add_argument("-o", "--output", default='channel0_0', + required=False, help="tracing data output file") + args = parser.parse_args() + +def main(): + parse_args() + serial_port = args.serial_port + serial_baudrate = args.serial_baudrate + output_file = args.output + try: + ser = serial.Serial(serial_port, serial_baudrate) + ser.isOpen() + except serial.SerialException as e: + sys.exit("{}".format(e)) + + print("serial open success") + + #enable device tracing + ser.write("enable\r".encode()) + + with open(output_file, "wb") as file_desc: + while True: + count = ser.inWaiting() + if count > 0: + while count > 0: + data = ser.read() + file_desc.write(data) + count -= 1 + + ser.close() + +if __name__=="__main__": + try: + main() + except KeyboardInterrupt: + print('Data capture interrupted, data saved into {}'.format(args.output)) + sys.exit(0)