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
  • Hello,

    Usually, it should be sufficient to have CONFIG_LOG and CONFIG_USE_SEGGER_RTT enabled to get RTT logging. Are you able to debug the application to confirm that the program is actually reaching main()?

    Best regards,

    Vidar

  • Hello, 

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

    Best regards,

    Gotoda

  • 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;
    }

  • I have selected Flash in VS Code. The following is displayed in the Terminal:

    west build --build-dir c:/ncs/applications/connectivity_bridge_v3-2-4_v2/build c:/ncs/applications/connectivity_bridge_v3-2-4_v2 --pristine --board thingy91x/nrf5340/cpuapp

  • OK, that looks like the right board to me. No glue, what goes wrong.

  • Hello,

    I tried with the connectivity bridge app myself now. Note that the logger configuration in prj.conf gets overridden by the board specific kconfig fragment in the "boards" folder. I also found that the image got to big when I enabled logging so had to disable the DAP debugger functionality to free up enough FLASH to enable the logger.

    Changes to enable RTT logging in app

    diff --git a/boards/thingy91x_nrf5340_cpuapp.conf b/boards/thingy91x_nrf5340_cpuapp.conf
    index 2b87e97..1c45ce6 100644
    --- a/boards/thingy91x_nrf5340_cpuapp.conf
    +++ b/boards/thingy91x_nrf5340_cpuapp.conf
    @@ -28,7 +28,7 @@ CONFIG_USB_DEVICE_VID=0x1915
     CONFIG_USB_DEVICE_PID=0x910A
     
     CONFIG_USB_MAX_NUM_TRANSFERS=8
    -CONFIG_BRIDGE_CMSIS_DAP_BULK_ENABLE=y
    +#CONFIG_BRIDGE_CMSIS_DAP_BULK_ENABLE=y
     CONFIG_RETENTION_BOOT_MODE=y
     CONFIG_REBOOT=y
     CONFIG_GPIO=y
    @@ -38,18 +38,21 @@ CONFIG_DK_LIBRARY=y
     # Bootloader firmware information
     CONFIG_FW_INFO=y
     CONFIG_SECURE_BOOT_STORAGE=y
    -CONFIG_DAP=y
    -CONFIG_DP_DRIVER=y
    +#CONFIG_DAP=y
    +#CONFIG_DP_DRIVER=y
     
    -CONFIG_CMSIS_DAP_DEVICE_VENDOR="Nordic Semiconductor ASA"
    -CONFIG_CMSIS_DAP_DEVICE_NAME="nrf91"
    +#CONFIG_CMSIS_DAP_DEVICE_VENDOR="Nordic Semiconductor ASA"
    +#CONFIG_CMSIS_DAP_DEVICE_NAME="nrf91"
     
    -CONFIG_BRIDGE_CMSIS_DAP_NORDIC_COMMANDS=y
    +#CONFIG_BRIDGE_CMSIS_DAP_NORDIC_COMMANDS=y
     
     # Reduce logging to save flash space
    -CONFIG_LOG=n
    -CONFIG_USE_SEGGER_RTT=n
    -CONFIG_LOG_BACKEND_RTT=n
    -CONFIG_LOG_BACKEND_RTT_MODE_DROP=n
    +#CONFIG_LOG=n
    +#CONFIG_USE_SEGGER_RTT=n
    +#CONFIG_LOG_BACKEND_RTT=n
    +#CONFIG_LOG_BACKEND_RTT_MODE_DROP=n
     CONFIG_CONSOLE=n
     CONFIG_UART_CONSOLE=n
    +CONFIG_RESET_ON_FATAL_ERROR=n
    +#CONFIG_LTO=y
    +#CONFIG_ISR_TABLES_LOCAL_DECLARATION=y
    \ No newline at end of file
    

    Best regards,

    Vidar

Reply
  • Hello,

    I tried with the connectivity bridge app myself now. Note that the logger configuration in prj.conf gets overridden by the board specific kconfig fragment in the "boards" folder. I also found that the image got to big when I enabled logging so had to disable the DAP debugger functionality to free up enough FLASH to enable the logger.

    Changes to enable RTT logging in app

    diff --git a/boards/thingy91x_nrf5340_cpuapp.conf b/boards/thingy91x_nrf5340_cpuapp.conf
    index 2b87e97..1c45ce6 100644
    --- a/boards/thingy91x_nrf5340_cpuapp.conf
    +++ b/boards/thingy91x_nrf5340_cpuapp.conf
    @@ -28,7 +28,7 @@ CONFIG_USB_DEVICE_VID=0x1915
     CONFIG_USB_DEVICE_PID=0x910A
     
     CONFIG_USB_MAX_NUM_TRANSFERS=8
    -CONFIG_BRIDGE_CMSIS_DAP_BULK_ENABLE=y
    +#CONFIG_BRIDGE_CMSIS_DAP_BULK_ENABLE=y
     CONFIG_RETENTION_BOOT_MODE=y
     CONFIG_REBOOT=y
     CONFIG_GPIO=y
    @@ -38,18 +38,21 @@ CONFIG_DK_LIBRARY=y
     # Bootloader firmware information
     CONFIG_FW_INFO=y
     CONFIG_SECURE_BOOT_STORAGE=y
    -CONFIG_DAP=y
    -CONFIG_DP_DRIVER=y
    +#CONFIG_DAP=y
    +#CONFIG_DP_DRIVER=y
     
    -CONFIG_CMSIS_DAP_DEVICE_VENDOR="Nordic Semiconductor ASA"
    -CONFIG_CMSIS_DAP_DEVICE_NAME="nrf91"
    +#CONFIG_CMSIS_DAP_DEVICE_VENDOR="Nordic Semiconductor ASA"
    +#CONFIG_CMSIS_DAP_DEVICE_NAME="nrf91"
     
    -CONFIG_BRIDGE_CMSIS_DAP_NORDIC_COMMANDS=y
    +#CONFIG_BRIDGE_CMSIS_DAP_NORDIC_COMMANDS=y
     
     # Reduce logging to save flash space
    -CONFIG_LOG=n
    -CONFIG_USE_SEGGER_RTT=n
    -CONFIG_LOG_BACKEND_RTT=n
    -CONFIG_LOG_BACKEND_RTT_MODE_DROP=n
    +#CONFIG_LOG=n
    +#CONFIG_USE_SEGGER_RTT=n
    +#CONFIG_LOG_BACKEND_RTT=n
    +#CONFIG_LOG_BACKEND_RTT_MODE_DROP=n
     CONFIG_CONSOLE=n
     CONFIG_UART_CONSOLE=n
    +CONFIG_RESET_ON_FATAL_ERROR=n
    +#CONFIG_LTO=y
    +#CONFIG_ISR_TABLES_LOCAL_DECLARATION=y
    \ No newline at end of file
    

    Best regards,

    Vidar

Children
No Data
Related