Skip to content

feat(rtt): first-class RTT console support with eject path #148

Description

@apage224

Summary

RTT setup is currently a manual painpoint: users must locate the _SEGGER_RTT control block address, pick the right J-Link probe, and start/drain the buffer by hand. Meanwhile nsx view silently captures nothing for RTT-only apps (e.g. coremark), because nothing declares the app's console transport.

NSX already owns all the data needed to remove this friction (built ELF, SEGGER device/clock config, and --probe-serial plumbing), so RTT can become a first-class console transport that mirrors the existing flash/view model while preserving the ability to "eject" to raw SEGGER/pylink commands.

Motivation

Observed during the AP510 runtime sweep: coremark flashed successfully but nsx view showed no output because its score is emitted over SEGGER RTT (channel 0), not SWO/ITM. See examples/coremark/README.md and the working-but-manual helper examples/coremark/tools/rtt_capture.py, which requires the user to pass a hardcoded --rtt-addr and cannot select a probe serial.

Proposed work

1. nsx rtt command (mirrors nsx view)

  • Same app/board selectors and --probe-serial plumbing already used by view_app (src/neuralspotx/api/_app.py) and the CLI (src/neuralspotx/cli/__init__.py).
  • Auto-extract the _SEGGER_RTT address directly from the built ELF symbol table (no manual hex, no map parsing).
  • Start RTT, wait for the up-buffer to come live (race already handled in examples/coremark/tools/rtt_capture.py), then stream channel 0.
  • Support --out/--file line-streamed capture, matching view --file.

2. Declare console transport in nsx.yml

console:
  transport: rtt   # or swo (default)
  rtt_channel: 0
  • nsx view on an RTT app prints a friendly redirect to nsx rtt instead of silently capturing nothing.
  • nsx rtt on a pure-SWO app warns symmetrically.
  • Removes README/tribal-knowledge as the only source of transport truth.

3. Preserve the eject path

  • --print-cmd / --dry-run: emit the fully resolved invocation (device, speed, probe serial, block address) without running.
  • --print-address: print just the resolved _SEGGER_RTT address (the one annoying-to-find value).
  • Generate a committed per-app/board RTT artifact under build/<board>/jlink/<app>/, mirroring how flash_cmds.jlink / reset_cmds.jlink are generated in src/neuralspotx/cmake/nsx_helpers.cmake.

Rollout order

  1. nsx rtt with auto-address extraction + probe-serial reuse (self-contained, biggest win).
  2. console.transport in nsx.yml + cross-warnings in view/rtt.
  3. Eject affordances (--print-cmd, --print-address, generated RTT artifact).

Acceptance criteria

  • nsx rtt <app> --board <board> --probe-serial <sn> captures coremark output on AP510 with no manual address.
  • nsx view on an RTT-declared app redirects to nsx rtt instead of empty capture.
  • Resolved RTT command/address are inspectable for the manual SEGGER/pylink workflow.

References

  • examples/coremark/README.md (RTT vs SWO note)
  • examples/coremark/tools/rtt_capture.py (current manual helper)
  • src/neuralspotx/cmake/nsx_helpers.cmake (flash/view/reset target generation)
  • src/neuralspotx/api/_app.py, src/neuralspotx/cli/__init__.py (probe-serial plumbing)

Follow-up PR to implement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions