我有一个带有USB设备接口的嵌入式Linux 3.19系统。设备需要向主机公开三个USB接口:虚拟网络接口(RNDIS或CDC ECM)和两个虚拟串行端口(CDC ACM)。该设备需要与现代Windows(7+)和Linux(3.16+)主机合作。
由于Windows本身不支持CDC ECM,我们决定实施两种USB配置(这是一种流行的方法):
目的是让Windows使用RNDIS的第一个配置,这是本机支持的(Windows总是选择第一个USB配置);并让非Windows主机使用CDC ECM的第二个配置。
我整理了一个脚本(基于David Lechner的类似脚本):http://pastebin.com/VtAusEmf。下面提供了脚本的相关部分(请点击链接查看完整的脚本,它相当大):
mkdir -p ${g}
echo "${usb_ver}" > ${g}/bcdUSB
echo "${dev_class}" > ${g}/bDeviceClass
echo "${vid}" > ${g}/idVendor
echo "${pid}" > ${g}/idProduct
mkdir ${g}/strings/0x409
echo "${mfg}" > ${g}/strings/0x409/manufacturer
echo "${prod}" > ${g}/strings/0x409/product
echo "${serial}" > ${g}/strings/0x409/serialnumber
mkdir ${g}/configs/c.1
echo "${attr}" > ${g}/configs/c.1/bmAttributes
echo "${pwr}" > ${g}/configs/c.1/MaxPower
mkdir ${g}/configs/c.1/strings/0x409
echo "${cfg1}" > ${g}/configs/c.1/strings/0x409/configuration
echo "1" > ${g}/os_desc/use
echo "${ms_vendor_code}" > ${g}/os_desc/b_vendor_code
echo "${ms_qw_sign}" > ${g}/os_desc/qw_sign
mkdir ${g}/functions/rndis.usb0
echo "${dev_mac}" > ${g}/functions/rndis.usb0/dev_addr
echo "${host_mac}" > ${g}/functions/rndis.usb0/host_addr
echo "${ms_compat_id}" > ${g}/functions/rndis.usb0/os_desc/interface.rndis/compatible_id
echo "${ms_subcompat_id}" > ${g}/functions/rndis.usb0/os_desc/interface.rndis/sub_compatible_id
mkdir ${g}/configs/c.2
echo "${attr}" > ${g}/configs/c.2/bmAttributes
echo "${pwr}" > ${g}/configs/c.2/MaxPower
mkdir ${g}/configs/c.2/strings/0x409
echo "${cfg2}" > ${g}/configs/c.2/strings/0x409/configuration
mkdir ${g}/functions/ecm.usb0
echo "${dev_mac}" > ${g}/functions/ecm.usb0/dev_addr
echo "${host_mac}" > ${g}/functions/ecm.usb0/host_addr
mkdir ${g}/functions/acm.GS0
mkdir ${g}/functions/acm.GS1
ln -s ${g}/configs/c.1 ${g}/os_desc
ln -s ${g}/functions/rndis.usb0 ${g}/configs/c.1
ln -s ${g}/functions/acm.GS0 ${g}/configs/c.1
ln -s ${g}/functions/acm.GS1 ${g}/configs/c.1
ln -s ${g}/functions/ecm.usb0 ${g}/configs/c.2
ln -s ${g}/functions/acm.GS0 ${g}/configs/c.2
ln -s ${g}/functions/acm.GS1 ${g}/configs/c.2
echo "${device}" > ${g}/UDC
生成的Gadget配置适用于Linux主机(第二个配置被选中,所有三个接口都可用并且正常工作),但Windows主机(使用8和10测试)仅检测RNDIS接口,忽略ACM接口。 RNDIS运作良好。
如果我禁用RNDIS接口,Windows主机只检测第一个ACM接口,忽略第二个接口。
我怀疑Windows无法正常处理复合USB设备。是这样,还是我做错了什么?如果是这样,我是否必须编写自己的.inf
文件,指定需要加载哪些类驱动程序?
答案 0 :(得分:1)
RTFM帮了忙。复合USB设备的要求在这些文章中描述:
解决方案:
echo "0xEF" > ${g}/bDeviceClass
echo "0x02" > ${g}/bDeviceSubClass
echo "0x01" > ${g}/bDeviceProtocol