Skip to content
mohammedrynPublic

About

Live FreeRTOS task, CPU, and memory monitoring on STM32.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

RTOSTwin

RTOSTwin records events from Cortex-M firmware and turns the captured stream into a report or timeline on your computer. It provides a C SDK for bare-metal and FreeRTOS applications and a Python CLI for project setup, capture, and offline analysis.

Use it to see which parts of your firmware ran, inspect supported FreeRTOS task events, or review fault data retained by a configured firmware build. The CLI runs locally. With UART telemetry, you can capture from a serial port without attaching a debugger.

Try a capture · Integrate your firmware · Check hardware support · Documentation

Install the CLI

Install from the repository with Python 3.11 or later. The firmware compiler is only needed when you build firmware.

git clone https://github.com/mohammedryn/RTOSTwin.git
cd RTOSTwin
python -m venv .venv

Activate the environment in PowerShell:

.\.venv\Scripts\Activate.ps1

On Linux or macOS:

. .venv/bin/activate

Then install and check the CLI:

python -m pip install -e ".[capture,terminal]"
rtostwin --help

The capture extra installs serial support. The terminal extra adds completion and history to the interactive workspace. For offline analysis alone, install with python -m pip install -e ..

Try a capture without a board

Run this from the repository root:

rtostwin report --input evidence/portable-sdk/2026-11-10-native-fault/raw.bin

The bundled example was generated by a native diagnostic fixture. Its report shows six validated frames, one retained panic record, and the captured program counter and link register. Symbol names require the matching firmware ELF. This fixture lets you try the report command before connecting a device. See the diagnostic examples.

Integrate an existing project

Start with a firmware project that already builds. For guided CMake integration, use the application's configured build directory with CMAKE_EXPORT_COMPILE_COMMANDS=ON. Keep the SDK checkout available at the same path after integration because the generated CMake wiring refers to it.

Scan and preview

Open the workspace with rtostwin shell. Replace these example paths with your own:

/project "D:/MyFirmware"
/scan --build-dir "D:/MyFirmware/build"
/integrate --build-dir "D:/MyFirmware/build" --heartbeat

The scan reads the selected project's settings. Guided setup proposes settings it can establish and asks you for the remaining choices. The last command previews changes to a supported project. The optional heartbeat emits an application event each time the generated service code runs, which is useful for checking the connection.

For a reviewed FreeRTOS project, use --observe scheduler when you want scheduler events. Select the kernel, port, configuration header, and CMake target actually used by your application. Startup must initialize RTOSTwin before task creation. Use /manual to choose integration settings explicitly.

Apply, build, and flash

When the preview matches the intended setup, run:

/integrate --build-dir "D:/MyFirmware/build" --heartbeat --apply
/build "D:/MyFirmware/build"

Use the same options as in the preview, and review the exact changes again before confirming. RTOSTwin saves original files and an integration manifest under the application's .rtostwin/ directory. Use /status to check the result. /undo restores the originals when the integrated files and backups still match. Keep other editors and build tools from writing to the project during apply or undo.

Flash the firmware with your board's usual tool. The workspace builds the application using its existing CMake build directory. Flashing is a separate step.

Capture and inspect the stream

Connect the telemetry interface and use the serial port and baud rate configured for your firmware. These commands run from a regular shell:

rtostwin capture --port COM7 --baud 921600 --duration 12 --output capture-001
rtostwin report --input capture-001
rtostwin perfetto --input capture-001 --output trace-001.json

Use the actual serial device path on your system. Choose a new output directory for each capture and a new filename for each export. Import the JSON into Perfetto to view timestamped observations.

Check the report for decoder diagnostics, frame or record sequence gaps, and device-reported loss. A completed command can still report missing or corrupt data. Perfetto export shows observed events as points in time. See the capture guide and offline analysis guide.

For a bundled board example instead of your own application, follow the NUCLEO-F401RE build and wiring instructions.

How the SDK fits into firmware

The SDK records timestamped events into a bounded buffer. Your main loop or an existing task calls rtostwin_poll() to prepare and submit a limited amount of pending data. Polling returns without waiting for the receiver or for a transfer to finish. The transport signals completion when it has finished using the submitted buffer. If recording outpaces transmission and the recorder fills, the SDK counts dropped records.

Guided integration can wire startup and service calls for supported source layouts. Add application events at the points you want to observe, and assign IDs and arguments that make sense for your application. For example, after initializing and starting the SDK:

#include <rtostwin/rtostwin.h>

/* Inside the application, when a sample is ready. */
RTOSTWIN_EVENT(0x8001u, sample_number, sample_value);

You can use rtostwin_record() directly when the application needs the return status. The SDK can run without a separate task or heap allocation. An optional FreeRTOS worker uses storage supplied by the application. See polling and lifecycle and FreeRTOS integration.

Select a profile for the observations you need:

Profile Use
minimal Application events with fixed storage for 16 records and two 128-byte frames
trace Configurable buffers and selected event categories, including supported scheduler events
health Health observations from an explicitly configured provider
flight Keep a bounded window of events around a trigger
disabled Build out instrumentation that uses the SDK event macro

See profiles and flight recording for setup and limitations. Retained fault data requires separate panic retention configuration.

Hardware and project support

Setup Support in this checkout
Existing CMake application Guided integration for supported literal executable targets and recognized startup and service locations
Bare-metal application Application events with a suitable clock, lock, and transmit binding
FreeRTOS scheduler tracing Guided setup for the reviewed single-core FreeRTOS 11.1.0 kernel and supported task hooks
NUCLEO-F401RE UART Reviewed USART2 TX DMA binding for the documented 84 MHz core and 42 MHz APB1 setup. Confirm clock settings and peripheral ownership before applying.
Other Cortex-M boards Provide board-specific bindings or existing application callbacks and validate on the target
PlatformIO, Arduino, and Teensy PlatformIO environment scanning is available. Automatic build integration and a Teensy-specific transport recipe are pending.
RTT and SPI Separate transports with their own target and host setup. See the RTT guide and SPI guide.

An application that already owns its telemetry connection can supply timestamp, interrupt-mask and nonblocking transmit callbacks. Existing interrupt handlers and FreeRTOS trace hooks may require manual composition. Guided scheduler setup covers the documented task hooks. Queue, mutex, health, interrupt, and fault observations require their own setup. See the integration guide and port contracts.

Hardware evidence and performance

Generated bare-metal and FreeRTOS integrations have run on the NUCLEO-F401RE. The documented FreeRTOS scheduler capture decoded 48,460 events in 12 seconds at 2 Mbaud, with no reported decoder diagnostics, sequence gaps, or device loss. That run used a 64-record buffer, 512-byte frames, and a 16-record service budget. The report includes earlier attempts that lost events with insufficient capacity or service. Guided integration report

In the separate minimal-profile benchmark, the latest reported section sums on the F401 at a nominal 1,000 application events per second were 2.83% for FreeRTOS and 2.58% for bare metal. These measurements cover selected code sections and can include overlapping interrupt time. The under-1% total CPU target, complete timing and stack bounds, and broader board validation remain open. Performance report

Documentation

Task Guide
Set up an application, preview edits, or undo integration Project integration
Find CLI commands or build an SDK package CLI reference · Building
Set up compilers and pinned firmware dependencies Dependencies
Generate hardware bindings or use an existing connection Generated bindings · Application uplink
Capture, decode, report, or export a timeline Capture · Offline analysis
Read the binary format Protocol v2
Find current implementation and verification status SDK progress · Commit ledger
Use the older SDK and host bridge Compatibility quick start · Optional metrics integration

Run rtostwin --help for scriptable commands. In the workspace, /help lists available commands and /exit closes the session.

Develop RTOSTwin

Path Contents
sdk/ Device library, Cortex-M ports, FreeRTOS adapter, and separate v1 compatibility code
host/cli/ Project integration, capture, and offline analysis
host/bridge/ Optional v1 decoder and metrics bridge
hardware/, examples/ Hardware profiles, binding templates, and reference projects
protocol/ Versioned wire definitions
tests/, tools/ Tests, build checks, and measurement tools
docs/, evidence/, archive/ Guides, validation records, and preserved project history

Install Python, a host C compiler, CMake 3.24+, Ninja, pytest, and the bridge dependencies as described in the dependency guide. Run from the repository root:

python tools/run_legacy_tests.py
python -m pytest host/bridge/tests -q -p no:cacheprovider
cmake --preset host-debug
cmake --build --preset host-debug
ctest --preset host-debug --no-tests=error --output-on-failure
python tools/check_repository.py

Run python -m pytest -q -p no:cacheprovider for the full Python suite. Some integration checks need the pinned Arm toolchain and firmware dependencies. Physical transport, timing, and board behavior are verified separately. See the repository layout and contributor instructions.

License

No project-wide license is declared in this checkout. Third-party dependencies retain their own licenses and notices. Pinned firmware dependencies

About

Live FreeRTOS task, CPU, and memory monitoring on STM32.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages