I'm trying to create a Gadget using FunctionFS and the FS driver on a IMX8 board running a Debian (kernel 4.14.98). My gadget is composed of two functions with the following configurations:
Code:
Function 1:Interface 0:Endpoint BULK OUT 0x01
Endpoint BULK IN 0x81
Function 2:Interface 0 Alternate setting 0:No Endpoint
Interface 0 Alternate setting 1:Endpoint BULK OUT 0x02
Endpoint BULK IN 0x82
Everything works fine until I activate the alternate setting 1 in Function 2 using libusb's libusb_set_interface_alt_setting from another computer. libusb shows no error but the exchanged USB packets show that a STALL has been returned from the board. There is also no debug information in the kernel logs concerning the STALL. This problem is not due to libusb as I have the same issue (and STALL) if I connect the gadget to another board not relying on libusb to communicate.
I tried changing the USB descriptors (endpoint addresses, alternate setting in function 1) and the code (when I open the endpoints, using one function instead of two) but nothing changes the outcome. I also looked in the kernel source code to figure where the error is but have found no obvious places that could create a STALL.
Anybody else having faced a similar issue or having any idea on how I could figure out what's happening? I would really appreciate the help.