Solved Problems writing to usb as gadget

Solved issue

onlyproblems

New Member
Joined
Sep 13, 2023
Messages
4
Reaction score
1
Credits
42
I am trying to mimic an existing device (ps4 and ps5 gamepads). My device is a Raspberry Pi Zero 2. USB Gadget mode seems to be working.
I copied the report descriptor and all settings/information of the device I am trying to mimic. My host correctly detect the device and lsusb shows everything as expected. The original devices have 3 audio functions and 1 hid function. I only copied the 1 hid function, so some slight changes occur but I dont suspect the error originates from the "missing" audio functions.


Now while trying to write to the /dev/hidg0 file (which is created after sucessfully binding my gadget config to the RPi's UDC) I get this error from Rust:
code: 108, kind: Uncategorized, message: "Cannot send after transport endpoint shutdown" (Yes I already asked in a Rust forum, but this seems like a linux issue to me)
The interesting thing is, that the same error occurs if the write call is done, before the RPi is connected to the host.

Connecting the RPi to my host, I get the following dmesg output:
Code:
usb 1-2: new high-speed USB device number 10 using xhci_hcd
usb 1-2: New USB device found, idVendor=054c, idProduct=0ce6, bcdDevice= 1.00
usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-2: Product: Wireless Controller
usb 1-2: Manufacturer: Sony Interactive Entertainment
playstation 0003:054C:0CE6.0013: hidraw4: USB HID v1.01 Gamepad [Sony Interactive Entertainment Wireless Controller] on usb-0000:03:00.3-2/input0
playstation 0003:054C:0CE6.0013: Invalid reportID received, expected 9 got 0
playstation 0003:054C:0CE6.0013: Failed to retrieve DualSense pairing info: -22
playstation 0003:054C:0CE6.0013: Failed to get MAC address from DualSense
playstation 0003:054C:0CE6.0013: Failed to create dualsense.
playstation: probe of 0003:054C:0CE6.0013 failed with error -22
I am completely lost at this point. I am beginning to suspect that what I am trying to do is impossible using the linux usb gadget driver because the options you can set are not enough to fool the host well enough.


If you want to read more, you can read the .md files in my repo
 
Last edited:


Have you tried to reset your Sony game controller? - There is a small round hole on the backside of the controller to reset it use a small paperclip and insert it gently and hold it down for 3 to 5 seconds - Connect the controller to your PlayStation console using the USB cable that came with your console, and press the PS button. Did it connect ?
 
How would this help with my problem?
Im running into this problem while mimicing a Sony Gamepad using the UDC of a Raspberry Pi. So the device is the RPi and the host is some linux system, but will later on by Win10 mostly.
All the Sony controllers I have, to test and get the actual descriptors from, work just as I expect them to :D
 
Last edited:
I stated right above the output block:
Connecting the RPi to my host
So this is not the actual DualSense controller but my RPi mimicing one. Which I am trying to do the whole time
 
So after being stuck on this problem for 2 days now, I figured out that the error:
code: 108, kind: Uncategorized, message: "Cannot send after transport endpoint shutdown"
Is not related to the error log of dmesg

I simply did not wait long enough after binding my device config to the UDC. The host and the linux gadget driver probably do some sort of handshake to tell eachother some information. Only then can data be written to the /dev/hidg0 file, without this error appearing.
 

Members online


Latest posts

Top