<?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>Setting the USB CDC-ACM Serial Number at Runtime</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/119588/setting-the-usb-cdc-acm-serial-number-at-runtime</link><description>If I have an application where I have implemented USB CDC-ACM, how can I set the serial number seen by the PC when I connect my device? Is it possible to set it at runtime?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 18 Mar 2025 10:59:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/119588/setting-the-usb-cdc-acm-serial-number-at-runtime" /><item><title>RE: Setting the USB CDC-ACM Serial Number at Runtime</title><link>https://devzone.nordicsemi.com/thread/527813?ContentTypeID=1</link><pubDate>Tue, 18 Mar 2025 10:59:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:84f8fb1b-ca44-490a-a872-51ee382fa3ac</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;If you download the latest nRF Connect SDK v2.9.1 and search for project that use&amp;nbsp;&lt;span&gt;CONFIG_USB_DEVICE_STACK_NEXT=y in it&amp;#39;s prj.conf that should be a good start.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Kenneth&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting the USB CDC-ACM Serial Number at Runtime</title><link>https://devzone.nordicsemi.com/thread/527788?ContentTypeID=1</link><pubDate>Tue, 18 Mar 2025 09:09:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d004337-babc-4d7b-ab86-483919233335</guid><dc:creator>Andrea Verdecchia</dc:creator><description>[quote userid="2111" url="~/f/nordic-q-a/119588/setting-the-usb-cdc-acm-serial-number-at-runtime/527213"]Sorry, if you look at the projects using &amp;quot;USB stack next&amp;quot; you can find they are using&amp;nbsp;CONFIG_USB_DEVICE_STACK_NEXT=y. So try that.[/quote]
&lt;p&gt;I keep getting compilation errors. Can you link me to the projects that use the &amp;quot;USB Next stack&amp;quot; you mentioned? I still don&amp;rsquo;t understand how to set my serial number using &lt;code data-start="210" data-end="242"&gt;USBD_DESC_SERIAL_NUMBER_DEFINE&lt;/code&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting the USB CDC-ACM Serial Number at Runtime</title><link>https://devzone.nordicsemi.com/thread/527213?ContentTypeID=1</link><pubDate>Thu, 13 Mar 2025 14:33:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5fdc4d44-03d1-4181-ab67-6d9e0117ea18</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Sorry, if you look at the projects using &amp;quot;USB stack next&amp;quot; you can find they are using&amp;nbsp;CONFIG_USB_DEVICE_STACK_NEXT=y. So try that.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting the USB CDC-ACM Serial Number at Runtime</title><link>https://devzone.nordicsemi.com/thread/527191?ContentTypeID=1</link><pubDate>Thu, 13 Mar 2025 13:48:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b8dc4ee3-fa0d-43fb-ab0c-3f4b208a3c47</guid><dc:creator>Andrea Verdecchia</dc:creator><description>&lt;p&gt;Sorry, but in the last few days, I haven&amp;#39;t had the chance to try your suggestion. I just tried integrating your code into mine, but I&amp;#39;m getting an error&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;error: &amp;#39;sample_sn&amp;#39; undeclared (first use in this function)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Additionally, I don&amp;#39;t understand how to set the serial number at runtime using &lt;code data-start="280" data-end="312"&gt;USBD_DESC_SERIAL_NUMBER_DEFINE&lt;/code&gt;, since the macro only defines the variable &lt;code data-start="356" data-end="367"&gt;sample_sn&lt;/code&gt;, and I don&amp;#39;t see where to insert the serial number string.&lt;/p&gt;
&lt;p&gt;I also tried setting the serial number using &lt;code data-start="475" data-end="497"&gt;CONFIG_USB_DEVICE_SN&lt;/code&gt;, but I didn&amp;#39;t get any results. It doesn&amp;#39;t even set the manufacturer or the product.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n
CONFIG_USB_DEVICE_MANUFACTURER=&amp;quot;Company&amp;quot;
CONFIG_USB_DEVICE_PRODUCT=&amp;quot;Product&amp;quot;
CONFIG_USB_DEVICE_SN=&amp;quot;S1234567890&amp;quot;
CONFIG_USB_DEVICE_PID=0x0002
CONFIG_USB_DEVICE_VID=0xAD5A&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Any suggestions?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting the USB CDC-ACM Serial Number at Runtime</title><link>https://devzone.nordicsemi.com/thread/526543?ContentTypeID=1</link><pubDate>Mon, 10 Mar 2025 12:34:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3828a3fb-82f1-424b-bafa-871858b14358</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I have not checked when it can be called in specific, I hope the examples or api documentation explain that.&lt;/p&gt;
&lt;p&gt;usbd_enable() is part of the newer USB device stack in Zephyr (sometimes referred to as &amp;quot;USB device next&amp;quot; or &amp;quot;USB stack next&amp;quot;). While usb_enable() is the legacy USB driver.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting the USB CDC-ACM Serial Number at Runtime</title><link>https://devzone.nordicsemi.com/thread/526526?ContentTypeID=1</link><pubDate>Mon, 10 Mar 2025 11:24:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d72eb8f-34fa-4200-81c1-2bd61582bf5b</guid><dc:creator>Andrea Verdecchia</dc:creator><description>&lt;p&gt;I imagine I need to call this function before enabling USB, or can I call it at any time?&lt;/p&gt;
&lt;p&gt;Also, I noticed that your example uses the USB device stack (&lt;code&gt;usbd*&lt;/code&gt;), while I am currently using &lt;code&gt;usb*&lt;/code&gt;. In fact, for enabling USB, I use &lt;code&gt;usb_enable&lt;/code&gt; instead of &lt;code&gt;usbd_enable&lt;/code&gt;. Does that make any difference?&lt;/p&gt;
&lt;p&gt;While we&amp;#39;re at it, what is the difference between using &lt;code&gt;usb_enable&lt;/code&gt; and &lt;code&gt;usbd_enable&lt;/code&gt;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting the USB CDC-ACM Serial Number at Runtime</title><link>https://devzone.nordicsemi.com/thread/526170?ContentTypeID=1</link><pubDate>Thu, 06 Mar 2025 12:53:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0cbb2613-d10d-4772-8986-b4e349349f6f</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;Normally the serial number is set on boot, e.g.:&amp;nbsp;&lt;br /&gt;&lt;br /&gt;USBD_DESC_SERIAL_NUMBER_DEFINE(sample_sn);&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; err = usbd_add_descriptor(&amp;amp;sample_usbd, &amp;amp;sample_sn);&lt;br /&gt;&amp;nbsp; &amp;nbsp; if (err) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LOG_ERR(&amp;quot;Failed to initialize SN descriptor (%d)&amp;quot;, err);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return NULL;&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;I guess it&amp;#39;s potentially possible to manipulate it if you want to.&lt;br /&gt;&lt;br /&gt;Kenneth&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>