Neural Inverse is Open Source →
DocsSerial & Tracing

Serial & Tracing

Three serial communication protocols are integrated into the Firmware Environment.

UART Serial Monitor

Port Detection

> fw_serial_list_ports

Auto-detects USB serial devices:

  • ST-Link virtual COM port
  • J-Link CDC
  • FTDI (FT232, FT2232)
  • CP2102 / CP2104
  • CH340 / CH341

Connecting

> fw_serial_connect /dev/ttyUSB0 115200

Parameters:

  • Port path
  • Baud rate (auto-detection available via fw_serial_auto_baud)
  • Data bits (default: 8)
  • Parity (default: none)
  • Stop bits (default: 1)

Sending Data

> fw_serial_send "AT+RST\r\n"

Sends a string. For binary data, use hex mode.

Reading

> fw_serial_read

Returns buffered received data with timestamps per line.

Features

  • Auto-reconnect — Recovers when USB device disconnects/reconnects
  • DTR/RTS control — Toggle signals for bootloader entry (e.g., ESP32 auto-reset)
  • HEX mode — Binary protocol display
  • Log export — Export session to text or CSV
  • Ring buffer — Configurable max line count

Baud Rate Auto-Detection

> fw_serial_auto_baud

Tries common baud rates (9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600) and reports which produces valid ASCII.

RTT (Real-Time Transfer)

Segger Real-Time Transfer provides zero-overhead debug logging over SWD/JTAG — no UART pins required.

How It Works

RTT uses a small RAM buffer on the MCU. The debug probe reads this buffer in the background during normal execution, with zero CPU overhead.

Requirements

  • Segger J-Link probe (or compatible)
  • RTT control block in firmware (SEGGER_RTT.h)

Backends

BackendToolNotes
JLinkExeSegger CLIMost reliable
pylinkPython packageScriptable

Usage

> fw_rtt_start

Starts RTT session. Data flows from MCU to host via the debug probe.

> fw_rtt_read 0

Reads from channel 0 (default printf/logging channel).

> fw_rtt_write 1 "config:verbose"

Writes to a down-channel (host → MCU).

Channels

RTT supports up to 32 channels:

  • Channel 0 — Default printf/logging (up)
  • Channels 1-15 — Custom data (up)
  • Channels 16-31 — Down channels (host → MCU)

Storage

RTT logs are saved to .inverse/rtt/<sessionId>/ch<N>.log.

ITM / SWO (Instrumentation Trace Macrocell)

ARM Cortex-M3/M4/M7/M33 processors include hardware tracing via the SWO (Serial Wire Output) pin.

Requirements

  • Cortex-M3 or higher
  • SWO pin connected to debug probe
  • CPU frequency known (for SWO baud calculation)

Usage

> fw_itm_start

Connects to ITM via SWO pin.

> fw_itm_read

Reads ITM trace output.

SWO Profiling

> fw_swo_profile

Uses DWT (Data Watchpoint and Trace) cycle counter and exception trace for:

  • Function timing
  • Interrupt latency
  • Sleep/wake profiling

Agent Tools

ToolDescription
fw_serial_list_portsList available serial ports
fw_serial_connectConnect to a serial port
fw_serial_disconnectDisconnect
fw_serial_sendSend data
fw_serial_readRead received data
fw_serial_monitorStream serial output
fw_serial_clearClear buffers
fw_serial_auto_baudAuto-detect baud rate
fw_rtt_startStart RTT session
fw_rtt_readRead RTT channel
fw_rtt_writeWrite to RTT down-channel
fw_itm_startStart ITM/SWO tracing
fw_itm_readRead ITM output
fw_swo_profileDWT cycle profiling

Was this page helpful?

Last edited