Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

what are the required steps/files/definitions/commands to get RTT output from a custom app into RTT Viewer ?

I am using an nRF chip and the nRF SDK for 1st time and I think I am still at the steep part of the learning curve.

My problem is that I cannot get the log from my custom app in RTT Viewer. I use:

  • custom PCB with Taiyo Yuden EYSKBNZWB/nRF52840 Wireless Module
  • SDK 17.0.2
  • arm gcc 10.3.1
  • J-Link RTT Viewer V7.52b (JLinkRTTViewerExe)
  • nRF5_SDK/examples/peripheral/template_project

In my main.c source file I have included the following headers: https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.2.0%2Flib_nrf_log.html

  • #include "nrf_log_ctrl.h"
  • #include "nrf_log_default_backends.h"
  • #include "nrf_log.h"

Again in the main.c source file, I have the define - https://devzone.nordicsemi.com/f/nordic-q-a/29977/undefined-reference-to-nrf_log_default_backend_init

  • #define NRF_LOG_BACKEND_RTT_ENABLED 1

In the Makefile @ nRF5_SDK/examples/peripheral/template_project/pca10056/blank/armgcc I added the following line:

  • $(SDK_ROOT)/components/libraries/log/src/nrf_log_default_backends.c \

in order to solve the linker issue: main.c: undefined reference to `nrf_log_default_backends_init'

In the sdk_config.h file @ nRF5_SDK/examples/peripheral/template_project/pca10056/blank/config I have the follwoing settings:

The contents of my main.s source file are:

int main ( void ) {
    ret_code_t err_code = NRF_LOG_INIT ( NULL );
    APP_ERROR_CHECK ( err_code );
    NRF_LOG_DEFAULT_BACKENDS_INIT ();
    
    while ( true ) {
        uint32_t i ;

        for ( i = 0; i < 10; i++ ) {
            NRF_LOG_INFO ( "i = %u\r\n", i );
        }
    }
}

I thought that I could see some numbers printed in RTT VIewer but unfortunately I still can't manage to get the RTT output into the RTT Viewer after reading several posts so I would ask for help at this point. Any would be highly appreciated :-)

P.S. I think the connection PC <-> J-Link <-> PCB works fine as I managed to get an LED blink ca. every second.

Parents
  • Okay, glad to hear we've resolved one part of the problem then!

    Okay, seeing as you're using nrfjprog to do the reset that makes sense. nrfjprog halts the CPU to hijack the debug/trace module and thus disconnect the RTT viewer from the J-Link device. Unfortunately, the RTT viewer does not have the feature that some serial terminals do (like teraterm for instance) where it is able to detect when the COM port is available again and automatically reconnect.

    You will either need to do logging over UART (serial) with a terminal that has this feature, or reset the device in your application, either by a button reset or a timeout that resets the device to be able to see the logging behave correctly. It seems like your application runs as intended, but that the RTT viewer is disconnected when you do the nrfjprog reset and thus you don't see any further logging information.

    Best regards,

    Simon

  • the RTT viewer is disconnected when you do the nrfjprog reset and thus you don't see any further logging information

    Yes, this is unfortunately true. However, Segger's J-Link Commander can issue a reset without disconnecting the RTT viewer.

    So instead of running nrfjprog in a terminal, open J-Link commander and issue a reset there.

Reply Children
  • Wow, thanks for the suggestion, !

    Just tried it out, and it works :-)

    Only 1 thing to add: issuing only "R" (for reset) in my case only halts the program (I waited for a while :-). In order to get the output in RTTViewer displayed again, I had to run a "Go" command (CPU starts again):

    ...
    Cortex-M4 identified.
    J-Link>R
    Reset delay: 0 ms
    Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.
    J-Link>Go
    J-Link>

Related