libusb_control_transfer() never returns

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
agba_3844561
Level 3
Level 3
5 likes given First like given

I am communicating with a [Cypress FX3 kit](https://www.cypress.com/products/ez-usb-fx3-superspeed-usb-30-peripheral-controller) device.

I did everything that was explained on AN84868. However, I would like to do my own source code so that I can integrate it with my code. (On linux)

I call cyusb_control_write() with:

         bReqType: 40 (hex)

         bType: 40 (hex)

         bTarget: 0

         bRequest: B2

         wValue: 0

         wIndex: 1

         wLength: 16 (decimal)

like this:

C++ code fragment

rStatus = cyusb_control_write(

   MimacUSB3Connection::device_handle/* a handle for the device to communicate with */
   WRITE_REQUEST_TYPE/* bmRequestType: the request type field for the setup packet */
   VND_CMD_SLAVESER_CFGLOAD/* bRequest: the request field for the setup packet */
   wValue/* wValue: the value field for the setup packet */
   wIndex/* wIndex: the index field for the setup packet */
   (unsigned char *) &fpga_firmware_size/* *data: a suitably-sized data buffer */
   wLength/* wLength: the length field for the setup packet. The data buffer should be at least this size. */
   timeout)/* timeout (in millseconds) that this function should wait before giving up due to no response being received. For an unlimited timeout, use value 0. */

Everytime I run there are 3 options (in order of frequency):

  1. cyusb_control_write never returns but it is able to send data and FX3 device gets all correctly.
  2. cyusb_control_write gets `Process finished with exit code 139 (interrupted by signal 11: SIGSEGV).`
  3. Everything works correctly.

Why could this be happening? As I get unexpected output I am clueless on how to debug this. My main concern is cyusb_control_write not returning after sending the data.

0 Likes
1 Solution
agba_3844561
Level 3
Level 3
5 likes given First like given

I solved the problem. Instead of using this static variable I'm using cyusb_gethandle(0) to get the handle.

I'm still trying to fully understand the problem (why my static variable didn't work). But I solved immediate problem.

View solution in original post

0 Likes
1 Reply
agba_3844561
Level 3
Level 3
5 likes given First like given

I solved the problem. Instead of using this static variable I'm using cyusb_gethandle(0) to get the handle.

I'm still trying to fully understand the problem (why my static variable didn't work). But I solved immediate problem.

0 Likes