<?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>Zephyr and NRFX USB support</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/114617/zephyr-and-nrfx-usb-support</link><description>Hello, 
 I&amp;#39;m using Zephyr 2.6.1 and nRF5340. 
 Tried to include in my project the NRFX driver for USB and I&amp;#39;m currently not able to find an enabling option for that. 
 In the prj.conf seems that is not recognized (available) any entry for that (i.e. following</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 17 Sep 2024 14:43:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/114617/zephyr-and-nrfx-usb-support" /><item><title>RE: Zephyr and NRFX USB support</title><link>https://devzone.nordicsemi.com/thread/502798?ContentTypeID=1</link><pubDate>Tue, 17 Sep 2024 14:43:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f4b8e82-6bd2-4c1e-9ced-562b9b303eef</guid><dc:creator>GioNor</dc:creator><description>&lt;p&gt;I tried using the Zephyr implementation and it works fine but this is not my goal since the Zephyr USB implementation is not compatible with Zephyr UART Asynch (&lt;span&gt;API with DMA)&lt;/span&gt; that I&amp;#39;m currently using.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr and NRFX USB support</title><link>https://devzone.nordicsemi.com/thread/502539?ContentTypeID=1</link><pubDate>Sun, 15 Sep 2024 07:49:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ba297f0-a7c9-40f9-9672-6ad6cf1b7397</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;That USB code looks like it was ripped from the old NRF SDK and should not be needed for any NRF connect stuff.&lt;/p&gt;
&lt;p&gt;Zephyr (which NRF connect is based upon)&amp;nbsp; ships with an USB CDC implementation already, try using this. There are samples that show you how to.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr and NRFX USB support</title><link>https://devzone.nordicsemi.com/thread/502515?ContentTypeID=1</link><pubDate>Fri, 13 Sep 2024 16:08:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:83b4fe6b-e60a-45a3-920b-bc682c900060</guid><dc:creator>GioNor</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Can&amp;#39;t upload a .zip file, so here are the instruction to setup your project in 1minute:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;1. Create anew application from sample&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/pastedimage1726243474736v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;2. this is the main.c content, replace the one created in the example&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*
 * Copyright (c) 2020 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
 */

#include &amp;lt;zephyr/kernel.h&amp;gt;
#include &amp;lt;zephyr/drivers/gpio.h&amp;gt;
#include &amp;lt;zephyr/init.h&amp;gt;
#include &amp;lt;nrf.h&amp;gt;
#include &amp;lt;nrfx.h&amp;gt;


/*START************************************************** */
/******************************************************** */

#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;stddef.h&amp;gt;
#include &amp;lt;nrfx_usbd.h&amp;gt;
#include &amp;lt;zephyr/logging/log.h&amp;gt;
LOG_MODULE_REGISTER(USB);



typedef enum {
    USB_SUCCESS = 0,
    USB_ERROR_INIT_FAILED,
    USB_ERROR_WRITE_FAILED,
    USB_ERROR_READ_FAILED
} USB_Error_t;

typedef void (*usb_event_handler_t)(nrfx_usbd_evt_t const * p_event);

void USB_Init(usb_event_handler_t event_handler);
void USB_Transfer(uint8_t ep, const void *p_data, size_t size);


#define USB_EP_IN   0x81  // Endpoint IN (da dispositivo a host)
#define USB_EP_OUT  0x01  // Endpoint OUT (da host a dispositivo)
#define DATA_SIZE   64    // Dimensione dei dati da trasferire

static uint8_t tx_data[DATA_SIZE] = &amp;quot;Hello from nRF5340!&amp;quot;;
static uint8_t rx_data[DATA_SIZE];

void usb_event_handler2(nrfx_usbd_evt_t const * p_event) {
	if (p_event-&amp;gt;type == NRFX_USBD_EVT_EPTRANSFER) {
		LOG_INF(&amp;quot;Data transfer on endpoint %d completed&amp;quot;, p_event-&amp;gt;data.eptransfer.ep);
	}
}




int main(void)
{
    LOG_INF(&amp;quot;USB CDC example started&amp;quot;);

    USB_Init(usb_event_handler2);

    USB_Transfer(USB_EP_IN, tx_data, sizeof(tx_data));
}



void USB_Init(usb_event_handler_t event_handler) {
    nrfx_err_t res = nrfx_usbd_init(event_handler);
    if (res != NRFX_SUCCESS) {
        LOG_ERR(&amp;quot;Failed to initialize USB: %d&amp;quot;, res);
    }

    nrfx_usbd_enable();
    nrfx_usbd_start(1);
}

void USB_Transfer(uint8_t ep, const void *p_data, size_t size) {
    nrfx_usbd_transfer_t transfer = {
        .p_data = p_data,
        .size = size
    };
    nrfx_err_t res = nrfx_usbd_ep_transfer(ep, &amp;amp;transfer);
    if (res != NRFX_SUCCESS) {
        LOG_ERR(&amp;quot;USB transfer failed: %d&amp;quot;, res);
    }
}









/** @brief Allow access to specific GPIOs for the network core.
 *
 * Function is executed very early during system initialization to make sure
 * that the network core is not started yet. More pins can be added if the
 * network core needs them.
 */
static int network_gpio_allow(void)
{

	/* When the use of the low frequency crystal oscillator (LFXO) is
	 * enabled, do not modify the configuration of the pins P0.00 (XL1)
	 * and P0.01 (XL2), as they need to stay configured with the value
	 * Peripheral.
	 */
	uint32_t start_pin = (IS_ENABLED(CONFIG_SOC_ENABLE_LFXO) ? 2 : 0);

	/* Allow the network core to use all GPIOs. */
	for (uint32_t i = start_pin; i &amp;lt; P0_PIN_NUM; i++) {
		NRF_P0_S-&amp;gt;PIN_CNF[i] = (GPIO_PIN_CNF_MCUSEL_NetworkMCU &amp;lt;&amp;lt;
					GPIO_PIN_CNF_MCUSEL_Pos);
	}

	for (uint32_t i = 0; i &amp;lt; P1_PIN_NUM; i++) {
		NRF_P1_S-&amp;gt;PIN_CNF[i] = (GPIO_PIN_CNF_MCUSEL_NetworkMCU &amp;lt;&amp;lt;
					GPIO_PIN_CNF_MCUSEL_Pos);
	}


	return 0;
}

SYS_INIT(network_gpio_allow, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_OBJECTS);
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;3. This is the prj.conf, replace the one created by the example&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#
# Copyright (c) 2020 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
CONFIG_MULTITHREADING=y
CONFIG_KERNEL_MEM_POOL=y
CONFIG_NUM_PREEMPT_PRIORITIES=0
CONFIG_SYS_CLOCK_EXISTS=y
CONFIG_ARM_MPU=y
CONFIG_SIZE_OPTIMIZATIONS=y
CONFIG_I2C=n
CONFIG_WATCHDOG=n
CONFIG_GPIO=n
CONFIG_SPI=n
CONFIG_SERIAL=n
CONFIG_FLASH=n
CONFIG_DYNAMIC_INTERRUPTS=n
CONFIG_IRQ_OFFLOAD=n
CONFIG_THREAD_STACK_INFO=n
CONFIG_THREAD_CUSTOM_DATA=n
CONFIG_BOOT_BANNER=n
CONFIG_BOOT_DELAY=0
CONFIG_CONSOLE=n
CONFIG_UART_CONSOLE=n
CONFIG_STDOUT_CONSOLE=n
CONFIG_PRINTK=n
CONFIG_EARLY_CONSOLE=n
CONFIG_BOARD_ENABLE_CPUNET=y



#enable the NRFX USB
CONFIG_USB_DEVICE_DRIVER=y
CONFIG_USB_NRFX=y
#CONFIG_USB_DEVICE_STACK=y
#CONFIG_USB_CDC_ACM=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;4. create a build configuration&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:74px;max-width:408px;" height="74" src="https://devzone.nordicsemi.com/resized-image/__size/816x148/__key/communityserver-discussions-components-files/4/pastedimage1726243671417v2.png" width="408" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;then build and get the linker error&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr and NRFX USB support</title><link>https://devzone.nordicsemi.com/thread/502393?ContentTypeID=1</link><pubDate>Thu, 12 Sep 2024 21:34:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f75d5940-162f-4e43-bded-9cfb7585e606</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;You need to pick one. So if you want to use the nrfx driver, remove &amp;quot;CONFIG_USB_DEVICE_STACK=y&amp;quot; and &amp;quot;CONFIG_USB_CDC_ACM=y&amp;quot;.&lt;/p&gt;
&lt;p&gt;Can you please share the entire build log? And perhaps also the application that you are trying to build. Perhaps I can have a look at it.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr and NRFX USB support</title><link>https://devzone.nordicsemi.com/thread/501942?ContentTypeID=1</link><pubDate>Tue, 10 Sep 2024 12:58:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8932e585-0bc8-4885-b4df-2df9d200a2d7</guid><dc:creator>GioNor</dc:creator><description>&lt;p&gt;Hello Edvin,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m writing my own application using NRFX drivers directly.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Anyway I tried the Zephyr USB implementation (included example) to exclude any other issue and I got VCOM working, but this is not my goal.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The errors I get are from the linker:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;undefined reference to `nrfx_usbd_init&amp;#39;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;undefined reference to `nrfx_usbdr_enable&amp;#39;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;undefined reference to `nrfx_usbd_ep_transfer&amp;#39;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;and so on.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;To me, seems that the USB file from nrfx is not compiled at all; this is what I put in the prj.conf:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_USB_NRFX&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_USB_DEVICE_STACK&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_USB_CDC_ACM&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;thank you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr and NRFX USB support</title><link>https://devzone.nordicsemi.com/thread/501933?ContentTypeID=1</link><pubDate>Tue, 10 Sep 2024 12:33:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:43f0e657-8d50-4198-9c78-f5698b2fb7c9</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;You mention that the nrfx_usbd.c is not enabled causing errors. Can you please specify what errors? Is it just the highlighting of the text that is off, or do you get any build errors?&lt;/p&gt;
&lt;p&gt;And are you trying to use one of the samples? Or did you write your own application?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;And finally, are you intending to use the zephyr USB drivers, or nrfx drivers directly?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr and NRFX USB support</title><link>https://devzone.nordicsemi.com/thread/501869?ContentTypeID=1</link><pubDate>Tue, 10 Sep 2024 09:31:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b8d82934-e3d4-4590-886b-b879a17219f9</guid><dc:creator>GioNor</dc:creator><description>&lt;p&gt;Nothing to do, nrfx is disabled at all&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr and NRFX USB support</title><link>https://devzone.nordicsemi.com/thread/501868?ContentTypeID=1</link><pubDate>Tue, 10 Sep 2024 09:28:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:abd15a54-8692-4563-bafc-bb4a1741605f</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;My bad, weak c&amp;amp;p job.&lt;/p&gt;
&lt;p&gt;It was supposed to read &lt;code&gt;CONFIG_USB_DEVICE_STACK=y&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr and NRFX USB support</title><link>https://devzone.nordicsemi.com/thread/501865?ContentTypeID=1</link><pubDate>Tue, 10 Sep 2024 09:22:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1e6fd203-23bb-4765-8d42-8e22e2f89a51</guid><dc:creator>GioNor</dc:creator><description>&lt;p&gt;Thank you, tried and this is the result:&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/pastedimage1725960087331v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr and NRFX USB support</title><link>https://devzone.nordicsemi.com/thread/501863?ContentTypeID=1</link><pubDate>Tue, 10 Sep 2024 09:19:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c67ca453-9ed5-4d2e-84c0-d48e25b321be</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;Try just &lt;code&gt;CONFIG_USB=y &lt;/code&gt;in your prj.conf file.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>