*Describe the bug
The sample app from Zephyr cdc_acm on the nrf5340 does not work. Same for all others USB-device samples. The device is not detectable by the host's USB driver.
There is what I am doing to see the problem:
- My target platform nrf5340 (nrf5340dk_nrf5340_cpuapp)
- The tools-chain is zephyr-sdk-0.16.1
- The NRF SDK 2.4.1
- It is not a regression -- same issue with SDK 2.2, 2.4
- To diagnose issue was used the next tips:
- Enabled the 'Debug' log level for USB stack;
- Checked wire connection between USB connector and MCU;
- Tested all another USB samples: HID, Bulk, etc no one work -- the result about the same;
- Captured the diagrams D+ and D- also connection of VBUS did not showed-up any issue ;
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;
6. Plug USB cable;
7. 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 never 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
....
.... Bunch of repeats lines above
....
[00:00:03.206,298] <inf> usb_cdc_acm: Device suspended
Environment (please complete the following information):
- OS: Linux, Manjaro
- Toolschain zephyr-sdk-0.16.1
- nrf SDK 2.4.1 same with 2.4.0 and 2.2