[Solved] RPi 4 keyboard gadget not working for phone

This forum is for topics dealing with problems with software specifically in the AArch64 repo.

[Solved] RPi 4 keyboard gadget not working for phone

Postby PixelWidow » Mon Mar 07, 2022 8:03 pm

So I thought I had everything one needs to send key-events over USB-C to any device as I see fit. I have loaded what I think are the necessary kernel modules and have even implemented some Raspbian specific requirements just to test my luck. The first device I tried to send keyboard events to was my ZTE ZMAX Pro phone. It is running Android 6.0, so I figure keyboard support is a thing. However, when I try to send events to /dev/hidg0, I get:

$this->bbcode_second_pass_code('', 'BrokenPipeError: [Errno 108] Cannot send after transport endpoint shutdown')

This doesn't seem to be a very google-able error. What's more strange is that this error message changes when I plug the RasPi into to a different device and then plug the phone in once again. (I think I should also note here that I'm supplying power to my RasPi over GPIO not the USB-C). I get this error message:

$this->bbcode_second_pass_code('', 'BlockingIOError: [Errno 11] write could not complete without blocking')

Again, the keyboard gadget works, but not with this phone. I find this strange because the NetHunter phone (a phone with Kali installed and able to function as a gadget) provides this functionality out of the box and it just works. There is an entire github repo devoted to pin cracking based on this functionality: https://github.com/urbanadventurer/Android-PIN-Bruteforce

Now, this might be something specific to my phone, but on the off chance that I have set up a module incorrectly or I'm not populating /sys/kernel/config/usb_gadget/ correctly, I'd figure my best bet are these forums. Any input is greatly appreciated!

my config.txt:
https://toastmasters227.mooo.com/config.txt

my cmdline.txt:
$this->bbcode_second_pass_code('', 'root=/dev/sda1 rw rootwait console=serial0,115200 console=tty1 selinux=0 plymouth.enable=0 smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 kgdboc=serial0,115200 modules-load=dwc2,libcomposite,g_hid')

my /etc/modules (I'm pretty sure this is Raspbian specific):
$this->bbcode_second_pass_code('', 'libcomposite
dwc2
g_hid')

my /etc/systemd/system/key.service:
https://toastmasters227.mooo.com/keys

my /root/usb:
https://toastmasters227.mooo.com/usb
Last edited by PixelWidow on Fri Mar 11, 2022 8:50 am, edited 1 time in total.
PixelWidow
 
Posts: 2
Joined: Mon Mar 07, 2022 2:21 am

Re: RPi 4 keyboard gadget not working for phone

Postby PixelWidow » Fri Mar 11, 2022 8:49 am

This post is hereafter marked as solved. This was not an issue pertaining to the Pi's ability to send keyboard events (which it appeared to do well enough within the bounds of what's expected for a Pi). The ZTE ZMAX family of phones appears to have come under scrutiny for the absence of support for keyboard/mouse/general OTG technology. See below:

https://androidforums.com/threads/usb-otg.918766/
https://www.gsmarena.com/zte_zmax_pro-reviews-8096p7.php

It's unfortunate my first attempt sending fake keyboard events happened to be with an incompatible device.

The documents referenced by the links above will no longer be accessible. Don't fret if you're looking for example documents for your project; You can find what I had listed above easily on google or elsewhere.
PixelWidow
 
Posts: 2
Joined: Mon Mar 07, 2022 2:21 am


Return to ARMv8

Who is online

Users browsing this forum: No registered users and 7 guests