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

RTT on SDK 14.2 and Segger

Hi,

My config :

Board NRF52DK
SDK 14.2
Segger ES Release 3.30
SEGGER J-Link V6.22a
macOS 10.13.1

I want to use RTT to debug my code. As a starting point I've used the blinky example. I can upload it to the board successfully.

Now I want to put a log every time a led switch so I followed the official documentation my entire code for the blinky example now looks like this :

#include <stdbool.h>
#include <stdint.h>
#include "nrf_delay.h"
#include "boards.h"
#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"

int main(void)
{
    /* Initializing Log */
    ret_code_t err_code;
    err_code = NRF_LOG_INIT(NULL);
    NRF_LOG_DEFAULT_BACKENDS_INIT();

    /* Configure board. */
    bsp_board_leds_init();

    /* Toggle LEDs. */
    while (true)
    {
        for (int i = 0; i < LEDS_NUMBER; i++)
        {
            bsp_board_led_invert(i);
            NRF_LOG_INFO("BLINK");
            nrf_delay_ms(500);
        }
    }
}

I've added to my Makefile the following files :

nrf_balloc.c
nrf_fprintf_format.c
nrf_fprintf.c
nrf_log_backend_serial.c
nrf_log_default_backends.c
nrf_log_frontend.c
nrf_log_str_formatter.c
nrf_memobj.c
SEGGER_RTT_printf.c
SEGGER_RTT_Syscalls_SES.c
SEGGER_RTT.c

I've added the following directories to the preprocessor :

some_path/nRF5_SDK_14.2.0/components/libraries/experimental_log some_path/nRF5_SDK_14.2.0/components/libraries/experimental_log/src some_path/nRF5_SDK_14.2.0/external/fprintf some_path/nRF5_SDK_14.2.0/components/libraries/atomic some_path/nRF5_SDK_14.2.0/components/libraries/balloc some_path/nRF5_SDK_14.2.0/components/libraries/experimental_memobj some_path/nRF5_SDK_14.2.0/components/libraries/experimental_memobj/src some_path/nRF5_SDK_14.2.0/external/segger_rtt

Here are the changes I've made on the sdk_config.h :

#define NRF_MEMOBJ_ENABLED 1
#define NRF_LOG_ENABLED 1
#define NRF_LOG_DEFERRED 0
#define NRF_LOG_BACKEND_SERIAL_USES_RTT 1
#define NRF_LOG_BACKEND_RTT_OUTPUT_BUFFER_SIZE 512
// Not sure these are useful but just in case ....
#define SEGGER_RTT_CONFIG_BUFFER_SIZE_UP 512
#define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 2
#define SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN 16
#define SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS 2
#define SEGGER_RTT_CONFIG_DEFAULT_MODE 0

For the RTT, I've been inspired by this thread.

On the first terminal I run : JLinkExe -device NRF52 -if SWD -speed 4000 -autoconnect 1

On the other : JLinkRTTClient

Terminal #1 output :

JLinkExe -device NRF52 -if SWD -speed 4000 -autoconnect 1
SEGGER J-Link Commander V6.22a (Compiled Nov 28 2017 17:57:01)
DLL version V6.22a, compiled Nov 28 2017 17:56:49

Connecting to J-Link via USB...O.K.
Firmware: J-Link OB-SAM3U128-V2-NordicSemi compiled Jul 24 2017 17:30:12
Hardware version: V1.00
S/N: 682621274
VTref = 3.300V
Device "NRF52" selected.


Connecting to target via SWD
Found SW-DP with ID 0x2BA01477
Found SW-DP with ID 0x2BA01477
Scanning AP map to find all available APs
AP[2]: Stopped AP scan as end of AP map has been reached
AP[0]: AHB-AP (IDR: 0x24770011)
AP[1]: JTAG-AP (IDR: 0x02880000)
Iterating through AP map to find AHB-AP to use
AP[0]: Core found
AP[0]: AHB-AP ROM base: 0xE00FF000
CPUID register: 0x410FC241. Implementer code: 0x41 (ARM)
Found Cortex-M4 r0p1, Little endian.
FPUnit: 6 code (BP) slots and 2 literal slots
CoreSight components:
ROMTbl[0] @ E00FF000
ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS-M7
ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 003BB002 DWT
ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 002BB003 FPB
ROMTbl[0][3]: E0000000, CID: B105E00D, PID: 003BB001 ITM
ROMTbl[0][4]: E0040000, CID: B105900D, PID: 000BB9A1 TPIU
ROMTbl[0][5]: E0041000, CID: B105900D, PID: 000BB925 ETM
Cortex-M4 identified.
J-Link>

Terminal #2 output :

JLinkRTTClient
###RTT Client: ************************************************************
###RTT Client: *           SEGGER MICROCONTROLLER GmbH & Co KG            *
###RTT Client: *   Solutions for real time microcontroller applications   *
###RTT Client: ************************************************************
###RTT Client: *                                                          *
###RTT Client: *  (c) 2012 - 2016  SEGGER Microcontroller GmbH & Co KG    *
###RTT Client: *                                                          *
###RTT Client: *     www.segger.com     Support: [email protected]       *
###RTT Client: *                                                          *
###RTT Client: ************************************************************
###RTT Client: *                                                          *
###RTT Client: * SEGGER J-Link RTT Client   Compiled Nov 28 2017 17:57:06 *
###RTT Client: *                                                          *
###RTT Client: ************************************************************

###RTT Client: -----------------------------------------------
###RTT Client: Connecting to J-Link RTT Server via localhost:19021  Connected.
SEGGER J-Link V6.22a - Real time terminal output
J-Link OB-SAM3U128-V2-NordicSemi compiled Jul 24 2017 17:30:12 V1.0, SN=682621274
Process: JLinkExe

The LEDs blinks but nothing appears in the RTT Client terminal...

Am I missing something ?

Thank you very much for your help.

Related