<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>printk on USB port nrf dongle</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/87347/printk-on-usb-port-nrf-dongle</link><description>I have working zigbee switch example for nrf52840 dongle and I want to add print. Am I using correct code changes? please suggest, Thank you. 
 printk is not giving any printouts. I can see the &amp;quot;Zephyr USB Console Sample&amp;quot; in available ports in windows</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 29 Apr 2022 08:32:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/87347/printk-on-usb-port-nrf-dongle" /><item><title>RE: printk on USB port nrf dongle</title><link>https://devzone.nordicsemi.com/thread/365534?ContentTypeID=1</link><pubDate>Fri, 29 Apr 2022 08:32:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:665e8fa1-9921-4dc2-a7f0-e254b8893136</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I use your &lt;span&gt;nrf52840dongle_nrf52840.overlay, this prj.conf&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#
# Copyright (c) 2020 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

CONFIG_NCS_SAMPLES_DEFAULTS=y

CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_SERIAL=y
CONFIG_GPIO=y

# Make sure printk is not printing to the UART console
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y


CONFIG_HEAP_MEM_POOL_SIZE=2048

CONFIG_ZIGBEE=y
CONFIG_ZIGBEE_APP_UTILS=y
CONFIG_ZIGBEE_ROLE_END_DEVICE=y

# Enable DK LED and Buttons library
CONFIG_DK_LIBRARY=y

# This example requires more workqueue stack
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

# Enable nRF ECB driver
CONFIG_CRYPTO=y
CONFIG_CRYPTO_NRF_ECB=y
CONFIG_CRYPTO_INIT_PRIORITY=80

# Cryptocell is not supported through CSPRNG driver API: NCSDK-4813
CONFIG_ENTROPY_CC3XX=n

# Enable API for powering down unused RAM parts
CONFIG_RAM_POWER_DOWN_LIBRARY=y

#Networking
CONFIG_NET_IPV6_MLD=n
CONFIG_NET_IPV6_NBR_CACHE=n
CONFIG_NET_IPV6_RA_RDNSS=n
CONFIG_NET_IP_ADDR_CHECK=n
CONFIG_NET_UDP=n

##############

CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_DRIVER=y
CONFIG_USB_DEVICE_PRODUCT=&amp;quot;Zephyr USB console sample&amp;quot;
CONFIG_USB_DEVICE_MANUFACTURER=&amp;quot;Nordic Semiconductor ASA&amp;quot;
CONFIG_USB_DEVICE_VID=0x1915
CONFIG_USB_DEVICE_PID=0x0100

CONFIG_UART_LINE_CTRL=y
CONFIG_USB_CDC_ACM_LOG_LEVEL_OFF=y

# Since the default LOG_MODE_MINIMAL is synchronous, it will mess with the USB
# driver/subsys. Use the deferred mode instead.
CONFIG_LOG_MODE_DEFERRED=y&lt;/pre&gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;and adding the following in main.c&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;sys/printk.h&amp;gt;
#include &amp;lt;usb/usb_device.h&amp;gt;
#include &amp;lt;drivers/uart.h&amp;gt;

BUILD_ASSERT(DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_console), zephyr_cdc_acm_uart),
	     &amp;quot;Console device is not ACM CDC UART device&amp;quot;);

void main(void)
{
	const struct device *dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
	uint32_t dtr = 0;

	if (usb_enable(NULL)) {
		return;
	}

	/* Poll if the DTR flag was set */
	while (!dtr) {
		uart_line_ctrl_get(dev, UART_LINE_CTRL_DTR, &amp;amp;dtr);
		/* Give CPU resources to low priority threads. */
		k_sleep(K_MSEC(100));
	}

	int console_init(void);
	printk(&amp;quot;hello world&amp;quot;);

//----------------------------
	LOG_INF(&amp;quot;Starting ZBOSS Light Switch example&amp;quot;);&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It can get both logging and printk as&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/288201.PNG" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Here is the project:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/light_5F00_switch_5F00_zigbee_5F00_log_5F00_NCSv1.9.7z"&gt;devzone.nordicsemi.com/.../light_5F00_switch_5F00_zigbee_5F00_log_5F00_NCSv1.9.7z&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;br /&gt;Amanda&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>