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