如何在Android Shell中通过ConfigFS设置USB小工具 [英] How to Setup USB Gadget via ConfigFS in Android Shell

查看:901
本文介绍了如何在Android Shell中通过ConfigFS设置USB小工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试将我的Android手机连接到同时充当HID,RNDIS和MASS_STORAGE设备的Windows机器.这些模式中的每一个作为单个模式都可以正常工作,但是我无法将它们正确组合,例如,我可以使用HID,MASS_STORAGE但可以使用norfilter 过滤HID,RNDIS.目前的最佳做法是通过外壳设置USB模式,例如

I am currently trying to get my Android-Phone connected to my Windows machine acting as HID, RNDIS and MASS_STORAGE device simultaneously. Each of those Modes as single mode is working fine but I cant get them combined properly, for example, i can use HID, MASS_STORAGE but norfilter filter HID, RNDIS. Best working practice at the moment is Setting the USB Mode via shell e.g.

setprop sys.usb.config mass_storage,adb

我还致力于使用:

echo 0 > /sys/class/android_usb/android0/enable
echo ecm,adb > /sys/class/android_usb/android0/functions
echo 1 > /sys/class/android_usb/android0/enable

这样,我还可以使网络接口ecm0正常运行.

That way I also could get the network interface ecm0 going.

从网上阅读的所有内容中,我可以使用sysfs或configfs设置具有不同功能的我自己的小工具.因此,我将必须在电话上将/config作为config挂载,但是无论我尝试什么,/config目录都保持为空且为只读.

From all read on the web, i could use sysfs or configfs to setup my own gadget with different functions. Therefore I would have to mount /config as configs on my Phone but no matter what I try the /config directory stays empty and read-only.

有人知道在Android Shell中设置USB小工具的正确方法吗?

Does anyone know a proper way to setup USB-Gadget in an Android Shell?

推荐答案

感谢您的回答 我再次进行了研究,找到了解决这个问题的方法.

thanks for your answer I worked on it again and found a way to figure this out.

首先,您需要禁用USB端口

First you need to disable the USB-Port

echo 0 > /sys/class/android_usb/android0/enable

一个非常重要的事情是正确的功能"-字符串

One very important thing is the right "functions"-String

echo "mass_storage,rndis_qc,ffs" > /sys/class/android_usb/android0/functions

在我的情况下,hid函数由内核自动附加,否则将不得不添加该函数.

In my case the hid functions are appended automatically by the Kernel otherwise one would have to add that.

另一个非常重要的事情是通过以下方式设置供应商和产品ID:

The other VERY important thing is to set the Vendor and Product id's via:

echo "VID" > /sys/class/android_usb/android0/idVendor
echo "PID" > /sys/class/android_usb/android0/idProduct

如果您使用现有设备的供应商和产品ID,Windows10将自动为该设备加载驱动程序.

If you use the Vendor and Product id's of an existing device Windows10 will load the driver for that device automatically.

可在以下位置找到USB设备的供应商/产品ID的列表:

A list of Vendor/Product id's for USB devices can be found here:

http://www.linux-usb.org/usb.ids

最后,您需要重新启用USB端口

Finally you need to reenable the USB port

echo 1 > /sys/class/android_usb/android0/enable

如果要使用网络共享,则当然也需要对其进行配置.以我为例,我成功地将Windows设备用作Windows10中的Hid,Storage和Rndis设备.

If you want to use tethering you would of course need to configure that as well. In my case i managed to use my Android device as Hid,Storage and Rndis device in Windows10 successfully.

希望这对某人有所帮助;)

Hope this helps someone ;)

这篇关于如何在Android Shell中通过ConfigFS设置USB小工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆