zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.52k stars 6.45k forks source link

CDC_ACM sample does not work with nrf5340 -- device suspended/resumed on the host "device descriptor read/64, error -71" #61863

Closed hww closed 1 year ago

hww commented 1 year ago

Describe the bug

I try to compile a sample of a USB device for nrf5340. No one of them work as it should. For example cdc_acm is not detectable by host's USB driver. There is what I am doing to see the problem:

To Reproduce

Steps to reproduce the behavior:

  1. copy cdc_acm to ~/
  2. open with VS Code;
  3. edit build settings:
    • change target "nrf5340dk_nrf5340_cpuapp";
    • change configuration to prj.conf;
  4. Open run menuconfig and change setting: "Max compiled-in log level for usb device" to the value "Debug";
  5. Build project;
  6. Flash firmware;
  7. Plug USB cable;
  8. Restart MCU;

Expected behavior

In the Linux shell type the dmesg and it should printout:

   usb 9-1: new full-speed USB device number 112 using uhci_hcd
   usb 9-1: New USB device found, idVendor=8086, idProduct=f8a1
   usb 9-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
   usb 9-1: Product: CDC-ACM
   usb 9-1: Manufacturer: Intel
   usb 9-1: SerialNumber: 00.01
   cdc_acm 9-1:1.0: ttyACM1: USB ACM device

Impact

In fact the Linux OS does not enumerate device -- the device newer send the answer to the host.

Logs and console output

The dmesg on host shows this

[ 6192.854409] usb 3-2: new full-speed USB device number 2 using xhci_hcd
[ 6192.994432] usb 3-2: device descriptor read/64, error -71
[ 6193.241087] usb 3-2: device descriptor read/64, error -71
[ 6193.477736] usb 3-2: new full-speed USB device number 3 using xhci_hcd
[ 6193.611085] usb 3-2: device descriptor read/64, error -71
[ 6193.854425] usb 3-2: device descriptor read/64, error -71
[ 6193.961150] usb usb3-port2: attempt power cycle
[ 6194.367734] usb 3-2: new full-speed USB device number 4 using xhci_hcd
[ 6194.367815] usb 3-2: Device not responding to setup address.
[ 6194.575253] usb 3-2: Device not responding to setup address.
[ 6194.784392] usb 3-2: device not accepting address 4, error -71
[ 6194.907727] usb 3-2: new full-speed USB device number 5 using xhci_hcd
[ 6194.908250] usb 3-2: Device not responding to setup address.
[ 6195.114461] usb 3-2: Device not responding to setup address.
[ 6195.321064] usb 3-2: device not accepting address 5, error -71
[ 6195.321142] usb usb3-port2: unable to enumerate USB device

The log on the MCU side is:

*** Booting Zephyr OS build v3.3.99-ncs1-1 ***
[00:00:00.522,308] <inf> cdc_acm_echo: Wait for DTR
[00:00:00.526,428] <inf> usb_cdc_acm: Device suspended
[00:00:00.627,410] <inf> usb_cdc_acm: Device resumed
[00:00:00.681,884] <inf> usb_cdc_acm: Device suspended
[00:00:00.694,000] <inf> usb_cdc_acm: Device resumed
[00:00:02.076,873] <inf> usb_cdc_acm: Device suspended
[00:00:02.150,695] <inf> usb_cdc_acm: Device resumed
[00:00:03.439,880] <inf> usb_cdc_acm: Device suspended

But when Debug level is activated it is:

*** Booting Zephyr OS build v3.3.99-ncs1-1 ***
[00:00:00.591,003] <dbg> usb_device: usb_enable: lock usb_enable_lock mutex
[00:00:00.591,125] <dbg> usb_device: composite_setup_ep_cb: set cb, ep: 0x81
[00:00:00.591,125] <dbg> usb_device: composite_setup_ep_cb: set cb, ep: 0x1
[00:00:00.591,156] <dbg> usb_device: composite_setup_ep_cb: set cb, ep: 0x82
[00:00:00.591,186] <dbg> usb_device: usb_enable: unlock usb_enable_lock mutex
[00:00:00.591,186] <inf> cdc_acm_echo: Wait for DTR
[00:00:00.595,245] <inf> usb_cdc_acm: Device suspended
[00:00:00.696,472] <inf> usb_cdc_acm: Device resumed
[00:00:00.696,472] <inf> usb_cdc_acm: from suspend
[00:00:00.826,446] <dbg> usb_device: usb_handle_control_transfer: ep 0x00, status 0x00
--- 23 messages dropped ---
[00:00:00.829,254] <dbg> usb_device: usb_handle_control_transfer: ep 0x00, status 0x00
[00:00:00.829,284] <dbg> usb_device: custom_handler: bRequest 0x06, wIndex 0x0000
[00:00:00.829,284] <dbg> usb_device: usb_get_descriptor: Get Descriptor request
[00:00:00.829,315] <wrn> usb_device: Failed to write endpoint buffer 0x80
[00:00:00.829,315] <wrn> usb_device: Failed to write endpoint buffer 0x80
[00:00:00.829,345] <wrn> usb_device: Failed to write endpoint buffer 0x80
[00:00:00.829,376] <wrn> usb_device: Failed to write endpoint buffer 0x80
[00:00:00.832,336] <dbg> usb_device: usb_handle_control_transfer: ep 0x00, status 0x00
[00:00:00.832,366] <dbg> usb_device: custom_handler: bRequest 0x06, wIndex 0x0000
[00:00:00.832,366] <dbg> usb_device: usb_get_descriptor: Get Descriptor request
[00:00:00.832,397] <wrn> usb_device: Failed to write endpoint buffer 0x80
[00:00:00.832,427] <wrn> usb_device: Failed to write endpoint buffer 0x80
[00:00:00.832,458] <wrn> usb_device: Failed to write endpoint buffer 0x80
[00:00:00.832,458] <wrn> usb_device: Failed to write endpoint buffer 0x80

....
....
....
[00:00:03.206,298] <inf> usb_cdc_acm: Device suspended

Environment (please complete the following information):

github-actions[bot] commented 1 year ago

Hi @hww! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙

thedjnK commented 1 year ago

You're using NCS, bugs for that go to https://devzone.nordicsemi.com/

If you can reproduce the issue with zephyr i.e. not NCS, then the bug should be reported here

jfischer-no commented 1 year ago

NCS issue or issue caused by the user.