FRDM-RW612 USB_DEVICE_STACK_NEXT support

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FRDM-RW612 USB_DEVICE_STACK_NEXT support

Jump to solution
6,214 Views
wima88
Contributor III

Hi , 

I'm using zephyr 4.0.0 an tried to run some samples with USB device stack next an encounter following error 

 <err> usbd_core: Failed to init device driver

however I ran some samples with old usb device stack. 

I would like to know if this is the expected behavior as of this zephyr version or am I missing something   

Tags (2)
0 Kudos
Reply
1 Solution
6,071 Views
DanielRuvalcaba
NXP TechSupport
NXP TechSupport

Hi,

 

I found the following issue in the Github repo NXP USB drivers don't work with usb_next · Issue #86409 · zephyrproject-rtos/zephyr. Looks like this has already been reported.

Could you please confirm is the same issue?

 

Regards,

Daniel

View solution in original post

0 Kudos
Reply
6 Replies
6,061 Views
wima88
Contributor III

Thanks Daniel, I follow the issue. I was about to create a issue on git 

Wimansha 

0 Kudos
Reply
6,180 Views
wima88
Contributor III

Hi Daniel ,

Thank you for getting back to me . 

I tried the following 

1.  use the hid-mouse example as it is with usbd_next_proj.conf  

2. use with loopback class

      1.  proj.conf 

CONFIG_LOG=y
 
CONFIG_USB_DEVICE_STACK_NEXT=y
CONFIG_USBD_LOOPBACK_CLASS=y
 
2.  main.c
 
#include "sample_usbd.h" 
/*located on zephyrproject/zephyr/samples/subsys/usb/common*/

#include <zephyr/kernel.h>
#include <zephyr/usb/usbd.h>

#include <zephyr/logging/log.h>

LOG_MODULE_REGISTER(app, LOG_LEVEL_DBG);

static void msg_cb(struct usbd_context *const usbd_ctx,
                   const struct usbd_msg *const msg) {
  LOG_INF("USBD message: %s", usbd_msg_type_string(msg->type));

  if (usbd_can_detect_vbus(usbd_ctx)) {
    if (msg->type == USBD_MSG_VBUS_READY) {
      if (usbd_enable(usbd_ctx)) {
        LOG_ERR("Failed to enable device support");
      }
    }

    if (msg->type == USBD_MSG_VBUS_REMOVED) {
      if (usbd_disable(usbd_ctx)) {
        LOG_ERR("Failed to disable device support");
      }
    }
  }
}
int main(void) {
  struct usbd_context *sample_usbd;
  int ret;

  sample_usbd = sample_usbd_init_device(msg_cb);
  if (sample_usbd == NULL) {
    k_msleep(100);
    return 0;
  }

  if (!usbd_can_detect_vbus(sample_usbd)) {
    ret = usbd_enable(sample_usbd);
    {
      if (ret) {
        LOG_ERR("Failed to enable usb support !");
        return ret;
      }
    }
  }
  return 0;
}

 in both cases I got   <err> usbd_core: Failed to init device driver . to be little more specific -12(-ENOMEM) 

after tracing the issue back I pin point the error to udc_mcux_init(...) function located in drivers/usb/udc/udc_mcux_ehci.c

to narrow it further

        /* Init MCUX USB device driver. */
        status = mcux_if->deviceInit(priv->controller_id,
                &priv->mcux_device, &(priv->mcux_device.controllerHandle));
        if (status != kStatus_USB_Success) {
                return -ENOMEM;
        }

 

 

 

0 Kudos
Reply
6,112 Views
DanielRuvalcaba
NXP TechSupport
NXP TechSupport

Hi,

 

If you use the HID mouse example as is, does it work?

Could you please try using Zephyr 4.1.0?

Is this custom code? If not, could you please point me where did you get it?

 

Regards,

Daniel.

0 Kudos
Reply
6,084 Views
wima88
Contributor III

Hi Daniel,

I tried it with zephyr 4.1.0, 

still seen the same error code, according to 4.1.0 migration guide   not much been change in zephyr USB side 

If I use HID-mouse as it is USB stack is initializing properly and I can see device enumeration on host. 

Wimansha

 

0 Kudos
Reply
6,072 Views
DanielRuvalcaba
NXP TechSupport
NXP TechSupport

Hi,

 

I found the following issue in the Github repo NXP USB drivers don't work with usb_next · Issue #86409 · zephyrproject-rtos/zephyr. Looks like this has already been reported.

Could you please confirm is the same issue?

 

Regards,

Daniel

0 Kudos
Reply
6,191 Views
DanielRuvalcaba
NXP TechSupport
NXP TechSupport

Hi,

What example are you testing?

Could you please share some reproduction steps?

Regards,

Daniel.

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2064972%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EFRDM-RW612%20USB_DEVICE_STACK_NEXT%20support%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2064972%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20%2C%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20using%20zephyr%204.0.0%20an%20tried%20to%20run%20some%20samples%20with%20USB%20device%20stack%20next%20an%20encounter%20following%20error%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E%26nbsp%3B%3CERR%3E%20usbd_core%3A%20Failed%20to%20init%20device%20driver%3C%2FERR%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3Ehowever%20I%20ran%20some%20samples%20with%20old%20usb%20device%20stack.%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20like%20to%20know%20if%20this%20is%20the%20expected%20behavior%20as%20of%20this%20zephyr%20version%20or%20am%20I%20missing%20something%26nbsp%3B%20%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2069034%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20FRDM-RW612%20USB_DEVICE_STACK_NEXT%20support%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2069034%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThanks%20Daniel%2C%20I%20follow%20the%20issue.%20I%20was%20about%20to%20create%20a%20issue%20on%20git%26nbsp%3B%3C%2FP%3E%3CP%3EWimansha%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2068896%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20FRDM-RW612%20USB_DEVICE_STACK_NEXT%20support%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2068896%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EI%20found%20the%20following%20issue%20in%20the%20Github%20repo%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fzephyrproject-rtos%2Fzephyr%2Fissues%2F86409%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3ENXP%20USB%20drivers%20don't%20work%20with%20usb_next%20%C2%B7%20Issue%20%2386409%20%C2%B7%20zephyrproject-rtos%2Fzephyr%3C%2FA%3E.%20Looks%20like%20this%20has%20already%20been%20reported.%3C%2FP%3E%0A%3CP%3ECould%20you%20please%20confirm%20is%20the%20same%20issue%3F%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3EDaniel%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2068791%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20FRDM-RW612%20USB_DEVICE_STACK_NEXT%20support%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2068791%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Daniel%2C%3C%2FP%3E%3CP%3EI%20tried%20it%20with%20zephyr%204.1.0%2C%26nbsp%3B%3C%2FP%3E%3CP%3Estill%20seen%20the%20same%20error%20code%2C%20according%20to%20%3CA%20href%3D%22https%3A%2F%2Fdocs.zephyrproject.org%2Flatest%2Freleases%2Fmigration-guide-4.1.html%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E4.1.0%20migration%20guide%26nbsp%3B%3C%2FA%3E%26nbsp%3B%20not%20much%20been%20change%20in%20zephyr%20USB%20side%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20I%20use%20HID-mouse%20as%20it%20is%20USB%20stack%20is%20initializing%20properly%20and%20I%20can%20see%20device%20enumeration%20on%20host.%26nbsp%3B%3C%2FP%3E%3CP%3EWimansha%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2067551%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20FRDM-RW612%20USB_DEVICE_STACK_NEXT%20support%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2067551%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EIf%20you%20use%20the%20HID%20mouse%20example%20as%20is%2C%20does%20it%20work%3F%3C%2FP%3E%0A%3CP%3ECould%20you%20please%20try%20using%20Zephyr%204.1.0%3F%3C%2FP%3E%0A%3CP%3EIs%20this%20custom%20code%3F%20If%20not%2C%20could%20you%20please%20point%20me%20where%20did%20you%20get%20it%3F%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3EDaniel.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2065796%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20FRDM-RW612%20USB_DEVICE_STACK_NEXT%20support%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2065796%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Daniel%20%2C%3C%2FP%3E%3CP%3EThank%20you%20for%20getting%20back%20to%20me%20.%26nbsp%3B%3C%2FP%3E%3CP%3EI%20tried%20the%20following%26nbsp%3B%3C%2FP%3E%3CP%3E1.%26nbsp%3B%20use%20the%20hid-mouse%20example%20as%20it%20is%20with%20usbd_next_proj.conf%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E2.%20use%20with%20loopback%20class%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%201.%26nbsp%3B%20proj.conf%26nbsp%3B%3C%2FP%3E%3CDIV%20class%3D%22lia-indent-padding-left-60px%22%20style%3D%22padding-left%20%3A%2060px%3B%22%20style%3D%22padding-left%20%3A%2060px%3B%22%3ECONFIG_LOG%3Dy%3C%2FDIV%3E%3CDIV%20class%3D%22lia-indent-padding-left-60px%22%20style%3D%22padding-left%20%3A%2060px%3B%22%20style%3D%22padding-left%20%3A%2060px%3B%22%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%20class%3D%22lia-indent-padding-left-60px%22%20style%3D%22padding-left%20%3A%2060px%3B%22%20style%3D%22padding-left%20%3A%2060px%3B%22%3ECONFIG_USB_DEVICE_STACK_NEXT%3Dy%3C%2FDIV%3E%3CDIV%20class%3D%22lia-indent-padding-left-60px%22%20style%3D%22padding-left%20%3A%2060px%3B%22%20style%3D%22padding-left%20%3A%2060px%3B%22%3ECONFIG_USBD_LOOPBACK_CLASS%3Dy%3C%2FDIV%3E%3CDIV%20class%3D%22lia-indent-padding-left-60px%22%20style%3D%22padding-left%20%3A%2060px%3B%22%20style%3D%22padding-left%20%3A%2060px%3B%22%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%20class%3D%22lia-indent-padding-left-30px%22%20style%3D%22padding-left%20%3A%2030px%3B%22%20style%3D%22padding-left%20%3A%2030px%3B%22%3E2.%26nbsp%3B%20main.c%3C%2FDIV%3E%3CDIV%20class%3D%22lia-indent-padding-left-30px%22%20style%3D%22padding-left%20%3A%2030px%3B%22%20style%3D%22padding-left%20%3A%2030px%3B%22%3E%26nbsp%3B%3C%2FDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-c%22%3E%3CCODE%3E%23include%20%22sample_usbd.h%22%20%0A%2F*located%20on%20zephyrproject%2Fzephyr%2Fsamples%2Fsubsys%2Fusb%2Fcommon*%2F%0A%0A%23include%20%3CZEPHYR%3E%0A%23include%20%3CZEPHYR%3E%0A%0A%23include%20%3CZEPHYR%3E%0A%0ALOG_MODULE_REGISTER(app%2C%20LOG_LEVEL_DBG)%3B%0A%0Astatic%20void%20msg_cb(struct%20usbd_context%20*const%20usbd_ctx%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20const%20struct%20usbd_msg%20*const%20msg)%20%7B%0A%20%20LOG_INF(%22USBD%20message%3A%20%25s%22%2C%20usbd_msg_type_string(msg-%26gt%3Btype))%3B%0A%0A%20%20if%20(usbd_can_detect_vbus(usbd_ctx))%20%7B%0A%20%20%20%20if%20(msg-%26gt%3Btype%20%3D%3D%20USBD_MSG_VBUS_READY)%20%7B%0A%20%20%20%20%20%20if%20(usbd_enable(usbd_ctx))%20%7B%0A%20%20%20%20%20%20%20%20LOG_ERR(%22Failed%20to%20enable%20device%20support%22)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%0A%20%20%20%20if%20(msg-%26gt%3Btype%20%3D%3D%20USBD_MSG_VBUS_REMOVED)%20%7B%0A%20%20%20%20%20%20if%20(usbd_disable(usbd_ctx))%20%7B%0A%20%20%20%20%20%20%20%20LOG_ERR(%22Failed%20to%20disable%20device%20support%22)%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0Aint%20main(void)%20%7B%0A%20%20struct%20usbd_context%20*sample_usbd%3B%0A%20%20int%20ret%3B%0A%0A%20%20sample_usbd%20%3D%20sample_usbd_init_device(msg_cb)%3B%0A%20%20if%20(sample_usbd%20%3D%3D%20NULL)%20%7B%0A%20%20%20%20k_msleep(100)%3B%0A%20%20%20%20return%200%3B%0A%20%20%7D%0A%0A%20%20if%20(!usbd_can_detect_vbus(sample_usbd))%20%7B%0A%20%20%20%20ret%20%3D%20usbd_enable(sample_usbd)%3B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20if%20(ret)%20%7B%0A%20%20%20%20%20%20%20%20LOG_ERR(%22Failed%20to%20enable%20usb%20support%20!%22)%3B%0A%20%20%20%20%20%20%20%20return%20ret%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%20%20return%200%3B%0A%7D%3C%2FZEPHYR%3E%3C%2FZEPHYR%3E%3C%2FZEPHYR%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3Bin%20both%20cases%20I%20got%26nbsp%3B%26nbsp%3B%3CSTRONG%3E%26nbsp%3B%3CERR%3E%20usbd_core%3A%20Failed%20to%20init%20device%20driver%20.%20%3C%2FERR%3E%3C%2FSTRONG%3Eto%20be%20little%20more%20specific%20-12(-ENOMEM)%26nbsp%3B%3C%2FP%3E%3CP%3Eafter%20tracing%20the%20issue%20back%20I%20pin%20point%20the%20error%20to%20udc_mcux_init(...)%20function%20located%20in%20drivers%2Fusb%2Fudc%2Fudc_mcux_ehci.c%3C%2FP%3E%3CP%3Eto%20narrow%20it%20further%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-c%22%3E%3CCODE%3E%20%20%20%20%20%20%20%20%2F*%20Init%20MCUX%20USB%20device%20driver.%20*%2F%0A%20%20%20%20%20%20%20%20status%20%3D%20mcux_if-%26gt%3BdeviceInit(priv-%26gt%3Bcontroller_id%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%26amp%3Bpriv-%26gt%3Bmcux_device%2C%20%26amp%3B(priv-%26gt%3Bmcux_device.controllerHandle))%3B%0A%20%20%20%20%20%20%20%20if%20(status%20!%3D%20kStatus_USB_Success)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20return%20-ENOMEM%3B%0A%20%20%20%20%20%20%20%20%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2065718%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20FRDM-RW612%20USB_DEVICE_STACK_NEXT%20support%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2065718%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3C%2FP%3E%0A%3CP%3EWhat%20example%20are%20you%20testing%3F%3C%2FP%3E%0A%3CP%3ECould%20you%20please%20share%20some%20reproduction%20steps%3F%3C%2FP%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3EDaniel.%3C%2FP%3E%3C%2FLINGO-BODY%3E