<?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>Using USB as virtual com as log with zephyr</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/113207/using-usb-as-virtual-com-as-log-with-zephyr</link><description>Hi to all, 
 I&amp;#39;m developing a beacon application on the nRF52840-DK starting from the example that I found in the VS Code (Zephyr). 
 I&amp;#39;m designing a custom board with only the nRF onboard (without the interface MCU). 
 If I insert a USB cable in the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 29 Jul 2024 07:47:31 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/113207/using-usb-as-virtual-com-as-log-with-zephyr" /><item><title>RE: Using USB as virtual com as log with zephyr</title><link>https://devzone.nordicsemi.com/thread/495940?ContentTypeID=1</link><pubDate>Mon, 29 Jul 2024 07:47:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b337a451-acbe-4157-82b6-91229ae83219</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;When testing the CDC ACM USB sample, I saw that the log is printed on the UART port, but only if the USB is connected. I suspect this is not what you want to achieve, so I made a sample that only uses nRF USB, which I have attached here. It is the Hello World sample from Zephyr, and I only added support for CDC ACM USB, so it is very simple and should be straightforward to incorporate into other projects.&lt;/p&gt;
&lt;p&gt;This is what the prj.conf looks like:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_REMOTE_WAKEUP=n
CONFIG_USB_DEVICE_PRODUCT=&amp;quot;My USB device&amp;quot;
CONFIG_USB_CDC_ACM=y
CONFIG_UART_LINE_CTRL=y
CONFIG_USB_DEVICE_PID=0x0001
CONFIG_USB_CDC_ACM_LOG_LEVEL_OFF=y

CONFIG_LOG=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And the devicetree overlay:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/ {
	chosen {
		zephyr,console = &amp;amp;cdc_acm_uart0;
	};
};

&amp;amp;zephyr_udc0 {
	cdc_acm_uart0: cdc_acm_uart0 {
		compatible = &amp;quot;zephyr,cdc-acm-uart&amp;quot;;
	};
};
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In main,c you need to include the usb_device.h file and enable USB with usb_enable():&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;zephyr/kernel.h&amp;gt;
#include &amp;lt;zephyr/usb/usb_device.h&amp;gt;
#include &amp;lt;zephyr/logging/log.h&amp;gt;

LOG_MODULE_REGISTER(app);

int main(void)
{
	usb_enable(NULL);
	printf(&amp;quot;Hello World! %s\n&amp;quot;, CONFIG_BOARD);
	while(true){
		LOG_INF(&amp;quot;Hello World\n&amp;quot;);
		/* Wait 100ms for the host to do all settings */
		k_msleep(100);
	}
	return 0;
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/hello_5F00_world_5F00_usb.zip"&gt;devzone.nordicsemi.com/.../hello_5F00_world_5F00_usb.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Please let me know if this makes it so you can get logs from the USB/COM13 or not &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using USB as virtual com as log with zephyr</title><link>https://devzone.nordicsemi.com/thread/495734?ContentTypeID=1</link><pubDate>Fri, 26 Jul 2024 06:39:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ddd571c-c6d7-47fa-b93f-1a586a38f5e3</guid><dc:creator>Serafino Convertini</dc:creator><description>&lt;p&gt;Hi Marte,&lt;/p&gt;
&lt;p&gt;I cannot see anything from COM13. This is the problem &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using USB as virtual com as log with zephyr</title><link>https://devzone.nordicsemi.com/thread/495634?ContentTypeID=1</link><pubDate>Thu, 25 Jul 2024 12:41:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ddbe9709-6c07-4bf7-b83a-ddb194899aa8</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Are you able to get logs from COM13?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using USB as virtual com as log with zephyr</title><link>https://devzone.nordicsemi.com/thread/495029?ContentTypeID=1</link><pubDate>Mon, 22 Jul 2024 13:10:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2ac9e18-1d87-4b91-a9ea-c10fcd69cf2f</guid><dc:creator>Serafino Convertini</dc:creator><description>&lt;p&gt;I see this&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Screenshot-2024_2D00_07_2D00_22-150822.png" /&gt;&lt;/p&gt;
&lt;p&gt;COM6 and COM7 is depending on IMCU while COM13 is provided by nRF configured USB-CDC example&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using USB as virtual com as log with zephyr</title><link>https://devzone.nordicsemi.com/thread/495025?ContentTypeID=1</link><pubDate>Mon, 22 Jul 2024 13:04:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:27fc2382-5c28-40dc-97c4-88b29c159005</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;If you go to device manger, do you see the device listed under Ports like this:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1721653420787v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using USB as virtual com as log with zephyr</title><link>https://devzone.nordicsemi.com/thread/494807?ContentTypeID=1</link><pubDate>Fri, 19 Jul 2024 12:34:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55e1c319-6ab0-49fa-89d7-0be320023a57</guid><dc:creator>Serafino Convertini</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I tried to build the example &amp;quot;zephyr\samples\subsys\usb\cdc_acm&amp;quot;, and I inserted at the end of the code (before return 0) this snippet&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;while(true){
	LOG_INF(&amp;quot;Hello World\n&amp;quot;);
	/* Wait 100ms for the host to do all settings */
	k_msleep(100);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But nothing happens. If I open a serial terminal with a baudrate of 115200, nothing is printed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using USB as virtual com as log with zephyr</title><link>https://devzone.nordicsemi.com/thread/494792?ContentTypeID=1</link><pubDate>Fri, 19 Jul 2024 12:02:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b19eac8-8cda-4bf4-8051-50d7f2acff16</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You can use the USB CDC-&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/samples/subsys/usb/cdc_acm/README.html"&gt;Sample&lt;/a&gt; as reference,&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>