2016-12-30 118 views
0

我有nanoi-neo,它是基于Allwinner H3的Linux板。它支持USB OTG模式,所以我想尝试使用GadgetFS将其转换为slave。在Allwinner H3基于Linux板上的GadgetFS

据我了解,我应该重建被他们用这个选项

<*> USB Gadget Drivers 
<*>  Gadget Filesystem 

而对于根文件系统提供的Linux内核使用

Package Selection for the target ---> 
Hardware handling ---> 
    [*] gadgetfs-test 

我然后继续建立和启动董事会。

我跟着这个guide和使用这些命令

root:/dev> mkdir /dev/gadget 
root:/dev> mount -t gadgetfs gadgetfs /dev/gadget 
[ 219.808688] WRN:L2558(drivers/usb/sunxi_usb/udc/sunxi_udc.c):ERR: Error in bind() : -120 
[ 219.827939] nop sunxi_usb_udc: failed to start (null): -120 
root:/dev> ls /dev/gadget/ -l 
total 0 
-rw------- 1 root  root    0 Jan 1 00:03 sunxi_usb_udc 

我无法找到关于此错误的东西。人们面对的大多数问题都是关于insmod,但是我已经在内核中内置了模块。所以我没有确定这个问题。

然后我发现这个post为即孙鑫SDK全志问我一些呼应值otg_role,我没有和我得到这个

echo 1 > /sys/bus/platform/devices/sunxi_usb_udc/otg_role 
[ 192.310934] sunxi-ehci sunxi-ehci.1: remove, state 4 
[ 192.326666] usb usb1: USB disconnect, device number 1 
[ 192.343775] sunxi-ehci sunxi-ehci.1: USB bus 1 deregistered 
[ 192.370300] sunxi-ohci sunxi-ohci.1: remove, state 4 
[ 192.385941] usb usb5: USB disconnect, device number 1 
[ 192.402761] sunxi-ohci sunxi-ohci.1: USB bus 5 deregistered 
[ 192.444442] sunxi-ehci sunxi-ehci.1: SW USB2.0 'Enhanced' Host Controller (EHCI) Driver 
[ 192.458113] sunxi-ehci sunxi-ehci.1: new USB bus registered, assigned bus number 1 
[ 192.471720] sunxi-ehci sunxi-ehci.1: irq 104, io mem 0xf1c1a000 
[ 192.500050] sunxi-ehci sunxi-ehci.1: USB 0.0 started, EHCI 1.00 
[ 192.511581] hub 1-0:1.0: USB hub found 
[ 192.519996] hub 1-0:1.0: 1 port detected 
[ 192.548993] sunxi-ohci sunxi-ohci.1: SW USB2.0 'Open' Host Controller (OHCI) Driver 
[ 192.561898] sunxi-ohci sunxi-ohci.1: new USB bus registered, assigned bus number 5 
[ 192.574365] sunxi-ohci sunxi-ohci.1: irq 105, io mem 0xf1c1a400 
[ 192.644522] hub 5-0:1.0: USB hub found 
[ 192.652612] hub 5-0:1.0: 1 port detected 

[email protected]:/$ # echo 2 > /sys/bus/platform/devices/sunxi_usb_udc/otg_role 
[ 195.940888] sunxi-ehci sunxi-ehci.1: remove, state 4 
[ 195.956330] usb usb1: USB disconnect, device number 1 
[ 195.976521] sunxi-ehci sunxi-ehci.1: USB bus 1 deregistered 
[ 195.997477] sunxi-ohci sunxi-ohci.1: remove, state 4 
[ 196.007624] usb usb5: USB disconnect, device number 1 
[ 196.018520] sunxi-ohci sunxi-ohci.1: USB bus 5 deregistered 

我再次尝试安装,但我得到了同样的错误。

有人可以指导我吗?

回答

0

有时很久以后...

简短的回答是你缺少这实际上实例化USB端点和处理设置和控制请求的用户模式组件。

这样的野兽的一个例子是在3个部分,下面的链接。

长版本:

要使用H3板的设备,你需要modprobe gadgetfs,创建一个目录mkdir -p /dev/gadget,然后将装置安装到该目录与mount -t gadgetfs gadgetfs /dev/gadget

最后使用echo 2 > /sys/bus/platform/devices/sunxi_usb_udc/otg_role启用设备角色。

您需要将以下内容添加到usb.cautoconfig()函数中,因为该代码方式早于AllWinner的存在。

构建usermode应用程序(usb)后,只需将其运行为详细模式下的sudo usb -v即可。如果您的设备正确插入并通电,则您的设备现在应该显示在具有两个批量终端和一个中断EP的主机上。

如果您尝试使用主线,您需要更改下面代码(位于/ dev/gadget中)中的控制器名称,并将正确的拼写添加到DTS文件中。祝你好运,因为我还没有得到4.11在我的NanoPi M1和NanoPi Neo Air主板上以设备模式工作。

希望这个迟来的东西对某个人来说有用!

if (stat(DEVNAME = "sunxi_usb_udc", &statb) == 0) 
{ 
    HIGHSPEED = 1; 
    fs_source_desc.bEndpointAddress = hs_source_desc.bEndpointAddress = USB_DIR_IN | 1; 
    EP_IN_NAME = "ep1in-bulk"; 
    fs_sink_desc.bEndpointAddress = hs_sink_desc.bEndpointAddress = USB_DIR_OUT | 1; 
    EP_OUT_NAME = "ep1out-bulk"; 
    source_sink_intf.bNumEndpoints = 3; 
    fs_status_desc.bEndpointAddress = hs_status_desc.bEndpointAddress = USB_DIR_IN | 2; 
    EP_STATUS_NAME = "ep2in-interrupt"; 
} 

Main usermode driver

USB descriptor strings

Header file for the above