Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working on Samsung S10 5G HID gadget #36

Open
himekifee opened this issue Aug 15, 2022 · 14 comments
Open

Not working on Samsung S10 5G HID gadget #36

himekifee opened this issue Aug 15, 2022 · 14 comments

Comments

@himekifee
Copy link

himekifee commented Aug 15, 2022

I've used this lovely tool on another more recent Samsung device and that did work. However, on this relatively old device, it does not work due to #12 at first. It did not create the HID gadget profile as that out of memory popped out. Fortunately, following your discussion on how later android kernel source fixed that issue also works for me. I added static int gadget_index in the beginning and changed device = device_create(android_class, NULL, MKDEV(0, 0), NULL, "android0"); to device = device_create(android_class, NULL, MKDEV(0, 0), NULL, "android%d", gadget_index++);. After that, I'm able to create a gadget as shown.
img

However, when I click on that enable button, it goes back to the disabled state automatically within 2 secs and no hidg endpoints get created. I didn't really find useful info in logs.
img
img
May you give me some advice, please? I kinda need a solution as my machine is still down, and I don't have a keyboard...

@tejado
Copy link
Owner

tejado commented Aug 16, 2022

Hi @himekifee,
my personal solution is to avoid Samsung devices for that purpose. I'm currently looking at more "open" devices like Pixel.

In regard to further information: have a look into the system log (run logcat under root) during the time of enabling the gadget manually and auto-disabling. We might see there something related to it which helps to debug that. I tried to understand that behaviour on an old Samsung phone few years ago but never came to any conclusion as it was very very time consuming and my lack of knowledge about the gadget system in the kernel.

@himekifee
Copy link
Author

I was also able to add the hid.keyboard function in g0 gadget. Is there a way to utilise this since I only do that for now as an emergent situation?

@himekifee
Copy link
Author

From what I can see there is no 0x409 dir in strings

:/config/usb_gadget/keyboard/configs/c.1/strings # ls
:/config/usb_gadget/keyboard/configs/c.1/strings # 

There is one under normal gadget

:/config/usb_gadget/g1/configs/b.1/strings # ls
0x409

Could it be the kernel thing that is fixed later as the above one?

@himekifee
Copy link
Author

I'm able to progress till I write UDC

[ 4693.039760] Config c/1 of keyboard needs at least one function.
[ 4693.039798] configfs-gadget 10c00000.dwc3: failed to start keyboard: -22

However, there are dirs under configs/c.1

130|:/config/usb_gadget/keyboard/configs/c.1 # ls
MaxPower  bmAttributes  hid.keyboard  hid.mouse  strings

@tejado
Copy link
Owner

tejado commented Aug 16, 2022

I'm able to progress till I write UDC

[ 4693.039760] Config c/1 of keyboard needs at least one function.
[ 4693.039798] configfs-gadget 10c00000.dwc3: failed to start keyboard: -22

However, there are dirs under configs/c.1

130|:/config/usb_gadget/keyboard/configs/c.1 # ls
MaxPower  bmAttributes  hid.keyboard  hid.mouse  strings

Here is the line of code which is reporting this error: https://github.com/corsicanu/android_kernel_samsung_universal9820/blob/7c38bfbe048f6b894b3f68d9bc7495399f0b0c87/drivers/usb/gadget/udc/core.c#L1353

EDIT:
And the first error will get reported here: https://github.com/corsicanu/android_kernel_samsung_universal9820/blob/7c38bfbe048f6b894b3f68d9bc7495399f0b0c87/drivers/usb/gadget/configfs.c#L1572

The return code also matches -EINVAL (-22). I remember that I was 1-2 years ago at the same step but were not able to figure out the cause.

@MrRob0-X
Copy link

Hi @himekifee, my personal solution is to avoid Samsung devices for that purpose. I'm currently looking at more "open" devices like Pixel.

In regard to further information: have a look into the system log (run logcat under root) during the time of enabling the gadget manually and auto-disabling. We might see there something related to it which helps to debug that. I tried to understand that behaviour on an old Samsung phone few years ago but never came to any conclusion as it was very very time consuming and my lack of knowledge about the gadget system in the kernel.

This happens with exynos versions with 4.x kernels and up, as far as i know the cause of this problem is a device blobs, which prevents the creation of hidg* functions in the system. to solve this problem we need to create a config with usb controller model used on current device, we can use it as magisk module or so but sadly i don't know the method, i can only get the init file from device tree, This information was taken from a friend of mine @Tkpointz.

@tejado
Copy link
Owner

tejado commented Feb 19, 2023

to solve this problem we need to create a config with usb controller model used on current device

What does this mean?

@MrRob0-X
Copy link

to solve this problem we need to create a config with usb controller model used on current device

What does this mean?

a config like the normal init config

@tejado
Copy link
Owner

tejado commented Feb 19, 2023

A config or a gadget? So you are saying it needs to like the default one (g1)? And if it is a config, should it be in a separate gadget or in the default one?

@MrRob0-X
Copy link

A config or a gadget? So you are saying it needs to like the default one (g1)? And if it is a config, should it be in a separate gadget or in the default one?

Nah i meant init config like nethunter.blabla

@tejado
Copy link
Owner

tejado commented Feb 19, 2023

A config or a gadget? So you are saying it needs to like the default one (g1)? And if it is a config, should it be in a separate gadget or in the default one?

Nah i meant init config like nethunter.blabla

Sorry, dont understand what you mean. The USB init config (init.usb.rc) which basically configures the USB Gadget according to the system settings writes to configFS like android-usb-gadget does.

@MrRob0-X
Copy link

A config or a gadget? So you are saying it needs to like the default one (g1)? And if it is a config, should it be in a separate gadget or in the default one?

Nah i meant init config like nethunter.blabla

Sorry, dont understand what you mean. The USB init config (init.usb.rc) which basically configures the USB Gadget according to the system settings writes to configFS like android-usb-gadget does.

You are absolutely right, but the difference here is that modified config will be based on device init config like samsung a30s
as example (init.exynos7885.usb.rc)

@tejado
Copy link
Owner

tejado commented Feb 19, 2023

Thanks, I will try it - but currently, it is no priority and I general recommend Pixel phones for this.
Happy to see some other users implementing/testing this.

@MrRob0-X
Copy link

Thanks, I will try it - but currently, it is no priority and I general recommend Pixel phones for this. Happy to see some other users implementing/testing this.

Actually this is not a solution because i said earlier that i don't know how to create a custom config based on stock one, just got info about it.

About this problem, the only solution right now is to get an Exynos device with 3.x kernel version or snapragon version which works without problems, i have two samsung devices with snap chipset a70 and note 20 ultra and hid working like a charm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants