mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-04 13:14:32 +02:00
Merge branch 'feature/update-openocd-to-v0.12.0-esp32-20250707' into 'master'
feat(tools): update openocd version to v0.12.0-esp32-20250707 See merge request espressif/esp-idf!40396
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-1-Clause
|
||||
*
|
||||
* SPDX-FileContributor: 2017-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileContributor: 2017-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*/
|
||||
/*********************************************************************
|
||||
* SEGGER Microcontroller GmbH *
|
||||
@@ -84,11 +84,7 @@ extern const SEGGER_SYSVIEW_OS_API SYSVIEW_X_OS_TraceAPI;
|
||||
// The target device name
|
||||
#define SYSVIEW_DEVICE_NAME CONFIG_IDF_TARGET
|
||||
// The target core name
|
||||
#if CONFIG_IDF_TARGET_ARCH_XTENSA
|
||||
#define SYSVIEW_CORE_NAME "xtensa"
|
||||
#elif CONFIG_IDF_TARGET_ARCH_RISCV
|
||||
#define SYSVIEW_CORE_NAME "riscv"
|
||||
#endif
|
||||
#define SYSVIEW_CORE_NAME "core0" // In dual core, this will be renamed by OpenOCD as core1
|
||||
|
||||
// Determine which timer to use as timestamp source
|
||||
#if CONFIG_APPTRACE_SV_TS_SOURCE_CCOUNT
|
||||
|
@@ -97,7 +97,7 @@
|
||||
- ESP32 target configuration file. Can be used together with one of the ``interface/`` configuration files.
|
||||
* - ``target/esp32-solo-1.cfg``
|
||||
- Target configuration file for ESP32-SOLO-1 module. Different from ``esp32.cfg`` in that it only configures one CPU.
|
||||
* - ``interface/ftdi/esp32_devkitj_v1.cfg``
|
||||
* - ``interface/ftdi/esp_ftdi.cfg``
|
||||
- JTAG adapter configuration file for ESP-WROVER-KIT and ESP-Prog boards.
|
||||
|
||||
---
|
||||
|
@@ -94,7 +94,7 @@
|
||||
- Board configuration file for ESP32-C2 debug through an ESP-Prog compatible FTDI, includes target and adapter configuration.
|
||||
* - ``target/esp32c2.cfg``
|
||||
- ESP32-C2 target configuration file. Can be used together with one of the ``interface/`` configuration files.
|
||||
* - ``interface/ftdi/esp32_devkitj_v1.cfg``
|
||||
* - ``interface/ftdi/esp_ftdi.cfg``
|
||||
- JTAG adapter configuration file for ESP-Prog boards.
|
||||
|
||||
---
|
||||
|
@@ -97,7 +97,7 @@
|
||||
- ESP32-C3 target configuration file. Can be used together with one of the ``interface/`` configuration files.
|
||||
* - ``interface/esp_usb_jtag.cfg``
|
||||
- JTAG adapter configuration file for ESP32-C3.
|
||||
* - ``interface/ftdi/esp32_devkitj_v1.cfg``
|
||||
* - ``interface/ftdi/esp_ftdi.cfg``
|
||||
- JTAG adapter configuration file for ESP-Prog boards.
|
||||
|
||||
---
|
||||
|
@@ -103,7 +103,7 @@
|
||||
- ESP32-C5 target configuration file. Can be used together with one of the ``interface/`` configuration files.
|
||||
* - ``interface/esp_usb_jtag.cfg``
|
||||
- JTAG adapter configuration file for ESP32-C5.
|
||||
* - ``interface/ftdi/esp32_devkitj_v1.cfg``
|
||||
* - ``interface/ftdi/esp_ftdi.cfg``
|
||||
- JTAG adapter configuration file for ESP-Prog boards.
|
||||
|
||||
---
|
||||
|
@@ -102,7 +102,7 @@
|
||||
- ESP32-C6 target configuration file. Can be used together with one of the ``interface/`` configuration files.
|
||||
* - ``interface/esp_usb_jtag.cfg``
|
||||
- JTAG adapter configuration file for ESP32-C6.
|
||||
* - ``interface/ftdi/esp32_devkitj_v1.cfg``
|
||||
* - ``interface/ftdi/esp_ftdi.cfg``
|
||||
- JTAG adapter configuration file for ESP-Prog boards.
|
||||
|
||||
---
|
||||
|
@@ -103,7 +103,7 @@
|
||||
- ESP32-C61 target configuration file. Can be used together with one of the ``interface/`` configuration files.
|
||||
* - ``interface/esp_usb_jtag.cfg``
|
||||
- JTAG adapter configuration file for ESP32-C61.
|
||||
* - ``interface/ftdi/esp32_devkitj_v1.cfg``
|
||||
* - ``interface/ftdi/esp_ftdi.cfg``
|
||||
- JTAG adapter configuration file for ESP-Prog boards.
|
||||
|
||||
---
|
||||
|
@@ -100,7 +100,7 @@
|
||||
- ESP32-H2 target configuration file. Can be used together with one of the ``interface/`` configuration files.
|
||||
* - ``interface/esp_usb_jtag.cfg``
|
||||
- JTAG adapter configuration file for ESP32-H2.
|
||||
* - ``interface/ftdi/esp32_devkitj_v1.cfg``
|
||||
* - ``interface/ftdi/esp_ftdi.cfg``
|
||||
- JTAG adapter configuration file for ESP-Prog boards.
|
||||
|
||||
---
|
||||
|
@@ -100,7 +100,7 @@
|
||||
- ESP32-H2 target configuration file. Can be used together with one of the ``interface/`` configuration files.
|
||||
* - ``interface/esp_usb_jtag.cfg``
|
||||
- JTAG adapter configuration file for ESP32-H2.
|
||||
* - ``interface/ftdi/esp32_devkitj_v1.cfg``
|
||||
* - ``interface/ftdi/esp_ftdi.cfg``
|
||||
- JTAG adapter configuration file for ESP-Prog boards.
|
||||
|
||||
---
|
||||
|
@@ -100,7 +100,7 @@
|
||||
- ESP32-H2 target configuration file. Can be used together with one of the ``interface/`` configuration files.
|
||||
* - ``interface/esp_usb_jtag.cfg``
|
||||
- JTAG adapter configuration file for ESP32-H2.
|
||||
* - ``interface/ftdi/esp32_devkitj_v1.cfg``
|
||||
* - ``interface/ftdi/esp_ftdi.cfg``
|
||||
- JTAG adapter configuration file for ESP-Prog boards.
|
||||
|
||||
---
|
||||
|
@@ -107,7 +107,7 @@
|
||||
- ESP32-P4 target configuration file. Can be used together with one of the ``interface/`` configuration files.
|
||||
* - ``interface/esp_usb_jtag.cfg``
|
||||
- JTAG adapter configuration file for ESP32-P4.
|
||||
* - ``interface/ftdi/esp32p4_ftdi.cfg``
|
||||
* - ``interface/ftdi/esp_ftdi.cfg``
|
||||
- JTAG adapter configuration file for ESP-Prog boards.
|
||||
|
||||
---
|
||||
|
@@ -92,7 +92,7 @@
|
||||
- ESP32-S2 target configuration file. Can be used together with one of the ``interface/`` configuration files.
|
||||
* - ``interface/ftdi/esp32s2_kaluga_v1.cfg``
|
||||
- JTAG adapter configuration file for ESP32-S2-Kaluga-1 board.
|
||||
* - ``interface/ftdi/esp32_devkitj_v1.cfg``
|
||||
* - ``interface/ftdi/esp_ftdi.cfg``
|
||||
- JTAG adapter configuration file for ESP-Prog boards.
|
||||
|
||||
---
|
||||
|
@@ -101,7 +101,7 @@
|
||||
- ESP32-S3 target configuration file. Can be used together with one of the ``interface/`` configuration files.
|
||||
* - ``interface/ftdi/esp_usb_jtag.cfg``
|
||||
- JTAG adapter configuration file for ESP32-S3 builtin USB JTAG.
|
||||
* - ``interface/ftdi/esp32_devkitj_v1.cfg``
|
||||
* - ``interface/ftdi/esp_ftdi.cfg``
|
||||
- JTAG adapter configuration file for ESP-Prog debug adapter board.
|
||||
|
||||
---
|
||||
|
@@ -97,7 +97,7 @@
|
||||
- ESP32 的目标配置文件,可以和某个 ``interface/`` 下的配置文件一同使用
|
||||
* - ``target/esp32-solo-1.cfg``
|
||||
- ESP32-SOLO-1 模组的目标配置文件,和 ``esp32.cfg`` 的差别在于它仅配置一个 CPU
|
||||
* - ``interface/ftdi/esp32_devkitj_v1.cfg``
|
||||
* - ``interface/ftdi/esp_ftdi.cfg``
|
||||
- 适用于 ESP-WROVER-KIT 和 ESP-Prog 的 JTAG 适配器配置文件
|
||||
|
||||
---
|
||||
|
@@ -94,7 +94,7 @@
|
||||
- Board configuration file for ESP32-C2 debug through an ESP-Prog compatible FTDI, includes target and adapter configuration.
|
||||
* - ``target/esp32c2.cfg``
|
||||
- ESP32-C2 target configuration file. Can be used together with one of the ``interface/`` configuration files.
|
||||
* - ``interface/ftdi/esp32_devkitj_v1.cfg``
|
||||
* - ``interface/ftdi/esp_ftdi.cfg``
|
||||
- JTAG adapter configuration file for ESP-Prog boards.
|
||||
|
||||
---
|
||||
|
@@ -97,7 +97,7 @@
|
||||
- ESP32-C3 目标配置文件。可以和某个 ``interface/`` 下的配置文件一同使用。
|
||||
* - ``interface/esp_usb_jtag.cfg``
|
||||
- 适用于 ESP32-C3 的 JTAG 适配器配置文件。
|
||||
* - ``interface/ftdi/esp32_devkitj_v1.cfg``
|
||||
* - ``interface/ftdi/esp_ftdi.cfg``
|
||||
- 适用于 ESP-Prog 的 JTAG 适配器配置文件。
|
||||
|
||||
---
|
||||
|
@@ -103,7 +103,7 @@
|
||||
- ESP32-C5 target configuration file. Can be used together with one of the ``interface/`` configuration files.
|
||||
* - ``interface/esp_usb_jtag.cfg``
|
||||
- JTAG adapter configuration file for ESP32-C5.
|
||||
* - ``interface/ftdi/esp32_devkitj_v1.cfg``
|
||||
* - ``interface/ftdi/esp_ftdi.cfg``
|
||||
- JTAG adapter configuration file for ESP-Prog boards.
|
||||
|
||||
---
|
||||
|
@@ -102,7 +102,7 @@
|
||||
- ESP32-C6 target configuration file. Can be used together with one of the ``interface/`` configuration files.
|
||||
* - ``interface/esp_usb_jtag.cfg``
|
||||
- JTAG adapter configuration file for ESP32-C6.
|
||||
* - ``interface/ftdi/esp32_devkitj_v1.cfg``
|
||||
* - ``interface/ftdi/esp_ftdi.cfg``
|
||||
- JTAG adapter configuration file for ESP-Prog boards.
|
||||
|
||||
---
|
||||
|
@@ -103,7 +103,7 @@
|
||||
- ESP32-C61 target configuration file. Can be used together with one of the ``interface/`` configuration files.
|
||||
* - ``interface/esp_usb_jtag.cfg``
|
||||
- JTAG adapter configuration file for ESP32-C61.
|
||||
* - ``interface/ftdi/esp32_devkitj_v1.cfg``
|
||||
* - ``interface/ftdi/esp_ftdi.cfg``
|
||||
- JTAG adapter configuration file for ESP-Prog boards.
|
||||
|
||||
---
|
||||
|
@@ -100,7 +100,7 @@
|
||||
- ESP32-H2 target configuration file. Can be used together with one of the ``interface/`` configuration files.
|
||||
* - ``interface/esp_usb_jtag.cfg``
|
||||
- JTAG adapter configuration file for ESP32-H2.
|
||||
* - ``interface/ftdi/esp32_devkitj_v1.cfg``
|
||||
* - ``interface/ftdi/esp_ftdi.cfg``
|
||||
- JTAG adapter configuration file for ESP-Prog boards.
|
||||
|
||||
---
|
||||
|
@@ -100,7 +100,7 @@
|
||||
- ESP32-H2 target configuration file. Can be used together with one of the ``interface/`` configuration files.
|
||||
* - ``interface/esp_usb_jtag.cfg``
|
||||
- JTAG adapter configuration file for ESP32-H2.
|
||||
* - ``interface/ftdi/esp32_devkitj_v1.cfg``
|
||||
* - ``interface/ftdi/esp_ftdi.cfg``
|
||||
- JTAG adapter configuration file for ESP-Prog boards.
|
||||
|
||||
---
|
||||
|
@@ -100,7 +100,7 @@
|
||||
- ESP32-H2 target configuration file. Can be used together with one of the ``interface/`` configuration files.
|
||||
* - ``interface/esp_usb_jtag.cfg``
|
||||
- JTAG adapter configuration file for ESP32-H2.
|
||||
* - ``interface/ftdi/esp32_devkitj_v1.cfg``
|
||||
* - ``interface/ftdi/esp_ftdi.cfg``
|
||||
- JTAG adapter configuration file for ESP-Prog boards.
|
||||
|
||||
---
|
||||
|
@@ -107,7 +107,7 @@
|
||||
- ESP32-P4 target configuration file. Can be used together with one of the ``interface/`` configuration files.
|
||||
* - ``interface/esp_usb_jtag.cfg``
|
||||
- JTAG adapter configuration file for ESP32-P4.
|
||||
* - ``interface/ftdi/esp32p4_ftdi.cfg``
|
||||
* - ``interface/ftdi/esp_ftdi.cfg``
|
||||
- JTAG adapter configuration file for ESP-Prog boards.
|
||||
|
||||
---
|
||||
|
@@ -92,7 +92,7 @@
|
||||
- ESP32-S2 目标配置文件,可以和某个 ``interface/`` 下的配置文件一同使用
|
||||
* - ``interface/ftdi/esp32s2_kaluga_v1.cfg``
|
||||
- 适用于 ESP32-S2-Kaluga-1 开发板的 JTAG 适配器配置文件
|
||||
* - ``interface/ftdi/esp32_devkitj_v1.cfg``
|
||||
* - ``interface/ftdi/esp_ftdi.cfg``
|
||||
- 适用于 ESP-Prog 板的 JTAG 适配器配置文件
|
||||
|
||||
---
|
||||
|
@@ -101,7 +101,7 @@
|
||||
- ESP32-S3 目标配置文件,可以和某个 ``interface/`` 下的配置文件一同使用
|
||||
* - ``interface/ftdi/esp_usb_jtag.cfg``
|
||||
- 适用于 ESP32-S3 的 JTAG 适配器配置文件。
|
||||
* - ``interface/ftdi/esp32_devkitj_v1.cfg``
|
||||
* - ``interface/ftdi/esp_ftdi.cfg``
|
||||
- 适用于 ESP-Prog 的 JTAG 适配器配置文件。
|
||||
|
||||
---
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
import copy
|
||||
import json
|
||||
@@ -72,7 +72,7 @@ _sysview_events_map = {
|
||||
'SYS_INIT': SYSVIEW_EVTID_INIT,
|
||||
'SYS_NAME_RESOURCE': SYSVIEW_EVTID_NAME_RESOURCE,
|
||||
'SYS_PRINT_FORMATTED': SYSVIEW_EVTID_PRINT_FORMATTED,
|
||||
'SYS_NUMMODULES': SYSVIEW_EVTID_NUMMODULES
|
||||
'SYS_NUMMODULES': SYSVIEW_EVTID_NUMMODULES,
|
||||
}
|
||||
|
||||
_os_events_map = {}
|
||||
@@ -94,7 +94,7 @@ def parse_trace(reader, parser, os_evt_map_file=''):
|
||||
global _os_events_map
|
||||
# parse OS events formats file
|
||||
_os_events_map = _read_events_map(os_evt_map_file)
|
||||
parser.esp_ext = ('; ESP_Extension\n' in _read_file_header(reader))
|
||||
_read_file_header(reader)
|
||||
_read_init_seq(reader)
|
||||
while True:
|
||||
event = parser.read_event(reader, _os_events_map)
|
||||
@@ -199,7 +199,7 @@ def _decode_u32(reader):
|
||||
sz = 0
|
||||
val = 0
|
||||
while True:
|
||||
b, = struct.unpack('<B', reader.read(1))
|
||||
(b,) = struct.unpack('<B', reader.read(1))
|
||||
if b & 0x80:
|
||||
val |= (b & 0x7F) << (7 * sz)
|
||||
else:
|
||||
@@ -262,11 +262,11 @@ def _decode_str(reader):
|
||||
"""
|
||||
sz = 0
|
||||
val = ''
|
||||
sz, = struct.unpack('<B', reader.read(1))
|
||||
(sz,) = struct.unpack('<B', reader.read(1))
|
||||
if sz == 0xFF:
|
||||
buf = struct.unpack('<2B', reader.read(2))
|
||||
sz = (buf[0] << 8) | buf[1]
|
||||
val, = struct.unpack('<%ds' % sz, reader.read(sz))
|
||||
(val,) = struct.unpack('<%ds' % sz, reader.read(sz))
|
||||
val = val.decode('utf-8')
|
||||
if sz < 0xFF:
|
||||
return (sz + 1, val) # one extra byte for length
|
||||
@@ -288,9 +288,9 @@ def _decode_plen(reader):
|
||||
decoded value.
|
||||
"""
|
||||
plen = 0
|
||||
b0, = struct.unpack('<B', reader.read(1))
|
||||
(b0,) = struct.unpack('<B', reader.read(1))
|
||||
if b0 & 0x80:
|
||||
b1, = struct.unpack('<B', reader.read(1))
|
||||
(b1,) = struct.unpack('<B', reader.read(1))
|
||||
plen = b1 # higher part
|
||||
plen = (plen << 7) | (b0 & ~0x80) # lower 7 bits
|
||||
else:
|
||||
@@ -302,6 +302,7 @@ class SysViewTraceParseError(apptrace.ParseError):
|
||||
"""
|
||||
SystemView parse error exception.
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
@@ -309,6 +310,7 @@ class SysViewEvent(apptrace.TraceEvent):
|
||||
"""
|
||||
Generic SystemView event class. This is a base class for all events.
|
||||
"""
|
||||
|
||||
def __init__(self, evt_id, core_id, reader, events_fmt_map=None):
|
||||
"""
|
||||
Constructor. Reads and optionally decodes event.
|
||||
@@ -361,13 +363,21 @@ class SysViewEvent(apptrace.TraceEvent):
|
||||
cur_pos = reader.get_pos()
|
||||
sz, param_val = event_param.decode(reader, self.plen - params_len)
|
||||
except Exception as e:
|
||||
raise SysViewTraceParseError('Failed to decode event {}({:d}) {:d} param @ 0x{:x}! {}'.format(self.name, self.id, self.plen, cur_pos, e))
|
||||
raise SysViewTraceParseError(
|
||||
'Failed to decode event {}({:d}) {:d} param @ 0x{:x}! {}'.format(
|
||||
self.name, self.id, self.plen, cur_pos, e
|
||||
)
|
||||
)
|
||||
event_param.idx = i
|
||||
event_param.value = param_val
|
||||
self.params[event_param.name] = event_param
|
||||
params_len += sz
|
||||
if self.id >= SYSVIEW_EVENT_ID_PREDEF_LEN_MAX and self.plen != params_len:
|
||||
raise SysViewTraceParseError('Invalid event {}({:d}) payload len {:d}! Must be {:d}.'.format(self.name, self.id, self.plen, params_len))
|
||||
raise SysViewTraceParseError(
|
||||
'Invalid event {}({:d}) payload len {:d}! Must be {:d}.'.format(
|
||||
self.name, self.id, self.plen, params_len
|
||||
)
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
params = ''
|
||||
@@ -375,13 +385,16 @@ class SysViewEvent(apptrace.TraceEvent):
|
||||
params += '{}, '.format(param)
|
||||
if len(params):
|
||||
params = params[:-2] # remove trailing ', '
|
||||
return '{:.9f} - core[{:d}].{}({:d}), plen {:d}: [{}]'.format(self.ts, self.core_id, self.name, self.id, self.plen, params)
|
||||
return '{:.9f} - core[{:d}].{}({:d}), plen {:d}: [{}]'.format(
|
||||
self.ts, self.core_id, self.name, self.id, self.plen, params
|
||||
)
|
||||
|
||||
|
||||
class SysViewEventParam:
|
||||
"""
|
||||
Abstract base SystemView event's parameter class. This is a base class for all event's parameters.
|
||||
"""
|
||||
|
||||
def __init__(self, name, decode_func):
|
||||
"""
|
||||
Constructor.
|
||||
@@ -428,6 +441,7 @@ class SysViewEventParamSimple(SysViewEventParam):
|
||||
"""
|
||||
Simple SystemView event's parameter class.
|
||||
"""
|
||||
|
||||
def decode(self, reader, max_sz):
|
||||
"""
|
||||
see SysViewEventParam.decode()
|
||||
@@ -439,6 +453,7 @@ class SysViewEventParamArray(SysViewEventParamSimple):
|
||||
"""
|
||||
Array SystemView event's parameter class.
|
||||
"""
|
||||
|
||||
def __init__(self, name, decode_func, size=-1):
|
||||
"""
|
||||
Constructor.
|
||||
@@ -476,6 +491,7 @@ class SysViewPredefinedEvent(SysViewEvent):
|
||||
"""
|
||||
Pre-defined SystemView events class.
|
||||
"""
|
||||
|
||||
_predef_events_fmt = {
|
||||
SYSVIEW_EVTID_NOP: ('svNop', []),
|
||||
SYSVIEW_EVTID_OVERFLOW: ('svOverflow', [SysViewEventParamSimple('drop_cnt', _decode_u32)]),
|
||||
@@ -484,12 +500,19 @@ class SysViewPredefinedEvent(SysViewEvent):
|
||||
SYSVIEW_EVTID_TASK_START_EXEC: ('svTaskStartExec', [SysViewEventParamSimple('tid', _decode_id)]),
|
||||
SYSVIEW_EVTID_TASK_STOP_EXEC: ('svTaskStopExec', []),
|
||||
SYSVIEW_EVTID_TASK_START_READY: ('svTaskStartReady', [SysViewEventParamSimple('tid', _decode_id)]),
|
||||
SYSVIEW_EVTID_TASK_STOP_READY: ('svTaskStopReady', [SysViewEventParamSimple('tid', _decode_id),
|
||||
SysViewEventParamSimple('cause', _decode_u32)]),
|
||||
SYSVIEW_EVTID_TASK_STOP_READY: (
|
||||
'svTaskStopReady',
|
||||
[SysViewEventParamSimple('tid', _decode_id), SysViewEventParamSimple('cause', _decode_u32)],
|
||||
),
|
||||
SYSVIEW_EVTID_TASK_CREATE: ('svTaskCreate', [SysViewEventParamSimple('tid', _decode_id)]),
|
||||
SYSVIEW_EVTID_TASK_INFO: ('svTaskInfo', [SysViewEventParamSimple('tid', _decode_id),
|
||||
SYSVIEW_EVTID_TASK_INFO: (
|
||||
'svTaskInfo',
|
||||
[
|
||||
SysViewEventParamSimple('tid', _decode_id),
|
||||
SysViewEventParamSimple('prio', _decode_u32),
|
||||
SysViewEventParamSimple('name', _decode_str)]),
|
||||
SysViewEventParamSimple('name', _decode_str),
|
||||
],
|
||||
),
|
||||
SYSVIEW_EVTID_TRACE_START: ('svTraceStart', []),
|
||||
SYSVIEW_EVTID_TRACE_STOP: ('svTraceStop', []),
|
||||
SYSVIEW_EVTID_SYSTIME_CYCLES: ('svSysTimeCycles', [SysViewEventParamSimple('cycles', _decode_u32)]),
|
||||
@@ -501,23 +524,45 @@ class SysViewPredefinedEvent(SysViewEvent):
|
||||
SYSVIEW_EVTID_ISR_TO_SCHEDULER: ('svExitIsrToScheduler', []),
|
||||
SYSVIEW_EVTID_TIMER_ENTER: ('svTimerEnter', [SysViewEventParamSimple('tim_id', _decode_u32)]),
|
||||
SYSVIEW_EVTID_TIMER_EXIT: ('svTimerExit', []),
|
||||
SYSVIEW_EVTID_STACK_INFO: ('svStackInfo', [SysViewEventParamSimple('tid', _decode_id),
|
||||
SYSVIEW_EVTID_STACK_INFO: (
|
||||
'svStackInfo',
|
||||
[
|
||||
SysViewEventParamSimple('tid', _decode_id),
|
||||
SysViewEventParamSimple('base', _decode_u32),
|
||||
SysViewEventParamSimple('sz', _decode_u32),
|
||||
SysViewEventParamSimple('unused', _decode_u32)]),
|
||||
SYSVIEW_EVTID_MODULEDESC: ('svModuleDesc', [SysViewEventParamSimple('mod_id', _decode_u32),
|
||||
SysViewEventParamSimple('unused', _decode_u32),
|
||||
],
|
||||
),
|
||||
SYSVIEW_EVTID_MODULEDESC: (
|
||||
'svModuleDesc',
|
||||
[
|
||||
SysViewEventParamSimple('mod_id', _decode_u32),
|
||||
SysViewEventParamSimple('evt_off', _decode_u32),
|
||||
SysViewEventParamSimple('desc', _decode_str)]),
|
||||
SYSVIEW_EVTID_INIT: ('svInit', [SysViewEventParamSimple('sys_freq', _decode_u32),
|
||||
SysViewEventParamSimple('desc', _decode_str),
|
||||
],
|
||||
),
|
||||
SYSVIEW_EVTID_INIT: (
|
||||
'svInit',
|
||||
[
|
||||
SysViewEventParamSimple('sys_freq', _decode_u32),
|
||||
SysViewEventParamSimple('cpu_freq', _decode_u32),
|
||||
SysViewEventParamSimple('ram_base', _decode_u32),
|
||||
SysViewEventParamSimple('id_shift', _decode_u32)]),
|
||||
SysViewEventParamSimple('id_shift', _decode_u32),
|
||||
],
|
||||
),
|
||||
SYSVIEW_EVTID_DATA_SAMPLE: ('svDataSample', []),
|
||||
SYSVIEW_EVTID_NAME_RESOURCE: ('svNameResource', [SysViewEventParamSimple('res_id', _decode_u32),
|
||||
SysViewEventParamSimple('name', _decode_str)]),
|
||||
SYSVIEW_EVTID_PRINT_FORMATTED: ('svPrint', [SysViewEventParamSimple('msg', _decode_str),
|
||||
SYSVIEW_EVTID_NAME_RESOURCE: (
|
||||
'svNameResource',
|
||||
[SysViewEventParamSimple('res_id', _decode_u32), SysViewEventParamSimple('name', _decode_str)],
|
||||
),
|
||||
SYSVIEW_EVTID_PRINT_FORMATTED: (
|
||||
'svPrint',
|
||||
[
|
||||
SysViewEventParamSimple('msg', _decode_str),
|
||||
SysViewEventParamSimple('lvl', _decode_u32),
|
||||
SysViewEventParamSimple('unused', _decode_u32)]),
|
||||
SysViewEventParamSimple('unused', _decode_u32),
|
||||
],
|
||||
),
|
||||
SYSVIEW_EVTID_NUMMODULES: ('svNumModules', [SysViewEventParamSimple('mod_cnt', _decode_u32)]),
|
||||
}
|
||||
|
||||
@@ -533,6 +578,7 @@ class SysViewOSEvent(SysViewEvent):
|
||||
"""
|
||||
OS related SystemView events class.
|
||||
"""
|
||||
|
||||
def __init__(self, evt_id, core_id, reader, events_fmt_map):
|
||||
"""
|
||||
see SysViewEvent.__init__()
|
||||
@@ -550,12 +596,20 @@ class SysViewHeapEvent(SysViewEvent):
|
||||
events_fmt : dict
|
||||
see return value of _read_events_map()
|
||||
"""
|
||||
|
||||
events_fmt = {
|
||||
0: ('esp_sysview_heap_trace_alloc', [SysViewEventParamSimple('addr', _decode_u32),
|
||||
0: (
|
||||
'esp_sysview_heap_trace_alloc',
|
||||
[
|
||||
SysViewEventParamSimple('addr', _decode_u32),
|
||||
SysViewEventParamSimple('size', _decode_u32),
|
||||
SysViewEventParamArray('callers', _decode_u32)]),
|
||||
1: ('esp_sysview_heap_trace_free', [SysViewEventParamSimple('addr', _decode_u32),
|
||||
SysViewEventParamArray('callers', _decode_u32)]),
|
||||
SysViewEventParamArray('callers', _decode_u32),
|
||||
],
|
||||
),
|
||||
1: (
|
||||
'esp_sysview_heap_trace_free',
|
||||
[SysViewEventParamSimple('addr', _decode_u32), SysViewEventParamArray('callers', _decode_u32)],
|
||||
),
|
||||
}
|
||||
|
||||
def __init__(self, evt_id, core_id, events_off, reader):
|
||||
@@ -574,8 +628,8 @@ class SysViewHeapEvent(SysViewEvent):
|
||||
see SysViewEvent.__init__()
|
||||
"""
|
||||
cur_events_map = {}
|
||||
for id in self.events_fmt:
|
||||
cur_events_map[events_off + id] = self.events_fmt[id]
|
||||
for _id in self.events_fmt:
|
||||
cur_events_map[events_off + _id] = self.events_fmt[_id]
|
||||
SysViewEvent.__init__(self, evt_id, core_id, reader, cur_events_map)
|
||||
# self.name = 'SysViewHeapEvent'
|
||||
|
||||
@@ -593,6 +647,7 @@ class SysViewTraceDataParser(apptrace.TraceDataProcessor):
|
||||
STREAMID_HEAP : int
|
||||
heap events stream ID.
|
||||
"""
|
||||
|
||||
STREAMID_SYS = -1
|
||||
STREAMID_LOG = 0
|
||||
STREAMID_HEAP = 1
|
||||
@@ -614,7 +669,6 @@ class SysViewTraceDataParser(apptrace.TraceDataProcessor):
|
||||
self.irqs_info = {}
|
||||
self.tasks_info = {}
|
||||
self.core_id = core_id
|
||||
self.esp_ext = False
|
||||
|
||||
def _parse_irq_desc(self, desc):
|
||||
"""
|
||||
@@ -701,24 +755,18 @@ class SysViewTraceDataParser(apptrace.TraceDataProcessor):
|
||||
SysViewEvent
|
||||
pre-defined, OS-related or extension event object.
|
||||
"""
|
||||
evt_hdr, = struct.unpack('<B', reader.read(1))
|
||||
(evt_hdr,) = struct.unpack('<B', reader.read(1))
|
||||
# read ID and core num
|
||||
evt_id = 0
|
||||
if evt_hdr & 0x80:
|
||||
# evt_id (2 bytes)
|
||||
b, = struct.unpack('<B', reader.read(1))
|
||||
(b,) = struct.unpack('<B', reader.read(1))
|
||||
# higher part
|
||||
if self.esp_ext:
|
||||
evt_id,core_id = self._decode_core_id(b)
|
||||
else:
|
||||
evt_id = b
|
||||
core_id = self.core_id
|
||||
evt_id = (evt_id << 7) | (evt_hdr & ~0x80) # lower 7 bits
|
||||
else:
|
||||
# evt_id (1 byte)
|
||||
if self.esp_ext:
|
||||
evt_id,core_id = self._decode_core_id(evt_hdr)
|
||||
else:
|
||||
evt_id = evt_hdr
|
||||
core_id = self.core_id
|
||||
if evt_id <= SYSVIEW_EVENT_ID_PREDEF_MAX:
|
||||
@@ -779,14 +827,22 @@ class SysViewTraceDataExtEventParser(SysViewTraceDataParser):
|
||||
self.events_num = events_num
|
||||
|
||||
def event_supported(self, event):
|
||||
return False if (self.events_off < SYSVIEW_MODULE_EVENT_OFFSET or event.id < self.events_off or
|
||||
event.id >= (self.events_off + self.events_num)) else True
|
||||
return (
|
||||
False
|
||||
if (
|
||||
self.events_off < SYSVIEW_MODULE_EVENT_OFFSET
|
||||
or event.id < self.events_off
|
||||
or event.id >= (self.events_off + self.events_num)
|
||||
)
|
||||
else True
|
||||
)
|
||||
|
||||
|
||||
class SysViewMultiTraceDataParser(SysViewTraceDataParser):
|
||||
"""
|
||||
SystemView trace data parser supporting multiple event streams.
|
||||
"""
|
||||
|
||||
def __init__(self, print_events=False, core_id=0):
|
||||
"""
|
||||
see SysViewTraceDataParser.__init__()
|
||||
@@ -850,10 +906,11 @@ class SysViewMultiTraceDataParser(SysViewTraceDataParser):
|
||||
self.stream_parsers[stream_id].on_new_event(event)
|
||||
|
||||
|
||||
class SysViewEventContext():
|
||||
class SysViewEventContext:
|
||||
"""
|
||||
SystemView event context.
|
||||
"""
|
||||
|
||||
def __init__(self, handle, irq, name=''):
|
||||
"""
|
||||
Constructor.
|
||||
@@ -876,6 +933,7 @@ class SysViewTraceDataProcessor(apptrace.TraceDataProcessor):
|
||||
"""
|
||||
Base SystemView trace data processor class.
|
||||
"""
|
||||
|
||||
def __init__(self, traces, root_proc=None, print_events=False, keep_all_events=False):
|
||||
"""
|
||||
Constructor.
|
||||
@@ -903,7 +961,8 @@ class SysViewTraceDataProcessor(apptrace.TraceDataProcessor):
|
||||
# empty list means IDLE context or self.start_ctx
|
||||
self.ctx_stack[t.core_id] = []
|
||||
# context is undefined, we do not know have we started the tracing in task/IDLE or IRQ context
|
||||
# in general there are three scenarios when we can start tracing: when core is in task, IDLE task or IRQ context
|
||||
# in general there are three scenarios when we can start tracing:
|
||||
# when core is in task, IDLE task or IRQ context
|
||||
self.prev_ctx[t.core_id] = None
|
||||
|
||||
def _get_curr_context(self, core_id):
|
||||
@@ -1000,14 +1059,6 @@ class SysViewTraceDataProcessor(apptrace.TraceDataProcessor):
|
||||
if SYSVIEW_EVTID_TASK_START_EXEC or SYSVIEW_EVTID_TASK_STOP_READY is received for unknown task.
|
||||
"""
|
||||
if event.core_id not in self.traces:
|
||||
if 0 in self.traces and self.traces[0].esp_ext:
|
||||
# for Espressif extension there is one trace for all cores
|
||||
trace = self.traces[0]
|
||||
if event.core_id not in self.ctx_stack:
|
||||
self.ctx_stack[event.core_id] = []
|
||||
if event.core_id not in self.prev_ctx:
|
||||
self.prev_ctx[event.core_id] = None
|
||||
else:
|
||||
raise SysViewTraceParseError('Event for unknown core %d' % event.core_id)
|
||||
else:
|
||||
trace = self.traces[event.core_id]
|
||||
@@ -1017,16 +1068,20 @@ class SysViewTraceDataProcessor(apptrace.TraceDataProcessor):
|
||||
if len(self.ctx_stack[event.core_id]):
|
||||
self.prev_ctx[event.core_id] = self.ctx_stack[event.core_id][-1]
|
||||
else:
|
||||
# the 1st context switching event after trace start is SYSVIEW_EVTID_ISR_ENTER, so we have been in IDLE context
|
||||
# the 1st context switching event after trace start is SYSVIEW_EVTID_ISR_ENTER,
|
||||
# so we have been in IDLE context
|
||||
self.prev_ctx[event.core_id] = SysViewEventContext(None, False, 'IDLE%d' % event.core_id)
|
||||
# put new ISR context on top of the stack (the last in the list)
|
||||
self.ctx_stack[event.core_id].append(SysViewEventContext(event.params['irq_num'].value, True, trace.irqs_info[event.params['irq_num'].value]))
|
||||
self.ctx_stack[event.core_id].append(
|
||||
SysViewEventContext(event.params['irq_num'].value, True, trace.irqs_info[event.params['irq_num'].value])
|
||||
)
|
||||
elif event.id == SYSVIEW_EVTID_ISR_EXIT or event.id == SYSVIEW_EVTID_ISR_TO_SCHEDULER:
|
||||
if len(self.ctx_stack[event.core_id]):
|
||||
# return to the previous context (the last in the list)
|
||||
self.prev_ctx[event.core_id] = self.ctx_stack[event.core_id].pop()
|
||||
else:
|
||||
# the 1st context switching event after trace start is SYSVIEW_EVTID_ISR_EXIT, so we have been in ISR context,
|
||||
# the 1st context switching event after trace start is SYSVIEW_EVTID_ISR_EXIT,
|
||||
# so we have been in ISR context,
|
||||
# but we do not know which one because SYSVIEW_EVTID_ISR_EXIT do not include the IRQ number
|
||||
self.prev_ctx[event.core_id] = SysViewEventContext(None, True, 'IRQ_oncore%d' % event.core_id)
|
||||
elif event.id == SYSVIEW_EVTID_TASK_START_EXEC:
|
||||
@@ -1036,10 +1091,13 @@ class SysViewTraceDataProcessor(apptrace.TraceDataProcessor):
|
||||
# return to the previous context (the last in the list)
|
||||
self.prev_ctx[event.core_id] = self.ctx_stack[event.core_id][-1]
|
||||
else:
|
||||
# the 1st context switching event after trace start is SYSVIEW_EVTID_TASK_START_EXEC, so we have been in IDLE context
|
||||
# the 1st context switching event after trace start is SYSVIEW_EVTID_TASK_START_EXEC,
|
||||
# so we have been in IDLE context
|
||||
self.prev_ctx[event.core_id] = SysViewEventContext(None, False, 'IDLE%d' % event.core_id)
|
||||
# only one task at a time in context stack (can be interrupted by a bunch of ISRs)
|
||||
self.ctx_stack[event.core_id] = [SysViewEventContext(event.params['tid'].value, False, trace.tasks_info[event.params['tid'].value])]
|
||||
self.ctx_stack[event.core_id] = [
|
||||
SysViewEventContext(event.params['tid'].value, False, trace.tasks_info[event.params['tid'].value])
|
||||
]
|
||||
elif event.id == SYSVIEW_EVTID_TASK_STOP_EXEC:
|
||||
# delete task from context stack
|
||||
for ctx in self.ctx_stack[event.core_id]:
|
||||
@@ -1053,12 +1111,18 @@ class SysViewTraceDataProcessor(apptrace.TraceDataProcessor):
|
||||
if event.params['tid'].value not in trace.tasks_info:
|
||||
raise SysViewTraceParseError('Stop ready unknown task 0x%x' % event.params['tid'].value)
|
||||
if len(self.ctx_stack[event.core_id]):
|
||||
if (not self.ctx_stack[event.core_id][-1].irq and event.params['tid'].value == self.ctx_stack[event.core_id][-1].handle):
|
||||
if (
|
||||
not self.ctx_stack[event.core_id][-1].irq
|
||||
and event.params['tid'].value == self.ctx_stack[event.core_id][-1].handle
|
||||
):
|
||||
# return to the previous context (the last in the list)
|
||||
self.prev_ctx[event.core_id] = self.ctx_stack[event.core_id].pop()
|
||||
else:
|
||||
# the 1st context switching event after trace start is SYSVIEW_EVTID_TASK_STOP_READY, so we have been in task context
|
||||
self.prev_ctx[event.core_id] = SysViewEventContext(event.params['tid'].value, False, trace.tasks_info[event.params['tid'].value])
|
||||
# the 1st context switching event after trace start is SYSVIEW_EVTID_TASK_STOP_READY,
|
||||
# so we have been in task context
|
||||
self.prev_ctx[event.core_id] = SysViewEventContext(
|
||||
event.params['tid'].value, False, trace.tasks_info[event.params['tid'].value]
|
||||
)
|
||||
|
||||
def on_new_event(self, event):
|
||||
"""
|
||||
@@ -1105,6 +1169,7 @@ class SysViewMultiStreamTraceDataProcessor(SysViewTraceDataProcessor):
|
||||
"""
|
||||
SystemView trace data processor supporting multiple event streams.
|
||||
"""
|
||||
|
||||
def __init__(self, traces, print_events=False, keep_all_events=False):
|
||||
"""
|
||||
see SysViewTraceDataProcessor.__init__()
|
||||
@@ -1146,10 +1211,6 @@ class SysViewMultiStreamTraceDataProcessor(SysViewTraceDataProcessor):
|
||||
SysViewTraceDataParser
|
||||
parser object for specified stream and core
|
||||
"""
|
||||
if core_id not in self.traces and 0 in self.traces and self.traces[0].esp_ext:
|
||||
# for Espressif extension there is one trace for all cores
|
||||
trace = self.traces[0]
|
||||
else:
|
||||
trace = self.traces[core_id]
|
||||
if stream_id == SysViewTraceDataParser.STREAMID_SYS:
|
||||
return trace
|
||||
@@ -1222,11 +1283,26 @@ class SysViewTraceDataJsonEncoder(json.JSONEncoder):
|
||||
callers = []
|
||||
for addr in obj.params['callers'].value:
|
||||
callers.append('0x{:x}'.format(addr))
|
||||
return {'ctx_name': obj.ctx_name, 'in_irq': obj.in_irq, 'id': obj.id, 'core_id': obj.core_id,
|
||||
'ts': obj.ts, 'addr': blk_addr, 'size': blk_size, 'callers': callers}
|
||||
return {
|
||||
'ctx_name': obj.ctx_name,
|
||||
'in_irq': obj.in_irq,
|
||||
'id': obj.id,
|
||||
'core_id': obj.core_id,
|
||||
'ts': obj.ts,
|
||||
'addr': blk_addr,
|
||||
'size': blk_size,
|
||||
'callers': callers,
|
||||
}
|
||||
if isinstance(obj, SysViewPredefinedEvent) and obj.id == SYSVIEW_EVTID_PRINT_FORMATTED:
|
||||
return {'ctx_name': obj.ctx_name, 'in_irq': obj.in_irq, 'id': obj.id, 'core_id': obj.core_id,
|
||||
'ts': obj.ts, 'msg': obj.params['msg'].value, 'lvl': obj.params['lvl'].value}
|
||||
return {
|
||||
'ctx_name': obj.ctx_name,
|
||||
'in_irq': obj.in_irq,
|
||||
'id': obj.id,
|
||||
'core_id': obj.core_id,
|
||||
'ts': obj.ts,
|
||||
'msg': obj.params['msg'].value,
|
||||
'lvl': obj.params['lvl'].value,
|
||||
}
|
||||
if isinstance(obj, SysViewEvent):
|
||||
jobj = obj.to_jsonable()
|
||||
# remove unused fields
|
||||
@@ -1243,20 +1319,26 @@ class SysViewHeapTraceDataParser(SysViewTraceDataExtEventParser):
|
||||
"""
|
||||
SystemView trace data parser supporting heap events.
|
||||
"""
|
||||
|
||||
def __init__(self, print_events=False, core_id=0):
|
||||
"""
|
||||
SystemView trace data parser supporting multiple event streams.
|
||||
see SysViewTraceDataExtEventParser.__init__()
|
||||
"""
|
||||
SysViewTraceDataExtEventParser.__init__(self, events_num=len(SysViewHeapEvent.events_fmt.keys()), core_id=core_id, print_events=print_events)
|
||||
SysViewTraceDataExtEventParser.__init__(
|
||||
self, events_num=len(SysViewHeapEvent.events_fmt.keys()), core_id=core_id, print_events=print_events
|
||||
)
|
||||
|
||||
def read_extension_event(self, evt_id, core_id, reader):
|
||||
"""
|
||||
Reads heap event.
|
||||
see SysViewTraceDataParser.read_extension_event()
|
||||
"""
|
||||
if (self.events_off >= SYSVIEW_MODULE_EVENT_OFFSET and evt_id >= self.events_off and
|
||||
evt_id < self.events_off + self.events_num):
|
||||
if (
|
||||
self.events_off >= SYSVIEW_MODULE_EVENT_OFFSET
|
||||
and evt_id >= self.events_off
|
||||
and evt_id < self.events_off + self.events_num
|
||||
):
|
||||
return SysViewHeapEvent(evt_id, core_id, self.events_off, reader)
|
||||
return SysViewTraceDataParser.read_extension_event(self, evt_id, core_id, reader)
|
||||
|
||||
@@ -1266,7 +1348,10 @@ class SysViewHeapTraceDataParser(SysViewTraceDataExtEventParser):
|
||||
"""
|
||||
if self.root_proc == self:
|
||||
SysViewTraceDataParser.on_new_event(self, event)
|
||||
if event.id == SYSVIEW_EVTID_MODULEDESC and event.params['desc'].value == 'M=ESP32 SystemView Heap Tracing Module':
|
||||
if (
|
||||
event.id == SYSVIEW_EVTID_MODULEDESC
|
||||
and event.params['desc'].value == 'M=ESP32 SystemView Heap Tracing Module'
|
||||
):
|
||||
self.events_off = event.params['evt_off'].value
|
||||
|
||||
|
||||
@@ -1274,7 +1359,10 @@ class SysViewHeapTraceDataProcessor(SysViewTraceDataProcessor, apptrace.BaseHeap
|
||||
"""
|
||||
SystemView trace data processor supporting heap events.
|
||||
"""
|
||||
def __init__(self, toolchain_pref, elf_path, root_proc=None, traces=[], print_events=False, print_heap_events=False):
|
||||
|
||||
def __init__(
|
||||
self, toolchain_pref, elf_path, root_proc=None, traces=[], print_events=False, print_heap_events=False
|
||||
):
|
||||
"""
|
||||
Constructor.
|
||||
see SysViewTraceDataProcessor.__init__()
|
||||
@@ -1296,11 +1384,9 @@ class SysViewHeapTraceDataProcessor(SysViewTraceDataProcessor, apptrace.BaseHeap
|
||||
def handle_event(self, event):
|
||||
heap_stream = self.root_proc.get_trace_stream(event.core_id, SysViewTraceDataParser.STREAMID_HEAP)
|
||||
if (event.id - heap_stream.events_off) == 0:
|
||||
heap_event = apptrace.HeapTraceEvent(event, True, toolchain=self.toolchain,
|
||||
elf_path=self.elf_path)
|
||||
heap_event = apptrace.HeapTraceEvent(event, True, toolchain=self.toolchain, elf_path=self.elf_path)
|
||||
else:
|
||||
heap_event = apptrace.HeapTraceEvent(event, False, toolchain=self.toolchain,
|
||||
elf_path=self.elf_path)
|
||||
heap_event = apptrace.HeapTraceEvent(event, False, toolchain=self.toolchain, elf_path=self.elf_path)
|
||||
apptrace.BaseHeapTraceDataProcessorImpl.on_new_event(self, heap_event)
|
||||
|
||||
def print_report(self):
|
||||
@@ -1316,6 +1402,7 @@ class SysViewLogTraceEvent(apptrace.LogTraceEvent):
|
||||
"""
|
||||
SystemView log event.
|
||||
"""
|
||||
|
||||
def __init__(self, ts, msg):
|
||||
"""
|
||||
Constructor.
|
||||
@@ -1344,6 +1431,7 @@ class SysViewLogTraceDataParser(SysViewTraceDataParser):
|
||||
"""
|
||||
SystemView trace data parser supporting log events.
|
||||
"""
|
||||
|
||||
def event_supported(self, event):
|
||||
return event.id == SYSVIEW_EVTID_PRINT_FORMATTED
|
||||
|
||||
@@ -1359,6 +1447,7 @@ class SysViewLogTraceDataProcessor(SysViewTraceDataProcessor, apptrace.BaseLogTr
|
||||
"""
|
||||
SystemView trace data processor supporting heap events.
|
||||
"""
|
||||
|
||||
def __init__(self, traces=[], root_proc=None, print_events=False, print_log_events=False):
|
||||
"""
|
||||
Constructor.
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# This is python script to process various types trace data streams in SystemView format.
|
||||
@@ -14,34 +14,137 @@ import logging
|
||||
import os.path
|
||||
import signal
|
||||
import sys
|
||||
import tempfile
|
||||
import traceback
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import espytrace.apptrace as apptrace
|
||||
import espytrace.sysview as sysview
|
||||
|
||||
|
||||
def main():
|
||||
def is_segger_multicore_format(file_path):
|
||||
"""Check if the file has offsets in header"""
|
||||
try:
|
||||
url = urlparse(file_path)
|
||||
if len(url.scheme) == 0 or url.scheme == 'file':
|
||||
with open(url.path, 'rb') as f:
|
||||
header = f.read(200)
|
||||
header_str = header.decode('utf-8', errors='ignore')
|
||||
if (
|
||||
'; Version SEGGER SystemViewer' in header_str
|
||||
and '; Author Espressif Inc' in header_str
|
||||
and '; Offset Core0' in header_str
|
||||
and '; Offset Core1' in header_str
|
||||
):
|
||||
return True
|
||||
except Exception as e:
|
||||
logging.error('Error checking SEGGER multicore file format:', e)
|
||||
return False
|
||||
|
||||
verbosity_levels = [
|
||||
logging.CRITICAL,
|
||||
logging.ERROR,
|
||||
logging.WARNING,
|
||||
logging.INFO,
|
||||
logging.DEBUG
|
||||
]
|
||||
|
||||
def split_segger_multicore_file(file_path):
|
||||
"""Split SEGGER multicore file into separate core files."""
|
||||
try:
|
||||
with open(urlparse(file_path).path, 'rb') as f:
|
||||
# Read first few lines to get offsets for each core
|
||||
header = f.read(200)
|
||||
header_str = header.decode('utf-8', errors='ignore')
|
||||
|
||||
core1_offset = None
|
||||
for line in header_str.split('\n'):
|
||||
if '; Offset Core1' in line:
|
||||
core1_offset = int(line.strip().split()[-1])
|
||||
|
||||
if core1_offset is None:
|
||||
logging.error('Failed to parse core1 offset')
|
||||
return None, None
|
||||
|
||||
# Read the entire file
|
||||
f.seek(0)
|
||||
data = f.read()
|
||||
|
||||
# Find first 10 sync bytes start offset
|
||||
sync_start = data.find(b'\x00' * 10)
|
||||
if sync_start == -1:
|
||||
logging.error('Sync bytes not found')
|
||||
return None, None
|
||||
|
||||
core0_offset = sync_start
|
||||
core1_offset += sync_start
|
||||
|
||||
# Parse original header and get version from there, if not found, use default version
|
||||
version = 'V3.60'
|
||||
for line in header_str.split('\n'):
|
||||
if '; Version SEGGER SystemViewer' in line:
|
||||
version = line.strip().split()[-1]
|
||||
break
|
||||
|
||||
# Rebuild header without offset lines
|
||||
core_header = f';\n; Version SEGGER SystemViewer {version}\n; Author Espressif Inc\n;\n'
|
||||
core_header = core_header.encode('utf-8')
|
||||
core_base = core_header + b'\x00' * 10
|
||||
|
||||
core0_data = core_base + data[core0_offset:core1_offset]
|
||||
core1_data = core_base + data[core1_offset:]
|
||||
|
||||
core0_file = tempfile.NamedTemporaryFile(delete=False, suffix='.svdat')
|
||||
core1_file = tempfile.NamedTemporaryFile(delete=False, suffix='.svdat')
|
||||
|
||||
core0_file.write(core0_data)
|
||||
core1_file.write(core1_data)
|
||||
|
||||
core0_file.close()
|
||||
core1_file.close()
|
||||
|
||||
return core0_file.name, core1_file.name
|
||||
|
||||
except Exception as e:
|
||||
logging.error('Failed to process files:', e)
|
||||
return None, None
|
||||
|
||||
|
||||
def main():
|
||||
verbosity_levels = [logging.CRITICAL, logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG]
|
||||
|
||||
parser = argparse.ArgumentParser(description='ESP32 SEGGER SystemView Trace Parsing Tool')
|
||||
|
||||
parser.add_argument('trace_sources', help='Trace data sources. Format: [file://]/path/to/file.', nargs='+', type=str)
|
||||
parser.add_argument(
|
||||
'trace_sources', help='Trace data sources. Format: [file://]/path/to/file.', nargs='+', type=str
|
||||
)
|
||||
parser.add_argument('--elf-file', '-b', help='Path to program ELF file.', type=str, default='')
|
||||
parser.add_argument('--tmo', '-w', help='Data wait timeout in sec. -1: infinite, 0: no wait', type=int, default=0)
|
||||
parser.add_argument('--dump-events', '-d', help='Dump all events.', action='store_true')
|
||||
parser.add_argument('--print-events', '-p', help='Print events of selected types. By default only reports are printed', action='store_true')
|
||||
parser.add_argument('--include-events', '-i', help='Events types to be included into report.', type=str, choices=['heap', 'log', 'all'], default='all')
|
||||
parser.add_argument(
|
||||
'--print-events',
|
||||
'-p',
|
||||
help='Print events of selected types. By default only reports are printed',
|
||||
action='store_true',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--include-events',
|
||||
'-i',
|
||||
help='Events types to be included into report.',
|
||||
type=str,
|
||||
choices=['heap', 'log', 'all'],
|
||||
default='all',
|
||||
)
|
||||
parser.add_argument('--toolchain', '-t', help='Toolchain prefix.', type=str, default='xtensa-esp32-elf-')
|
||||
parser.add_argument('--events-map', '-e', help='Events map file.', type=str, default=os.path.join(os.path.dirname(__file__), 'SYSVIEW_FreeRTOS.txt'))
|
||||
parser.add_argument(
|
||||
'--events-map',
|
||||
'-e',
|
||||
help='Events map file.',
|
||||
type=str,
|
||||
default=os.path.join(os.path.dirname(__file__), 'SYSVIEW_FreeRTOS.txt'),
|
||||
)
|
||||
parser.add_argument('--to-json', '-j', help='Print JSON.', action='store_true', default=False)
|
||||
parser.add_argument('--verbose', '-v', help='Verbosity level. Default 1', choices=range(0, len(verbosity_levels)), type=int, default=1)
|
||||
parser.add_argument(
|
||||
'--verbose',
|
||||
'-v',
|
||||
help='Verbosity level. Default 1',
|
||||
choices=range(0, len(verbosity_levels)),
|
||||
type=int,
|
||||
default=1,
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
def sig_int_handler(signum, frame):
|
||||
@@ -60,17 +163,33 @@ def main():
|
||||
|
||||
logging.basicConfig(level=verbosity_levels[args.verbose], format='[%(levelname)s] %(message)s')
|
||||
|
||||
temp_files = []
|
||||
# Only check for SEGGER format if there's exactly one trace source
|
||||
if len(args.trace_sources) == 1:
|
||||
trace_source = args.trace_sources[0]
|
||||
if is_segger_multicore_format(trace_source):
|
||||
core0_file, core1_file = split_segger_multicore_file(trace_source)
|
||||
if core0_file and core1_file:
|
||||
temp_files.extend([core0_file, core1_file])
|
||||
args.trace_sources = temp_files
|
||||
else:
|
||||
sys.exit(2)
|
||||
|
||||
# parse trace files
|
||||
parsers = []
|
||||
for i, trace_source in enumerate(args.trace_sources):
|
||||
try:
|
||||
parser = sysview.SysViewMultiTraceDataParser(print_events=False, core_id=i)
|
||||
if include_events['heap']:
|
||||
parser.add_stream_parser(sysview.SysViewTraceDataParser.STREAMID_HEAP,
|
||||
sysview.SysViewHeapTraceDataParser(print_events=False, core_id=i))
|
||||
parser.add_stream_parser(
|
||||
sysview.SysViewTraceDataParser.STREAMID_HEAP,
|
||||
sysview.SysViewHeapTraceDataParser(print_events=False, core_id=i),
|
||||
)
|
||||
if include_events['log']:
|
||||
parser.add_stream_parser(sysview.SysViewTraceDataParser.STREAMID_LOG,
|
||||
sysview.SysViewLogTraceDataParser(print_events=False, core_id=i))
|
||||
parser.add_stream_parser(
|
||||
sysview.SysViewTraceDataParser.STREAMID_LOG,
|
||||
sysview.SysViewLogTraceDataParser(print_events=False, core_id=i),
|
||||
)
|
||||
parsers.append(parser)
|
||||
except Exception as e:
|
||||
logging.error('Failed to create data parser (%s)!', e)
|
||||
@@ -97,13 +216,21 @@ def main():
|
||||
|
||||
# merge and process traces
|
||||
try:
|
||||
proc = sysview.SysViewMultiStreamTraceDataProcessor(traces=parsers, print_events=args.dump_events, keep_all_events=True if args.to_json else False)
|
||||
proc = sysview.SysViewMultiStreamTraceDataProcessor(
|
||||
traces=parsers, print_events=args.dump_events, keep_all_events=True if args.to_json else False
|
||||
)
|
||||
if include_events['heap']:
|
||||
proc.add_stream_processor(sysview.SysViewTraceDataParser.STREAMID_HEAP,
|
||||
sysview.SysViewHeapTraceDataProcessor(args.toolchain, args.elf_file, root_proc=proc, print_heap_events=args.print_events))
|
||||
proc.add_stream_processor(
|
||||
sysview.SysViewTraceDataParser.STREAMID_HEAP,
|
||||
sysview.SysViewHeapTraceDataProcessor(
|
||||
args.toolchain, args.elf_file, root_proc=proc, print_heap_events=args.print_events
|
||||
),
|
||||
)
|
||||
if include_events['log']:
|
||||
proc.add_stream_processor(sysview.SysViewTraceDataParser.STREAMID_LOG,
|
||||
sysview.SysViewLogTraceDataProcessor(root_proc=proc, print_log_events=args.print_events))
|
||||
proc.add_stream_processor(
|
||||
sysview.SysViewTraceDataParser.STREAMID_LOG,
|
||||
sysview.SysViewLogTraceDataProcessor(root_proc=proc, print_log_events=args.print_events),
|
||||
)
|
||||
except Exception as e:
|
||||
logging.error('Failed to create data processor (%s)!', e)
|
||||
traceback.print_exc()
|
||||
@@ -119,11 +246,21 @@ def main():
|
||||
sys.exit(2)
|
||||
finally:
|
||||
if args.to_json:
|
||||
print(json.dumps(proc, cls=sysview.SysViewTraceDataJsonEncoder, indent=4, separators=(',', ': '), sort_keys=True))
|
||||
print(
|
||||
json.dumps(
|
||||
proc, cls=sysview.SysViewTraceDataJsonEncoder, indent=4, separators=(',', ': '), sort_keys=True
|
||||
)
|
||||
)
|
||||
else:
|
||||
proc.print_report()
|
||||
proc.cleanup()
|
||||
|
||||
for file in temp_files:
|
||||
try:
|
||||
os.remove(file)
|
||||
except Exception as e:
|
||||
logging.warning('Failed to remove temporary file %s: %s', file, e)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
```
|
||||
cd $IDF_PATH/examples/system/sysview_tracing_heap_log
|
||||
xtensa-esp32-elf-gdb -x gdbinit build/sysview_tracing_heap_log.elf
|
||||
xtensa-esp32-elf-gdb -x $IDF_PATH/tools/esp_app_trace/test/sysview/gdbinit build/sysview_tracing_heap_log.elf
|
||||
```
|
||||
When program stops at `heap_trace_stop` quit GDB and OpenOCD
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
```
|
||||
cd $IDF_PATH/examples/system/sysview_tracing_heap_log
|
||||
xtensa-esp32-elf-gdb -x gdbinit-mcore build/sysview_tracing_heap_log.elf
|
||||
xtensa-esp32-elf-gdb -x $IDF_PATH/tools/esp_app_trace/test/sysview/gdbinit-mcore build/sysview_tracing_heap_log.elf
|
||||
```
|
||||
When program stops at `heap_trace_stop` quit GDB and OpenOCD
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
You can use the commands from the `test.sh` to generate expected result files
|
||||
|
||||
```
|
||||
cd $IDF_PATH/tools/esp_app_trace/test/sysview/
|
||||
$IDF_PATH/tools/esp_app_trace/sysviewtrace_proc.py -d -p -b sysview_tracing_heap_log.elf heap_log0.svdat heap_log1.svdat &> expected_output
|
||||
$IDF_PATH/tools/esp_app_trace/sysviewtrace_proc.py -j -b sysview_tracing_heap_log.elf heap_log0.svdat heap_log1.svdat &> expected_output.json
|
||||
$IDF_PATH/tools/esp_app_trace/sysviewtrace_proc.py -d -p -b sysview_tracing_heap_log.elf heap_log_mcore.svdat &> expected_output_mcore
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,29 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
{ python -m coverage debug sys \
|
||||
&& python -m coverage erase &> output \
|
||||
&& python -m coverage run -a $IDF_PATH/tools/esp_app_trace/sysviewtrace_proc.py -d -p -b sysview_tracing_heap_log.elf heap_log0.svdat heap_log1.svdat &>> output \
|
||||
&& diff output expected_output \
|
||||
&& python -m coverage report \
|
||||
; } || { echo 'The test for sysviewtrace_proc has failed. Please examine the artifacts.' ; exit 1; }
|
||||
{ python -m coverage debug sys && \
|
||||
python -m coverage erase > output && \
|
||||
python -m coverage run -a $IDF_PATH/tools/esp_app_trace/sysviewtrace_proc.py -d -p -b sysview_tracing_heap_log.elf heap_log0.svdat heap_log1.svdat >> output && \
|
||||
diff output expected_output && \
|
||||
python -m coverage report; \
|
||||
} || { echo 'The test for sysviewtrace_proc has failed. Please examine the artifacts.' ; exit 1; }
|
||||
|
||||
{ python -m coverage debug sys \
|
||||
&& python -m coverage erase &> output.json \
|
||||
&& python -m coverage run -a $IDF_PATH/tools/esp_app_trace/sysviewtrace_proc.py -j -b sysview_tracing_heap_log.elf heap_log0.svdat heap_log1.svdat &>> output.json \
|
||||
&& diff output.json expected_output.json \
|
||||
&& python -m coverage report \
|
||||
; } || { echo 'The test for sysviewtrace_proc JSON functionality has failed. Please examine the artifacts.' ; exit 1; }
|
||||
{ python -m coverage debug sys && \
|
||||
python -m coverage erase > output.json && \
|
||||
python -m coverage run -a $IDF_PATH/tools/esp_app_trace/sysviewtrace_proc.py -j -b sysview_tracing_heap_log.elf heap_log0.svdat heap_log1.svdat >> output.json && \
|
||||
diff output.json expected_output.json && \
|
||||
python -m coverage report; \
|
||||
} || { echo 'The test for sysviewtrace_proc JSON functionality has failed. Please examine the artifacts.' ; exit 1; }
|
||||
|
||||
{ python -m coverage debug sys \
|
||||
&& python -m coverage erase &> output \
|
||||
&& python -m coverage run -a $IDF_PATH/tools/esp_app_trace/sysviewtrace_proc.py -d -p -b sysview_tracing_heap_log.elf heap_log_mcore.svdat &>> output \
|
||||
&& diff output expected_output_mcore \
|
||||
&& python -m coverage report \
|
||||
; } || { echo 'The test for mcore sysviewtrace_proc functionality has failed. Please examine the artifacts.' ; exit 1; }
|
||||
{ python -m coverage debug sys && \
|
||||
python -m coverage erase > output && \
|
||||
python -m coverage run -a $IDF_PATH/tools/esp_app_trace/sysviewtrace_proc.py -d -p -b sysview_tracing_heap_log.elf heap_log_mcore.svdat >> output && \
|
||||
diff output expected_output_mcore && \
|
||||
python -m coverage report; \
|
||||
} || { echo 'The test for mcore sysviewtrace_proc functionality has failed. Please examine the artifacts.' ; exit 1; }
|
||||
|
||||
{ python -m coverage debug sys \
|
||||
&& python -m coverage erase &> output.json \
|
||||
&& python -m coverage run -a $IDF_PATH/tools/esp_app_trace/sysviewtrace_proc.py -j -b sysview_tracing_heap_log.elf heap_log_mcore.svdat &>> output.json \
|
||||
&& diff output.json expected_output_mcore.json \
|
||||
&& python -m coverage report \
|
||||
; } || { echo 'The test for mcore sysviewtrace_proc JSON functionality has failed. Please examine the artifacts.' ; exit 1; }
|
||||
{ python -m coverage debug sys && \
|
||||
python -m coverage erase > output.json && \
|
||||
python -m coverage run -a $IDF_PATH/tools/esp_app_trace/sysviewtrace_proc.py -j -b sysview_tracing_heap_log.elf heap_log_mcore.svdat >> output.json && \
|
||||
diff output.json expected_output_mcore.json && \
|
||||
python -m coverage report; \
|
||||
} || { echo 'The test for mcore sysviewtrace_proc JSON functionality has failed. Please examine the artifacts.' ; exit 1; }
|
||||
|
@@ -672,46 +672,46 @@
|
||||
"versions": [
|
||||
{
|
||||
"linux-amd64": {
|
||||
"sha256": "eb1fa9b21c65b45a2200af6dcc2914e32335d37b6dbbd181778dcc0dc025e70a",
|
||||
"size": 2445546,
|
||||
"url": "https://github.com/espressif/openocd-esp32/releases/download/v0.12.0-esp32-20250422/openocd-esp32-linux-amd64-0.12.0-esp32-20250422.tar.gz"
|
||||
"sha256": "766293bd7a08900d3536f87a0a7ade960f07266f16e4147f95ca5ce4e15d4c5d",
|
||||
"size": 2489724,
|
||||
"url": "https://github.com/espressif/openocd-esp32/releases/download/v0.12.0-esp32-20250707/openocd-esp32-linux-amd64-0.12.0-esp32-20250707.tar.gz"
|
||||
},
|
||||
"linux-arm64": {
|
||||
"sha256": "f70334a9b12a75b4d943e09fa5db30973037c39dbb54d6fa9f1a7118228b3d1c",
|
||||
"size": 2330926,
|
||||
"url": "https://github.com/espressif/openocd-esp32/releases/download/v0.12.0-esp32-20250422/openocd-esp32-linux-arm64-0.12.0-esp32-20250422.tar.gz"
|
||||
"sha256": "34b6883c372444b49950893b2fc0101aefd10d404a88ef72c97e80199f8544d3",
|
||||
"size": 2371243,
|
||||
"url": "https://github.com/espressif/openocd-esp32/releases/download/v0.12.0-esp32-20250707/openocd-esp32-linux-arm64-0.12.0-esp32-20250707.tar.gz"
|
||||
},
|
||||
"linux-armel": {
|
||||
"sha256": "4ac34d6fd1af86aeda87c8318732f8d691c300c285c7fd2f5037c432c63fbbb3",
|
||||
"size": 2470732,
|
||||
"url": "https://github.com/espressif/openocd-esp32/releases/download/v0.12.0-esp32-20250422/openocd-esp32-linux-armel-0.12.0-esp32-20250422.tar.gz"
|
||||
"sha256": "fd48492cf3ee16577c661fdccc14c349d34a9ab93aac5039ddf72332d4f4b70b",
|
||||
"size": 2517680,
|
||||
"url": "https://github.com/espressif/openocd-esp32/releases/download/v0.12.0-esp32-20250707/openocd-esp32-linux-armel-0.12.0-esp32-20250707.tar.gz"
|
||||
},
|
||||
"linux-armhf": {
|
||||
"sha256": "75372bdbcef2df64013dd36c88836e1029c52955941b69ca463397ccbd287c21",
|
||||
"size": 2310816,
|
||||
"url": "https://github.com/espressif/openocd-esp32/releases/download/v0.12.0-esp32-20250422/openocd-esp32-linux-armhf-0.12.0-esp32-20250422.tar.gz"
|
||||
"sha256": "a468cc108578a1f4553ac0502c814d47791ef79f5997a31e941908fa5119de9c",
|
||||
"size": 2353427,
|
||||
"url": "https://github.com/espressif/openocd-esp32/releases/download/v0.12.0-esp32-20250707/openocd-esp32-linux-armhf-0.12.0-esp32-20250707.tar.gz"
|
||||
},
|
||||
"macos": {
|
||||
"sha256": "9186a7a06304c6d9201cbce4ee3c7099b393bf8d329cda17a68874f92308f6ce",
|
||||
"size": 2548730,
|
||||
"url": "https://github.com/espressif/openocd-esp32/releases/download/v0.12.0-esp32-20250422/openocd-esp32-macos-0.12.0-esp32-20250422.tar.gz"
|
||||
"sha256": "6267be53892a76d535938a1b044b685adc7d292f090447e8a3e3d0f0996474d1",
|
||||
"size": 2585348,
|
||||
"url": "https://github.com/espressif/openocd-esp32/releases/download/v0.12.0-esp32-20250707/openocd-esp32-macos-0.12.0-esp32-20250707.tar.gz"
|
||||
},
|
||||
"macos-arm64": {
|
||||
"sha256": "2cc39318d52f393233ff1f777871aebe5b97b3fbad29556a238489263401b774",
|
||||
"size": 2593819,
|
||||
"url": "https://github.com/espressif/openocd-esp32/releases/download/v0.12.0-esp32-20250422/openocd-esp32-macos-arm64-0.12.0-esp32-20250422.tar.gz"
|
||||
"sha256": "150e938ac48a6ee031ddbc8b31043bc7f2073ab2ee4896b658918d35899673c3",
|
||||
"size": 2628741,
|
||||
"url": "https://github.com/espressif/openocd-esp32/releases/download/v0.12.0-esp32-20250707/openocd-esp32-macos-arm64-0.12.0-esp32-20250707.tar.gz"
|
||||
},
|
||||
"name": "v0.12.0-esp32-20250422",
|
||||
"name": "v0.12.0-esp32-20250707",
|
||||
"status": "recommended",
|
||||
"win32": {
|
||||
"sha256": "ecb4f8533fa9098d10000f5f7e8b8eaa8591015b824b481078ddb2b37e7aa6f2",
|
||||
"size": 2988859,
|
||||
"url": "https://github.com/espressif/openocd-esp32/releases/download/v0.12.0-esp32-20250422/openocd-esp32-win32-0.12.0-esp32-20250422.zip"
|
||||
"sha256": "666274b04af7f36b430b6d063006051c37b8635b5175735ad5af07a1fbc6f486",
|
||||
"size": 3034680,
|
||||
"url": "https://github.com/espressif/openocd-esp32/releases/download/v0.12.0-esp32-20250707/openocd-esp32-win32-0.12.0-esp32-20250707.zip"
|
||||
},
|
||||
"win64": {
|
||||
"sha256": "e9eae8e1a8d0e030cd81dcb08394a9137cb7338a6211dfabcdbdfb37b58c5a23",
|
||||
"size": 2988858,
|
||||
"url": "https://github.com/espressif/openocd-esp32/releases/download/v0.12.0-esp32-20250422/openocd-esp32-win64-0.12.0-esp32-20250422.zip"
|
||||
"sha256": "5186ba3f7ee29fb6ab68a4ed7bb417211bad76ecdcdf9280a9187ebfd549a3c1",
|
||||
"size": 3034680,
|
||||
"url": "https://github.com/espressif/openocd-esp32/releases/download/v0.12.0-esp32-20250707/openocd-esp32-win64-0.12.0-esp32-20250707.zip"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
Reference in New Issue
Block a user