Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usb loopback not work on nrf52840 #31928

Closed
a1ien opened this issue Feb 3, 2021 · 1 comment
Closed

usb loopback not work on nrf52840 #31928

a1ien opened this issue Feb 3, 2021 · 1 comment
Assignees
Labels
area: USB Universal Serial Bus

Comments

@a1ien
Copy link
Contributor

a1ien commented Feb 3, 2021

Describe the bug
I try run testusb samples and simple program with libusb. But only can write to device. Reading from device fail with timeout. And event not call

static void loopback_in_cb(uint8_t ep, enum usb_dc_ep_cb_status_code ep_status)

To Reproduce
Steps to reproduce the behavior:

  1. cmake -B usb_loopback -GNinja -DBOARD=nrf52840dongle_nrf52840 zephyrproject/zephyr/samples/subsys/usb/testusb
  2. cmake --build usb_loopback
  3. flash
  4. compile and run test.c source code

Expected behavior
Output

0, transfer 4
0, transfer 5

Instead libusb_bulk_transfer read from device fail with timout

0, transfer 4
-7, transfer 0

Impact
How to read data from usb device/

Logs and console output

*** Booting Zephyr OS build zephyr-v2.4.0-3783-g3f1d1f5773dd  ***
[00:00:00.275,726] <dbg> usb_descriptor.ascii7_to_utf16le: char 4 : 34, idx 12 -> 25
--- 45 messages dropped ---
[00:00:00.275,756] <dbg> usb_descriptor.ascii7_to_utf16le: char B : 42, idx 11 -> 23
[00:00:00.275,756] <dbg> usb_descriptor.ascii7_to_utf16le: char 5 : 35, idx 10 -> 21
[00:00:00.275,787] <dbg> usb_descriptor.ascii7_to_utf16le: char 6 : 36, idx 9 -> 19
[00:00:00.275,817] <dbg> usb_descriptor.ascii7_to_utf16le: char 5 : 35, idx 8 -> 17
[00:00:00.275,817] <dbg> usb_descriptor.ascii7_to_utf16le: char 2 : 32, idx 7 -> 15
[00:00:00.275,848] <dbg> usb_descriptor.ascii7_to_utf16le: char B : 42, idx 6 -> 13
[00:00:00.275,878] <dbg> usb_descriptor.ascii7_to_utf16le: char 0 : 30, idx 5 -> 11
[00:00:00.275,878] <dbg> usb_descriptor.ascii7_to_utf16le: char 1 : 31, idx 4 -> 9
[00:00:00.275,909] <dbg> usb_descriptor.ascii7_to_utf16le: char 2 : 32, idx 3 -> 7
[00:00:00.275,939] <dbg> usb_descriptor.ascii7_to_utf16le: char 3 : 33, idx 2 -> 5
[00:00:00.275,939] <dbg> usb_descriptor.ascii7_to_utf16le: char 7 : 37, idx 1 -> 3
[00:00:00.275,970] <dbg> usb_descriptor.ascii7_to_utf16le: char 5 : 35, idx 0 -> 1
[00:00:00.281,768] <dbg> usb_device.usb_enable: lock usb_enable_lock mutex
[00:00:00.281,921] <dbg> usb_device.composite_setup_ep_cb: set cb, ep: 0x1
[00:00:00.281,951] <dbg> usb_device.composite_setup_ep_cb: set cb, ep: 0x81
[00:00:00.281,951] <dbg> usb_device.usb_enable: unlock usb_enable_lock mutex
[00:00:00.281,982] <inf> main: entered main.
[00:00:00.582,000] <dbg> usb_device.usb_handle_control_transfer: ep 0x00, status 0x00
[00:00:00.582,031] <dbg> usb_device.custom_handler: bRequest 0x06, wIndex 0x0000
[00:00:00.582,061] <dbg> usb_device.usb_handle_std_device_req: REQ_GET_DESCRIPTOR
[00:00:00.582,153] <dbg> usb_device.usb_handle_control_transfer: ep 0x80, status 0x02
[00:00:00.707,855] <dbg> usb_device.usb_handle_control_transfer: ep 0x00, status 0x00
[00:00:00.707,885] <dbg> usb_device.custom_handler: bRequest 0x06, wIndex 0x0000
[00:00:00.707,885] <dbg> usb_device.usb_handle_std_device_req: REQ_GET_DESCRIPTOR
[00:00:00.708,007] <dbg> usb_device.usb_handle_control_transfer: ep 0x80, status 0x02
[00:00:00.708,160] <dbg> usb_device.usb_handle_control_transfer: ep 0x00, status 0x00
[00:00:00.708,190] <dbg> usb_device.custom_handler: bRequest 0x06, wIndex 0x0000
--- 3 messages dropped ---
[00:00:00.761,749] <dbg> usb_device.usb_handle_control_transfer: ep 0x00, status 0x00
--- 15 messages dropped ---
[00:00:00.788,543] <dbg> usb_device.usb_handle_control_transfer: ep 0x00, status 0x00
[00:00:00.788,574] <dbg> usb_device.custom_handler: bRequest 0x06, wIndex 0x0000
[00:00:00.788,574] <dbg> usb_device.usb_handle_std_device_req: REQ_GET_DESCRIPTOR
[00:00:00.788,726] <dbg> usb_device.usb_handle_control_transfer: ep 0x80, status 0x02
[00:00:00.788,909] <dbg> usb_device.usb_handle_control_transfer: ep 0x00, status 0x00
[00:00:00.788,940] <dbg> usb_device.custom_handler: bRequest 0x06, wIndex 0x0000
[00:00:00.788,940] <dbg> usb_device.usb_handle_std_device_req: REQ_GET_DESCRIPTOR
[00:00:00.789,093] <dbg> usb_device.usb_handle_control_transfer: ep 0x80, status 0x02
[00:00:00.789,215] <dbg> usb_device.usb_handle_control_transfer: ep 0x00, status 0x00
[00:00:00.789,245] <dbg> usb_device.custom_handler: bRequest 0x06, wIndex 0x0000
[00:00:00.789,276] <dbg> usb_device.usb_handle_std_device_req: REQ_GET_DESCRIPTOR
[00:00:00.789,367] <dbg> usb_device.usb_handle_control_transfer: ep 0x80, status 0x02
[00:00:00.789,489] <dbg> usb_device.usb_handle_control_transfer: ep 0x00, status 0x00
[00:00:00.789,550] <dbg> usb_device.custom_handler: bRequest 0x06, wIndex 0x0409
[00:00:00.789,550] <dbg> usb_device.usb_handle_std_device_req: REQ_GET_DESCRIPTOR
[00:00:00.789,764] <dbg> usb_device.usb_handle_control_transfer: ep 0x80, status 0x02
[00:00:00.789,916] <dbg> usb_device.usb_handle_control_transfer: ep 0x00, status 0x00
[00:00:00.789,978] <dbg> usb_device.custom_handler: bRequest 0x06, wIndex 0x0409
[00:00:00.789,978] <dbg> usb_device.usb_handle_std_device_req: REQ_GET_DESCRIPTOR
[00:00:00.790,130] <dbg> usb_device.usb_handle_control_transfer: ep 0x80, status 0x02
[00:00:00.790,252] <dbg> usb_device.usb_handle_control_transfer: ep 0x00, status 0x00
[00:00:00.790,313] <dbg> usb_device.custom_handler: bRequest 0x06, wIndex 0x0409
[00:00:00.790,313] <dbg> usb_device.usb_handle_std_device_req: REQ_GET_DESCRIPTOR
[00:00:00.790,435] <dbg> usb_device.usb_handle_control_transfer: ep 0x80, status 0x02
[00:00:00.796,630] <dbg> usb_device.usb_handle_control_transfer: ep 0x00, status 0x00
[00:00:00.796,661] <dbg> usb_device.custom_handler: bRequest 0x09, wIndex 0x0000
[00:00:00.796,691] <dbg> usb_device.usb_handle_std_device_req: REQ_SET_CONFIGURATION, conf 0x1
[00:00:00.796,722] <dbg> usb_device.set_endpoint: Set endpoint 0x1 type 2 MPS 64
[00:00:00.796,752] <dbg> usb_device.set_endpoint: Set endpoint 0x81 type 2 MPS 64
[00:00:34.231,628] <dbg> usb_loopback.loopback_out_cb: ep 0x1, bytes to read 4 

Environment (please complete the following information):

  • OS: Linux,
  • Toolchain Zephyr SDK 0.12.2
  • Commit: master branch

Additional context
In log no entry for loopback_in_cb. Maybe I wrong call libusb_bulk_transfer?

@a1ien a1ien added the bug The issue is a bug, or the PR is fixing a bug label Feb 3, 2021
@nashif nashif added area: USB Universal Serial Bus platform: nRF Nordic nRFx labels Feb 3, 2021
@jfischer-no jfischer-no removed bug The issue is a bug, or the PR is fixing a bug platform: nRF Nordic nRFx labels Feb 3, 2021
@jfischer-no
Copy link
Collaborator

As described here samples/subsys/usb/testusb is there to test drivers and device stack. Sample works fine on nRF52840 and passes all the tests.

Of course you can write an application that communicates with the sample. loopback is unfortunately not quite the right class name and may be confusing. In your application, the host should make Set Interface request before the first IN transfer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: USB Universal Serial Bus
Projects
None yet
Development

No branches or pull requests

3 participants