Firmware logging

Stream RTT, defmt, or serial UART output from remote hardware.

Each job reads logs from either RTT or a serial UART. RTT is the default.

ModeCLI optionBest for
RTT--logging rttdefmt, high-rate debug output, and firmware that already uses a debug-probe logger.
Serial--logging serial --baud <RATE>; default baud: 115200Existing UART logging and boards whose firmware exposes output through a configured serial port.

RTT and defmt

RTT writes data through a control block in target RAM. OnMCU finds that block through the debugger and reads the target-to-host channel. It does not use a peripheral UART.

RTT is selected by default:

onmcu run --board NUCLEO-H743ZI --file firmware.elf

The explicit form is:

onmcu run --logging rtt --board NUCLEO-H743ZI --file firmware.elf

For Rust defmt, keep the metadata in the linked ELF and include its logger and linker script:

Cargo.toml
[dependencies]
defmt = "1"
defmt-rtt = "1"
.cargo/config.toml
[target.thumbv7em-none-eabihf]
rustflags = [
  "-C", "link-arg=-Tlink.x",
  "-C", "link-arg=-Tdefmt.x",
]

[env]
DEFMT_LOG = "info"

Your project still needs the target-specific runtime, memory layout, and panic handler.

Serial UART

Select serial logging and pass the firmware's baud rate:

onmcu run \
  --logging serial \
  --baud 115200 \
  --board NUCLEO-F401RE \
  --file firmware.elf

The firmware must configure the UART, pins, clock, framing, and baud rate expected by the board connection. --baud defaults to 115200; it has no effect in RTT mode.

The nucleo-f401re-serial C example configures USART2 on PA2/PA3 at 115200 8N1 and selects --logging serial in its Makefile.

Flush before exiting

A semihosting exit can stop the debug session at once. Before you exit:

  • flush a buffered RTT or defmt logger when the API provides it; or
  • allow enough time for a serial peripheral and bridge to transmit queued bytes.

The serial C example delays briefly after its last line for this reason. Then it calls sys_exit(0) to finish the run.

No output appears

Check these in order:

  1. The selected --logging mode matches the logger compiled into the firmware.
  2. The ELF still contains RTT and defmt metadata when decoding defmt.
  3. The serial baud and framing match the firmware.
  4. The firmware reaches logger initialization and does not fault first.
  5. The target memory layout and selected board match the binary.

See Troubleshooting for job and authentication failures.

On this page