This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux: AM5718: Use the libusb library work failed !

Expert 1385 points

Tool/software: Linux

Hi,

I am on writing a demo based on the libusb, and build the demo based on library of the SDK version is 3.1.0.6.

it worked at first time, but I run it the second time, it return failed.

and the demo is as follow:

7080.libusbdemo.zip

and I run the demo in AM57xx evm , and it has the same result.

I hope you can try it on your side, Thank you very much!

Best Regards

Qing

  • And tell me that's why ?

    Thank you very much!

    Best Regards
    Qing
  • Where does it fail when you run second time ? At open time ?

  • Dear Dwarakesh  R :

    When I use the libusb_bulk_transfer(), and it return -7, and errno message is "Resource temporarily unavailable". Thank you very much!

    you can retry on your am57xx evm board. There is no such issue on am335x platform device.

    Best Regards
    Qing

  • Hi Qing,

    Do you see any error in kernel dmesg logs ? Can you check the dmesg logs between first succesful run and second failure run ?

  • Dear Dwarakesh R :

    Thanks for your quick response!

    I am pretty sure that "No any kernel dmesg error log" is generated during runing the demo.
    It's quite strange!

    Thank you very much!

    Best Regards
    Qing
  • Dear Dwarakesh R :

    I finally enable the debug log, and as follow:
    [timestamp] [threadID] facility level [function call] <message>
    --------------------------------------------------------------------------------
    [ 0.000017] [000003fa] libusb: debug [libusb_init] created default context
    [ 0.000197] [000003fa] libusb: debug [libusb_init] libusb v1.0.21.11156
    [ 0.000316] [000003fa] libusb: debug [find_usbfs_path] found usbfs at /dev/bus/usb
    [ 0.000388] [000003fa] libusb: debug [op_init] bulk continuation flag supported
    [ 0.000408] [000003fa] libusb: debug [op_init] zero length packet flag supported
    [ 0.000456] [000003fa] libusb: debug [op_init] sysfs can relate devices
    [ 0.000473] [000003fa] libusb: debug [op_init] sysfs has complete descriptors
    [ 0.004319] [000003fb] libusb: debug [linux_udev_event_thread_main] udev event thread entering.
    [ 0.008041] [000003fa] libusb: debug [linux_get_device_address] getting address for device: usb1 detached: 0
    [ 0.008067] [000003fa] libusb: debug [linux_get_device_address] scan usb1
    [ 0.008342] [000003fa] libusb: debug [linux_get_device_address] bus=1 dev=1
    [ 0.008363] [000003fa] libusb: debug [linux_enumerate_device] busnum 1 devaddr 1 session_id 257
    [ 0.008381] [000003fa] libusb: debug [linux_enumerate_device] allocating new device for 1/1 (session 257)
    [ 0.008961] [000003fa] libusb: debug [linux_get_device_address] getting address for device: 1-1 detached: 0
    [ 0.008983] [000003fa] libusb: debug [linux_get_device_address] scan 1-1
    [ 0.009217] [000003fa] libusb: debug [linux_get_device_address] bus=1 dev=2
    [ 0.009237] [000003fa] libusb: debug [linux_enumerate_device] busnum 1 devaddr 2 session_id 258
    [ 0.009254] [000003fa] libusb: debug [linux_enumerate_device] allocating new device for 1/2 (session 258)
    [ 0.009473] [000003fa] libusb: debug [linux_get_parent_info] Dev 0x397d0 (1-1) has parent 0x39728 (usb1) port 1
    [ 0.009810] [000003fa] libusb: debug [linux_get_device_address] getting address for device: usb2 detached: 0
    [ 0.009831] [000003fa] libusb: debug [linux_get_device_address] scan usb2
    [ 0.010056] [000003fa] libusb: debug [linux_get_device_address] bus=2 dev=1
    [ 0.010076] [000003fa] libusb: debug [linux_enumerate_device] busnum 2 devaddr 1 session_id 513
    [ 0.010093] [000003fa] libusb: debug [linux_enumerate_device] allocating new device for 2/1 (session 513)
    [ 0.010583] [000003fa] libusb: debug [linux_get_device_address] getting address for device: usb3 detached: 0
    [ 0.010604] [000003fa] libusb: debug [linux_get_device_address] scan usb3
    [ 0.010831] [000003fa] libusb: debug [linux_get_device_address] bus=3 dev=1
    [ 0.010851] [000003fa] libusb: debug [linux_enumerate_device] busnum 3 devaddr 1 session_id 769
    [ 0.010868] [000003fa] libusb: debug [linux_enumerate_device] allocating new device for 3/1 (session 769)
    [ 0.011378] [000003fa] libusb: debug [linux_get_device_address] getting address for device: usb4 detached: 0
    [ 0.011399] [000003fa] libusb: debug [linux_get_device_address] scan usb4
    [ 0.011626] [000003fa] libusb: debug [linux_get_device_address] bus=4 dev=1
    [ 0.011645] [000003fa] libusb: debug [linux_enumerate_device] busnum 4 devaddr 1 session_id 1025
    [ 0.011662] [000003fa] libusb: debug [linux_enumerate_device] allocating new device for 4/1 (session 1025)
    [ 0.011893] [000003fa] libusb: debug [usbi_add_pollfd] add fd 6 events 1
    [ 0.011970] [000003fa] libusb: debug [usbi_io_init] using timerfd for timeouts
    [ 0.011990] [000003fa] libusb: debug [usbi_add_pollfd] add fd 8 events 1
    [ 0.012012] [000003fa] libusb: debug [libusb_get_device_list]
    [ 0.012067] [000003fa] libusb: debug [libusb_get_device_descriptor]
    [ 0.012084] [000003fa] libusb: debug [libusb_get_device_descriptor]
    [ 0.012098] [000003fa] libusb: debug [libusb_get_device_descriptor]
    [ 0.012112] [000003fa] libusb: debug [libusb_get_device_descriptor]
    [ 0.012127] [000003fa] libusb: debug [libusb_open] open 1.2
    [ 0.012200] [000003fa] libusb: debug [usbi_add_pollfd] add fd 9 events 4
    [ 0.012224] [000003fa] libusb: debug [libusb_claim_interface] interface 0
    [ 0.012307] [000003fa] libusb: debug [libusb_clear_halt] endpoint 2
    [ 0.012454] [000003fa] libusb: debug [libusb_clear_halt] endpoint 82
    ############# libusb_bulk_transfer
    [ 0.012650] [000003fa] libusb: debug [libusb_bulk_transfer] QQQQ

    [ 0.012680] [000003fa] libusb: debug [libusb_alloc_transfer] transfer 0x3af08
    [ 0.346513] [000003fa] libusb: debug [libusb_submit_transfer] transfer 0x3af08
    [ 0.346539] [000003fa] libusb: debug [submit_bulk_transfer] need 1 urbs for new transfer with length 3
    [ 0.346611] [000003fa] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
    [ 0.346638] [000003fa] libusb: debug [handle_events] poll fds modified, reallocating
    [ 0.346664] [000003fa] libusb: debug [handle_events] poll() 3 fds with timeout in 60000ms
    [ 0.346691] [000003fa] libusb: debug [handle_events] poll() returned 1
    [ 0.346713] [000003fa] libusb: debug [reap_for_handle] urb type=3 status=0 transferred=3
    [ 0.346731] [000003fa] libusb: debug [handle_bulk_completion] handling completion status 0 of bulk urb 1/1
    [ 0.346747] [000003fa] libusb: debug [handle_bulk_completion] last URB in transfer --> complete!
    [ 0.346763] [000003fa] libusb: debug [usbi_handle_transfer_completion] transfer 0x3af08 has callback 0xb6f733b0
    [ 0.346778] [000003fa] libusb: debug [sync_transfer_cb] actual_length=3
    [ 0.346810] [000003fa] libusb: debug [libusb_free_transfer] transfer 0x3af08
    [Error message:]
    Resource temporarily unavailable: Resource temporarily unavailable
    BytesWritten=3
    ############# libusb_bulk_transfer
    [ 0.346912] [000003fa] libusb: debug [libusb_bulk_transfer] QQQQ

    [ 0.346933] [000003fa] libusb: debug [libusb_alloc_transfer] transfer 0x3af08
    [ 0.346949] [000003fa] libusb: debug [libusb_submit_transfer] transfer 0x3af08
    [ 0.346965] [000003fa] libusb: debug [submit_bulk_transfer] need 1 urbs for new transfer with length 64
    [ 0.346996] [000003fa] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
    [ 0.347014] [000003fa] libusb: debug [handle_events] poll() 3 fds with timeout in 60000ms
    [ 0.356049] [000003fa] libusb: debug [handle_events] poll() returned 1
    [ 0.356073] [000003fa] libusb: debug [reap_for_handle] urb type=3 status=0 transferred=1
    [ 0.356090] [000003fa] libusb: debug [handle_bulk_completion] handling completion status 0 of bulk urb 1/1
    [ 0.356105] [000003fa] libusb: debug [handle_bulk_completion] last URB in transfer --> complete!
    [ 0.356121] [000003fa] libusb: debug [usbi_handle_transfer_completion] transfer 0x3af08 has callback 0xb6f733b0
    [ 0.356136] [000003fa] libusb: debug [sync_transfer_cb] actual_length=1
    [ 0.356154] [000003fa] libusb: debug [libusb_free_transfer] transfer 0x3af08
    [Error message:]
    Resource temporarily unavailable: Resource temporarily unavailable
    1 :12 0
    [ 0.356204] [000003fa] libusb: debug [libusb_release_interface] interface 0
    [ 0.356251] [000003fa] libusb: debug [libusb_close]
    [ 0.356279] [000003fa] libusb: debug [usbi_remove_pollfd] remove fd 9

    Is it helpful to you ?

    Best Regards
    Qing
  • Hi,

    I have solved this problem.

    I just add the API libusb_reset_device(devh) after the open the usb device.

    and there is no any error when transfer.

    And the all filles is as attahcment. 2061.LibUSBSimpleDemo.c

    Best Regards

    Qing

  • Hi Qing,

    Good to know it you are able to make it work. I am just curious to know, what happens when you remove "libusb_clear_halt" and also remove the "libusb_reset_device" and check for the second time ?
  • Hi,
    After I removed "libusb_clear_halt" and "libusb_reset_device" , this program just can be run normally at the first time. When I run it at second time, this program will block at libusb_bulk_transfer().

    Best Regards
    Qing