From a69fa9504aab4a3a21063200111eae64e16506c8 Mon Sep 17 00:00:00 2001 From: hanzhijian Date: Wed, 26 Aug 2026 17:30:25 +0800 Subject: [PATCH 1/2] [add] MRamTrace: lightweight RAM-backed function tracing for MCU firmware --- tools/Kconfig | 1 + tools/MRamTrace/Kconfig | 30 ++++++++++++++++++++++++++++++ tools/MRamTrace/package.json | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 tools/MRamTrace/Kconfig create mode 100644 tools/MRamTrace/package.json diff --git a/tools/Kconfig b/tools/Kconfig index 5f11dd57df..1284631db8 100644 --- a/tools/Kconfig +++ b/tools/Kconfig @@ -58,4 +58,5 @@ source "$PKGS_DIR/packages/tools/uORB/Kconfig" source "$PKGS_DIR/packages/tools/RT-Tunnel/Kconfig" source "$PKGS_DIR/packages/tools/Virtual-Terminal/Kconfig" source "$PKGS_DIR/packages/tools/fee/Kconfig" +source "$PKGS_DIR/packages/tools/MRamTrace/Kconfig" endmenu diff --git a/tools/MRamTrace/Kconfig b/tools/MRamTrace/Kconfig new file mode 100644 index 0000000000..dcb4ad547c --- /dev/null +++ b/tools/MRamTrace/Kconfig @@ -0,0 +1,30 @@ +menuconfig PKG_USING_MRAMTRACE + bool "MRamTrace: low-overhead RAM-based function tracing" + default n + help + MRamTrace is a lightweight, RAM-resident function tracer for + microcontrollers. It uses GCC/Clang -finstrument-functions to capture + function enter/exit events into a ring buffer, then exports them for + offline call-graph / flamegraph analysis (Perfetto, Speedscope, + KCachegrind, FlameGraph). + +if PKG_USING_MRAMTRACE + + config PKG_MRAMTRACE_USING_DEMO + bool "Enable the RT-Thread demo" + default y + help + Builds a demo that runs a signal-processing workload (compiled with + -finstrument-functions), captures a trace window, and exports the + events to the console via the `ram_trace_demo` shell command. + + config PKG_MRAMTRACE_DEMO_CPU_HZ + int "Demo timestamp frequency (CPU clock Hz)" + default 168000000 + depends on PKG_MRAMTRACE_USING_DEMO + help + CPU clock frequency in Hz, used to convert the Cortex-M DWT cycle + counter timestamps into wall-clock time. Set this to the actual + core clock of your target. + +endif diff --git a/tools/MRamTrace/package.json b/tools/MRamTrace/package.json new file mode 100644 index 0000000000..f988e4f0a2 --- /dev/null +++ b/tools/MRamTrace/package.json @@ -0,0 +1,33 @@ +{ + "name": "MRamTrace", + "description": "MRamTrace is a lightweight RAM-backed function tracing and offline visualization tool for MCU firmware. It captures function enter/exit events via GCC/Clang -finstrument-functions into a ring buffer, then exports them (UART, log, file, Bluetooth, or custom backend) for offline call-graph, flamegraph, Perfetto, Speedscope and KCachegrind analysis.", + "description_zh": "MRamTrace 是一款轻量级基于 RAM 的 MCU 函数追踪与离线可视化工具,通过 GCC/Clang 的 -finstrument-functions 将函数进入/退出事件写入环形缓冲区,冻结后通过 UART、日志、文件、蓝牙或自定义后端导出,结合 ELF 生成调用图、火焰图、Perfetto、Speedscope 和 KCachegrind 等离线分析数据。", + "enable": "PKG_USING_MRAMTRACE", + "keywords": [ + "trace", + "profiling", + "flamegraph", + "callgraph", + "perf", + "instrument" + ], + "category": "tools", + "author": { + "name": "hanzhijian", + "email": "hanzhijian1991@gmail.com", + "github": "Zepp-Hanzj" + }, + "license": "MIT", + "repository": "https://github.com/Zepp-Hanzj/MRamTrace", + "homepage": "https://github.com/Zepp-Hanzj/MRamTrace#readme", + "doc": "https://github.com/Zepp-Hanzj/MRamTrace/blob/main/README.md", + "readme": "MRamTrace is a lightweight RAM-backed function tracing and offline visualization tool for MCU firmware. It captures function enter/exit events via GCC/Clang -finstrument-functions into a ring buffer, then exports them for offline call-graph, flamegraph, Perfetto, Speedscope and KCachegrind analysis.", + "site": [ + { + "version": "latest", + "URL": "https://github.com/Zepp-Hanzj/MRamTrace.git", + "filename": "MRamTrace.zip", + "VER_SHA": "main" + } + ] +} From 33b572e77ca0254af71e1a5360fc090d3d905233 Mon Sep 17 00:00:00 2001 From: hanzhijian Date: Wed, 26 Aug 2026 18:02:28 +0800 Subject: [PATCH 2/2] Pin MRamTrace to v1.0.0 release commit --- tools/MRamTrace/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/MRamTrace/package.json b/tools/MRamTrace/package.json index f988e4f0a2..9166cd094f 100644 --- a/tools/MRamTrace/package.json +++ b/tools/MRamTrace/package.json @@ -27,7 +27,7 @@ "version": "latest", "URL": "https://github.com/Zepp-Hanzj/MRamTrace.git", "filename": "MRamTrace.zip", - "VER_SHA": "main" + "VER_SHA": "81c2e76605c87eb387b06c98b8ab1162a655e888" } ] }