<?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>Dynamically enable and disable cdc_acm_uart* devices (instances) on USB connection</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/108138/dynamically-enable-and-disable-cdc_acm_uart-devices-instances-on-usb-connection</link><description>Hello, 
 I have two virtual COM ports configured via the USB interface of my nRF5340 SoC: 
 
 Is it possible to enable and disable each instance individually during runtime? 
 Some simple examples would be: 
 (1) User presses button A --&amp;gt; cdc_acm_uart0</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 23 Feb 2024 14:59:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/108138/dynamically-enable-and-disable-cdc_acm_uart-devices-instances-on-usb-connection" /><item><title>RE: Dynamically enable and disable cdc_acm_uart* devices (instances) on USB connection</title><link>https://devzone.nordicsemi.com/thread/470498?ContentTypeID=1</link><pubDate>Fri, 23 Feb 2024 14:59:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc221f51-8c2b-437d-8605-475e335a67d1</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="puz_md"]By the way, is there a feature where I can upload confidential code? Or can it be seen by everybody?[/quote]
&lt;p&gt;I can convert the ticket to private, then the information is only visible to you, Nordic, and selected distributor.&lt;/p&gt;
[quote user="puz_md"]Concerning the &amp;quot;USB_DEVICE_STACK_NEXT&amp;quot;, can you tell me in which development state it is? Is it stable? Would you advise switching over to the new stack completely for an industrial product?[/quote]
&lt;p&gt;The new stack is experimental and should not be used in a production firmware at this point. You can use it to explore new features, but it should not be used in production until it is taken out of experimental state.&lt;/p&gt;
[quote user="puz_md"]If I understand correctly, with the STACK_NEXT, everything USB-related must be configured in my own code, so no use of prj.conf directives and auto-configuration in the background seems to be possible. Can I access the old configuration values from prj.conf, like device ID or seller name, from my code for the STACK_NEXT? Do you suggest keeping USB related configuration and values in prj.conf, or place it somewhere differently in the code?[/quote]
&lt;p&gt;This will likely change if/when the new stack is in production state and replace the old stack.&lt;/p&gt;
[quote user="puz_md"]I think I&amp;#39;ve seen a USB configuration structure in one of the samples using NEXT_STACK, probably it is related to this one. I have to check again, as I didn&amp;#39;t see at first glimpse any configuration number being handled in the code at configuration registration time.[/quote]
&lt;p&gt;All examples I have seen in nRF Connect SDK/Zephyr use 1 for this parameter.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamically enable and disable cdc_acm_uart* devices (instances) on USB connection</title><link>https://devzone.nordicsemi.com/thread/470098?ContentTypeID=1</link><pubDate>Wed, 21 Feb 2024 18:29:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51ac9522-5275-4aca-96b2-51247d210b12</guid><dc:creator>puz_md</dc:creator><description>&lt;p&gt;Hi &lt;span&gt;J&amp;oslash;rgen&lt;/span&gt;,&lt;/p&gt;
&lt;p&gt;thanks a lot for your reply.&lt;/p&gt;
[quote userid="14926" url="~/f/nordic-q-a/108138/dynamically-enable-and-disable-cdc_acm_uart-devices-instances-on-usb-connection/469853"]Can you share your project used for testing this?[/quote]
&lt;p&gt;This might be a bit tricky at the moment, I cannot send the whole project because of confidentiality. I have considered reducing my project to the basic framework that shows the problem, but I am very busy with deadlines the coming days... maybe I can find some time in two weeks or so. By the way, is there a feature where I can upload confidential code? Or can it be seen by everybody?&lt;/p&gt;
&lt;p&gt;Concerning the &amp;quot;USB_DEVICE_STACK_NEXT&amp;quot;, can you tell me in which development state it is? Is it stable? Would you advise switching over to the new stack completely for an industrial product?&lt;/p&gt;
&lt;p&gt;If I understand correctly, with the STACK_NEXT, everything USB-related must be configured in my own code, so no use of prj.conf directives and auto-configuration in the background seems to be possible. Can I access the old configuration values from prj.conf, like device ID or seller name, from my code for the STACK_NEXT? Do you suggest keeping USB related configuration and values in prj.conf, or place it somewhere differently in the code?&lt;/p&gt;
[quote userid="14926" url="~/f/nordic-q-a/108138/dynamically-enable-and-disable-cdc_acm_uart-devices-instances-on-usb-connection/469853"]bConfigurationValue is described in the USB specifications. This corresponds to the number of the configuration you want to use.[/quote]
&lt;p&gt;I think I&amp;#39;ve seen a USB configuration structure in one of the samples using NEXT_STACK, probably it is related to this one. I have to check again, as I didn&amp;#39;t see at first glimpse any configuration number being handled in the code at configuration registration time.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Michael&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamically enable and disable cdc_acm_uart* devices (instances) on USB connection</title><link>https://devzone.nordicsemi.com/thread/469853?ContentTypeID=1</link><pubDate>Tue, 20 Feb 2024 15:12:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fee27ecd-4a08-4714-8afa-131e9628ef7e</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Michael,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Can you share your project used for testing this?&lt;/span&gt;&lt;/p&gt;
[quote user="puz_md"]&lt;span&gt;I have some trouble getting the USB contect for the reister/unregister functions, as the sample code seems to require the &lt;span style="font-family:courier new, courier;"&gt;CONFIG_USB_DEVICE_STACK_NEXT=y&lt;/span&gt; option. If I add this option, I get a compile error:&amp;nbsp;&lt;/span&gt;&lt;span style="font-family:courier new, courier;"&gt;gen_isr_tables.py: error: multiple registrations at table_index 55 for irq 55 (0x37)&lt;/span&gt;.[/quote]
&lt;p&gt;Sounds like&amp;nbsp;both the&amp;nbsp;old and the new USB stack is being included in the project.&lt;/p&gt;
[quote user="puz_md"]If I don&amp;#39;t use STACK_NEXT, but try to use the macro&lt;span style="font-family:courier new, courier;"&gt; USBD_DEVICE_DEFINE()&lt;/span&gt; like in the example code, I get the following compile error: &lt;span style="font-family:courier new, courier;"&gt;[...]ld.bfd.exe: app/libapp.a(main.c.obj):(._usbd_contex.static.my_usbd_+0x18): undefined reference to `__device_dts_ord_115&amp;#39;&lt;/span&gt;[/quote]
&lt;p&gt;This macro is not available in the old stack API.&lt;/p&gt;
[quote user="puz_md"]Is there a way to access/retrieve the &amp;quot;USB device support runtime context&amp;quot; (first parameter of the &lt;span style="font-family:courier new, courier;"&gt;usbd_[un]register_class()&lt;/span&gt; function) when it is defined by the normal system stack?[/quote]
&lt;p&gt;I do not think there is any API to get this, would likely require changing the library sources.&lt;/p&gt;
[quote user="puz_md"]And what is the cfg parameter of the &lt;span style="font-family:courier new, courier;"&gt;usbd_[un]register_class()&lt;/span&gt; functions used for? I don&amp;#39;t understand what the &amp;quot;(similar to bConfigurationValue)&amp;quot; description means, either... is it a boolean value? What does it affect?[/quote]
&lt;p&gt;bConfigurationValue is described in the USB specifications. This corresponds to the number of the configuration you want to use.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;Best regards,&lt;br /&gt;Jørgen&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamically enable and disable cdc_acm_uart* devices (instances) on USB connection</title><link>https://devzone.nordicsemi.com/thread/468685?ContentTypeID=1</link><pubDate>Tue, 13 Feb 2024 15:39:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aab92e9c-7d96-463c-bc9f-8a0432e86cb4</guid><dc:creator>puz_md</dc:creator><description>&lt;p&gt;Hi &lt;span&gt;J&amp;oslash;rgen,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have some trouble getting the USB contect for the reister/unregister functions, as the sample code seems to require the &lt;span style="font-family:courier new, courier;"&gt;CONFIG_USB_DEVICE_STACK_NEXT=y&lt;/span&gt; option. If I add this option, I get a compile error:&amp;nbsp;&lt;/span&gt;&lt;span style="font-family:courier new, courier;"&gt;gen_isr_tables.py: error: multiple registrations at table_index 55 for irq 55 (0x37)&lt;/span&gt;. I&amp;#39;m currently using the &lt;span style="font-family:courier new, courier;"&gt;#CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=y&lt;/span&gt; option, but even if I disable it, I still get the irq related link error with STACK_NEXT.&lt;/p&gt;
&lt;p&gt;If I don&amp;#39;t use STACK_NEXT, but try to use the macro&lt;span style="font-family:courier new, courier;"&gt; USBD_DEVICE_DEFINE()&lt;/span&gt; like in the example code, I get the following compile error: &lt;span style="font-family:courier new, courier;"&gt;[...]ld.bfd.exe: app/libapp.a(main.c.obj):(._usbd_contex.static.my_usbd_+0x18): undefined reference to `__device_dts_ord_115&amp;#39;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Is there a way to access/retrieve the &amp;quot;USB device support runtime context&amp;quot; (first parameter of the &lt;span style="font-family:courier new, courier;"&gt;usbd_[un]register_class()&lt;/span&gt; function) when it is defined by the normal system stack?&lt;/p&gt;
&lt;p&gt;And what is the cfg parameter of the &lt;span style="font-family:courier new, courier;"&gt;usbd_[un]register_class()&lt;/span&gt; functions used for? I don&amp;#39;t understand what the &amp;quot;(similar to bConfigurationValue)&amp;quot; description means, either... is it a boolean value? What does it affect?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Michael&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamically enable and disable cdc_acm_uart* devices (instances) on USB connection</title><link>https://devzone.nordicsemi.com/thread/468109?ContentTypeID=1</link><pubDate>Thu, 08 Feb 2024 15:16:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6be9ae7b-52eb-4f89-a062-006e0ba0abd5</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You might use the&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.5.1/zephyr/connectivity/usb/device_next/api/usbd.html#c.usbd_register_class"&gt;usbd_register_class&lt;/a&gt;&lt;span&gt;() and &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.5.1/zephyr/connectivity/usb/device_next/api/usbd.html#c.usbd_unregister_class"&gt;usbd_unregister_class&lt;/a&gt;&lt;/span&gt;&lt;span&gt;() APIs to achieve this, but these APIs can only be used when the USB device stack is disabled.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;See the &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.4.99-ncs1-1/samples/subsys/usb/cdc_acm/src/main.c#L80-L84"&gt;USB CDC ACM sample&lt;/a&gt; on how the usbd_register_class API is used to register the cdc_acm instance.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;br /&gt;Jørgen&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>