Segger RTT (NCS 3.2.4)

We are developing the nRF5340 for the Thingy91X based on Connectivity Bridge (NCS 3.2.4).
I want to output logs from SWD and view them with RTT Viewer, but even when I call LOG_INF() or printk() at the beginning of the main function, no logs are output at all.
The following definitions are already present in prj.conf, but are there any other settings that need to be configured?

prj.conf

# Logging
CONFIG_LOG=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_RTT_MODE_DROP=y
CONFIG_LOG_MODE_IMMEDIATE=y
CONFIG_LOG_DEFAULT_LEVEL=4
CONFIG_LOG_PRINTK=y

# Console
CONFIG_CONSOLE=y
CONFIG_RTT_CONSOLE=y
CONFIG_UART_CONSOLE=n
CONFIG_LOG_BACKEND_UART=n
CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=1024
CONFIG_SEGGER_RTT_BUFFER_SIZE_DOWN=16

# printk support
CONFIG_PRINTK=y


main.c
 
/*
 * Copyright (c) 2020 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
 */

#include <zephyr/kernel.h>

#include <app_event_manager.h>
#include <hw_id.h>

#define MODULE main
#include "module_state_event.h"

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(MODULE);

static uint8_t usb_serial_str[] = "THINGY91_12PLACEHLDRS";

/* Overriding weak function to set iSerialNumber at runtime. */
uint8_t *usb_update_sn_string_descriptor(void)
{
#if defined(CONFIG_SOC_SERIES_NRF52X)
	snprintk(usb_serial_str, sizeof(usb_serial_str), "THINGY91_%04X%08X",
				(uint32_t)(NRF_FICR->DEVICEADDR[1] & 0x0000FFFF)|0x0000C000,
				(uint32_t)NRF_FICR->DEVICEADDR[0]);
#else
	char buf[HW_ID_LEN] = {0};

	if (!hw_id_get(buf, ARRAY_SIZE(buf))) {
		snprintk(usb_serial_str, sizeof(usb_serial_str), "THINGY91X_%s", buf);
	}
#endif
	return usb_serial_str;
}

int main(void)
{
	LOG_ERR("This is a error message!");
	LOG_WRN("This is a warning message!");
	LOG_INF("This is a information message!");
	LOG_DBG("This is a debugging message!");
	printk("This is a printk message!");

	if (app_event_manager_init()) {
		LOG_ERR("Application Event Manager not initialized");
	} else {
		module_set_state(MODULE_STATE_READY);
	}
	return 0;
}
 

Parents Reply Children
  • Hello, 

    The program has reached the main() function. I confirmed this by toggling the LED.

    Best regards,

    Gotoda

  • Thanks for confirming. To ensure that it is not entering a boot loop either, please try adding CONFIG_RESET_ON_FATAL_ERROR=n to your project configuration file (prj.conf)

  • Adding CONFIG_RESET_ON_FATAL_ERROR=n did not change the situation.

  • Thanks for confirming. To help verify your setup, please try programming the attached hex file and see if that works which I've confirmed worked on my end. It's based on the "Hello World" sample, but changed the code to the following:

    #include <stdio.h>
    #include <zephyr/kernel.h>
    
    #include <zephyr/logging/log.h>
    LOG_MODULE_REGISTER(app);
    
    int main(void)
    {
    	LOG_INF("RTT test");
    	
    	for(;;) {
    		printk("Hello World! %s\n", CONFIG_BOARD_TARGET);
    		k_msleep(1000);
    	}
    }

    and added the following two lines to the project configuration (prj.conf):

    CONFIG_LOG=y
    CONFIG_USE_SEGGER_RTT=y

    Expected output

    Hex file

    8015.merged.hex

  • When I write the provided hex file, "Hello World!" is displayed in the RTT Viewer (updated two lines every two seconds).

    I tried adding that main statement to the Connectivity Bridge's default code, but nothing is displayed in the RTT Viewer.

    /*
     * Copyright (c) 2020 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
     */
    
    #include <zephyr/kernel.h>
    
    #include <app_event_manager.h>
    #include <hw_id.h>
    
    #define MODULE main
    #include "module_state_event.h"
    
    #include <zephyr/logging/log.h>
    LOG_MODULE_REGISTER(MODULE);
    
    static uint8_t usb_serial_str[] = "THINGY91_12PLACEHLDRS";
    
    /* Overriding weak function to set iSerialNumber at runtime. */
    uint8_t *usb_update_sn_string_descriptor(void)
    {
    #if defined(CONFIG_SOC_SERIES_NRF52X)
    	snprintk(usb_serial_str, sizeof(usb_serial_str), "THINGY91_%04X%08X",
    				(uint32_t)(NRF_FICR->DEVICEADDR[1] & 0x0000FFFF)|0x0000C000,
    				(uint32_t)NRF_FICR->DEVICEADDR[0]);
    #else
    	char buf[HW_ID_LEN] = {0};
    
    	if (!hw_id_get(buf, ARRAY_SIZE(buf))) {
    		snprintk(usb_serial_str, sizeof(usb_serial_str), "THINGY91X_%s", buf);
    	}
    #endif
    	return usb_serial_str;
    }
    
    int main(void)
    {
    	LOG_INF("RTT test");
    
    	for(;;) {
    		printk("Hello World! %s\n", CONFIG_BOARD_TARGET);
    		k_msleep(1000);
    	}
    
    	if (app_event_manager_init()) {
    		LOG_ERR("Application Event Manager not initialized");
    	} else {
    		module_set_state(MODULE_STATE_READY);
    	}
    	return 0;
    }

Related