This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to debug nRF52 without RTT?

Hi. I'm quite new to nRF programming. I successfuly solved how to compile/link/flash the software onto nRF52 DK using just a simple editor (Notepad++), the ARM toolchain and makefile.

Now I'm trying to see some logging/debug info. I have found that there are several options:

  • NRF_LOG over RTT
  • NRF_LOG over UART
  • printf

As I understood so far, I need a specialized software and/or hardware for the RTT. Therefore I would prefer the other two.

The questions:

  1. What and where should I configure to enable the NRF_LOG over UART? (NRF_LOG_ENABLE and other sdk_config.h stuff)
  2. What and where should I configure to enable printf logging? (some UART initialization?)
  3. What software tools do I need to capture either the NRF_LOG or printf output? Please recommend som free and/or portable software like e.g. putty.

Please keep in mind that I have only a little experience with such debugging. I'd like to setup a development environment without huge IDEs or specialised hardware.

Thank you.

  • The NRF52 DK has the required j-link for RTT build-in. Its the same one uses to program the chip, and the RTT viewer should be installed together with the other SEGGER tools.

  • I agree, but I've read some posts that RTT consumes much memory. Maybe it has been fixed already but I still believe that something as simple as UART is less hungry than some extensive 3rd party library. And I believe that debugging over UART is enough for many projects. Therefore I am trying to setup the UART debugging.

  • I have played around with this yesterday and got it working. Hope this answer helps someone new to nRF programming...

    The  steps that I performed are:

    1. install Putty Tray (I got some problems with old and good Putty when connecting to serial port)
    2. check the NRF_LOG_BACKEND_UART_BAUDRATE in sdk_config.h
    3. connect putty (yes, I mean Putty Tray) to serial port, use the baudrate from above and also check other UART connection params (parity, stop bit, control flow)
    4. put this code into main.c:
      #include "nrf_log.h"
      #include "nrf_log_ctrl.h"
      #include "nrf_log_default_backends.h"
      
      ...
      
      int main(void) {
        APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
        NRF_LOG_DEFAULT_BACKENDS_INIT();
      
        ...
        
        NRF_LOG_INFO("Hello, UART debugging.")
        
        ...
      }
    5. if using Makefile to compile/link the project, add following lines to Makefile (read the comments):
      # add these .c files to SRC_FILES
      
         $(SDK_ROOT)/components/libraries/experimental_log/src/nrf_log_backend_rtt.c \
         $(SDK_ROOT)/components/libraries/experimental_log/src/nrf_log_backend_serial.c \
         $(SDK_ROOT)/components/libraries/experimental_log/src/nrf_log_backend_uart.c \
         $(SDK_ROOT)/components/libraries/experimental_log/src/nrf_log_default_backends.c \
         $(SDK_ROOT)/components/libraries/experimental_log/src/nrf_log_frontend.c \
         $(SDK_ROOT)/components/libraries/experimental_log/src/nrf_log_str_formatter.c \
      
      # add these folders to INC_FOLDERS
      
        $(SDK_ROOT)/components/libraries/experimental_log \
        $(SDK_ROOT)/components/libraries/experimental_log/src \
      
    6. compile/link/flash

    Now you should see the logs in the putty terminal.

Related