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.
| Mode | CLI option | Best for |
|---|---|---|
| RTT | --logging rtt | defmt, high-rate debug output, and firmware that already uses a debug-probe logger. |
| Serial | --logging serial --baud <RATE>; default baud: 115200 | Existing 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.elfThe explicit form is:
onmcu run --logging rtt --board NUCLEO-H743ZI --file firmware.elfFor Rust defmt, keep the metadata in the linked ELF and include its logger and linker script:
[dependencies]
defmt = "1"
defmt-rtt = "1"[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.elfThe 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
defmtlogger 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:
- The selected
--loggingmode matches the logger compiled into the firmware. - The ELF still contains RTT and
defmtmetadata when decodingdefmt. - The serial baud and framing match the firmware.
- The firmware reaches logger initialization and does not fault first.
- The target memory layout and selected board match the binary.
See Troubleshooting for job and authentication failures.