Can't enable RTT trace

Hello,

I need to do some RTT trace logging, but I can’t enable it. I am trying to create minimal example code, and for this purpose I am using the UDP sample.

I added these lines to prj.conf to enable the RTT console:
# Console
CONFIG_CONSOLE=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_RTT_CONSOLE=y
CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=4096

And these lines to enable trace:
# Enable trace
CONFIG_NRF_MODEM_LIB_TRACE=y
CONFIG_NRF_MODEM_LIB_TRACE_BACKEND_RTT=y

The console is working, but the trace is not being captured. What could be the problem?

To start the trace capture, I am using the following command:
nrfjprog --reset && JLinkRTTLogger -Device NRF9160_XXAA -If SWD -Speed 50000 modemtraces.bin

And I get the output

@Eizenss-Mac-mini udp % nrfjprog --reset && JLinkRTTLogger -Device NRF9160_XXAA -If SWD -Speed 50000 modemtraces.bin
Applying system reset.
Run.
SEGGER J-Link RTT Logger
Compiled Jun 4 2025 12:16:00
(c) 2016-2017 SEGGER Microcontroller GmbH, www.segger.com
Solutions for real time microcontroller applications

Default logfile path: /Users/eizenspoiss/Library/Application Support/SEGGER

------------------------------------------------------------


Shutting down... Done.%


Test setup:

  • nRF9160 DK

  • macOS

  • SDK version 2.5.0


PS:
I used this ticket as guide
https://devzone.nordicsemi.com/f/nordic-q-a/104983/how-to-capture-nrf9160-modem-traces-using-rtt




Parents Reply
  • Finally I found, why the modem trace via RTT failed in the other ticket.

    Assuming to enable the snippet with 

    west build -S nrf91-modem-trace-rtt 

    the pain will be, that the snippet is applied to all images including McuBoot, and so it fails in the end.

    Using

    west build -- -D<app>_SNIPPET="nrf91-modem-trace-rtt"

    (with the name of the application folder as <app> )

    it "works on my machine" ;-).

Children
  • Thanks for pointing out (and reminding me). Did a quick search in our docs using the AI search tool, and it provided the following answer (not far from your answer)


    How do I collect modem traces through RTT?

    To collect modem traces through RTT (Real Time Transfer) on an nRF91 Series device, follow these steps:

    1. Enable RTT Trace Backend in Your Application

      In your project configuration file (prj.conf), add the following Kconfig options:

      CONFIG_NRF_MODEM_LIB_TRACE=y CONFIG_NRF_MODEM_LIB_TRACE_BACKEND_RTT=y CONFIG_USE_SEGGER_RTT=y

      Alternatively, you can enable RTT tracing by adding the nrf91-modem-trace-rtt snippet to your build. For example, using west:

      west build --board <board_target> -- -D<image_name>_SNIPPET="nrf91-modem-trace-rtt"

      Or with CMake:

      -D<image_name>_SNIPPET="nrf91-modem-trace-rtt"

      nRF91 modem traces with RTT backend using snippets

    2. Build and Program the Firmware

      Build your application with the above configuration and flash it to your device.

    3. Capture the Trace Using J-Link RTT Logger

      Use the SEGGER J-Link RTT Logger to capture the modem trace. Run the following command (adjust the device and file path as needed):

      JLinkRTTLogger -Device NRF9160_XXAA -If SWD -Speed 50000 -RTTChannel 1 modem_trace.bin

      This will save the raw modem trace data to modem_trace.bin How to capture nrf9160 modem traces using RTT?.

    4. Convert the Trace to PCAP Format (Optional)

      You can convert the captured .bin file to PCAP format for analysis in Wireshark using the Cellular Monitor app or nrfutil:

      nrfutil trace lte --input-file modem_trace.bin --output-pcapng rtt-trace.pcapng

      Asset Tracker Template: Modem Tracing

    5. View the Trace

      • Open the .bin or .pcapng file in the Cellular Monitor app or Wireshark for analysis.
      • Note: In the current release, Cellular Monitor does not support live RTT capture, but you can load and view previously captured RTT traces Viewing RTT traces in Cellular Monitor.

    Summary:
    Enable RTT tracing in your firmware, capture the trace with J-Link RTT Logger, and analyze the trace using Cellular Monitor or Wireshark. This method is especially useful if your hardware does not have a spare UART for trace output.

    If you need to capture both application logs and modem traces over RTT simultaneously, use different RTT channels for each and capture them in separate terminals Asset Tracker Template: Modem Tracing.

  • west build --board <board_target> -- -D<image_name>_SNIPPET="nrf91-modem-trace-rtt"

    Yes, that's what's documented. But it leaves you with the question, what the "<image_name>" will be ;-).

    The answer may be surprising, because "The name of the default image is the name of the folder it resides is". 

  • At least the developers are aware. Nothing more we can do there.

Related