From af55b454a1dc22055245c22b20e931bee7ee596d Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Thu, 26 Sep 2024 16:44:43 +0300 Subject: [PATCH] tools: debug_stream.py: Use cavstool.debug_slot_offset_by_type() The new cavstool.debug_slot_offset_by_type() opens an opportunity to improve debug_stream.py usability a bit. If the debugfs file is not found, then try to find the correct debug slot the correct slot using cavstool direct access and debug_slot_offset_by_type(). Signed-off-by: Jyri Sarha --- tools/debug_stream/debug_stream.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/debug_stream/debug_stream.py b/tools/debug_stream/debug_stream.py index bde98bd9c796..752e53a92d1f 100644 --- a/tools/debug_stream/debug_stream.py +++ b/tools/debug_stream/debug_stream.py @@ -11,6 +11,7 @@ import ctypes import time import sys +import os import logging @@ -505,7 +506,15 @@ def cavstool_main_loop(my_args): while True: if not cavstool.fw_is_alive(dsp): cavstool.wait_fw_entered(dsp, timeout_s=None) - offset = cavstool.debug_slot_offset(my_args.direct_access_slot) + if my_args.direct_access_slot < 0: + offset = cavstool.debug_slot_offset_by_type(ADSP_DW_SLOT_DEBUG_STREAM) + if offset is None: + logging.error("Could not find debug_stream slot") + sys.exit(1) + logging.info("Got offset 0x%08x by type 0x%08x", offset, + ADSP_DW_SLOT_DEBUG_STREAM) + else: + offset = cavstool.debug_slot_offset(my_args.direct_access_slot) buf = cavstool.win_read(offset, 0, DEBUG_SLOT_SIZE) decoder.set_slot(buf) if not decoder.get_descriptors(): @@ -529,7 +538,7 @@ def main_f(my_args): about the host CPU load. That is why there where no synchronous mechanism done and the host simply polls for new records. """ - if my_args.direct_access_slot >= 0: + if my_args.direct_access_slot >= 0 or not os.path.isfile(my_args.debugstream_file): return cavstool_main_loop(my_args) decoder = DebugStreamDecoder() prev_error = None