请教各位专家。
- 问题:tiny210 linux,尝试s3c-udc与gadgetfs一起使用,失败。
- 错误现象:
1.把usb.c(gadgetfs官方测试程序,我修改过)编译为可执行程序 usb。执行usb时,到向文
件描述符write后死机.
我对usb.c的修改,是为了使之识别 s3c-ucd。按s3c-hsudc.c注释,
The S3C24XX USB 2.0 high-speed USB controller supports upto 9 endpoints.
Each endpoint can be configured as either in or out endpoint. Endpoints
can be configured for Bulk or Interrupt transfer mode.
我试着进行了几种配置,均导致死机。
2. 执行前usb运行前,执行了下述操作,控制台均无报错。
mkdir /dev/gadget
insmod gadgetfs.ko
mount -t gadgetfs none /dev/gadget
此时,
[root@FriendlyARM plg]# ls /dev/gadget
ls /dev/gadget
s3c-udc
3. dmesg的出错信息:
[ 299.539226] gadgetfs: USB Gadget filesystem, version 24 Aug 2004
[ 353.895836] s3c-udc: bind to driver nop --> error -120
其中第二行是mount操作后出现的。
我猜测,usb.c死机的原因在这里,即gadgetfs加载失败。
请教原因何在?
- 操作系统:
[root@FriendlyARM plg]# uname -a
uname -a
Linux FriendlyARM 3.0.8-FriendlyARM #9 PREEMPT Tue May 7 22:56:46 CST 2013 armv7l GNU/Linux
- 内核配置:
│ │ --- USB Gadget Support │ │
│ │ [*] Debugging messages (DEVELOPMENT) │ │
│ │ [*] Debugging information files (DEVELOPMENT) │ │
│ │ (500) Maximum VBUS Power usage (2-500 mA) │ │
│ │ USB Peripheral Controller (S3C HS USB OTG Device) ---> │ │
│ │ *** NOTE: S3C OTG device role enables the controller driver below *** │ │
│ │ <*> S3C high speed(2.0, dual-speed) USB OTG device (NEW) │ │
│ │ S3C OTGD transfer mode (enabled DMA MODE) ---> │ │
│ │ <M> USB Gadget Drivers │ │
│ │ <M> Gadget Zero (DEVELOPMENT) │ │
│ │ < > Audio Gadget (EXPERIMENTAL) │ │
│ │ < > Ethernet Gadget (with CDC Ethernet support) │ │
│ │ < > Network Control Model (NCM) support │ │
│ │ <M> Gadget Filesystem (EXPERIMENTAL) │ │
│ │ < > Function Filesystem (EXPERIMENTAL) │ │
│ │ < > File-backed Storage Gadget │ │
│ │ <M> Mass Storage Gadget │ │
│ │ <M> Serial Gadget (with CDC ACM and CDC OBEX support) │ │
│ │ < > MIDI Gadget (EXPERIMENTAL) │ │
│ │ < > Printer Gadget │ │
│ │ < > CDC Composite Device (Ethernet and ACM) │ │
│ │ < > Nokia composite gadget │ │
│ │ < > Multifunction Composite Gadget (EXPERIMENTAL) │ │
│ │ < > HID Gadget │ │
│ │ < > EHCI Debug Device Gadget │ │
│ │ < > USB Webcam Gadget │ │
- 其他信息:
1. g_serial.ko与s3c-udc配合,可以与PC的HOST端通信;
我的理解,这表明 tiny210的ucd 确实是 s3c-udc.
2. gadgetfs.ko载入内核(with dummy_hcd + usb.c),dmesg无错误信息。
我的理解,这表明gadgetfs.ko与dummy_hcd可以配合工作。
# lsusb -v
lsusb -v
Bus 3 Device 7 ID 0525a4a4 Netchip Technology, Inc. Linux-USB user-mode bulk source/sink
Device Descriptor
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 255 Vendor Specific Class
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x0525 Netchip Technology, Inc.
idProduct 0xa4a4 Linux-USB user-mode bulk source/sink
bcdDevice 1.00
iManufacturer 1 Licensed to Code, LLC
iProduct 2 My Source/Sink Product
iSerial 3 1.3
bNumConfigurations 1
Configuration Descriptor
bLength 9
bDescriptorType 2
wTotalLength 39
bNumInterfaces 1
bConfigurationValue 3
iConfiguration 4 The Configuration
bmAttributes 0xc0
Self Powered
MaxPower 2mA
Interface Descriptor
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 3
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 5 Source/Sink
Endpoint Descriptor
bLength 7
bDescriptorType 5
bEndpointAddress 0x87 EP 7 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor
bLength 7
bDescriptorType 5
bEndpointAddress 0x03 EP 3 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 1
Endpoint Descriptor
bLength 7
bDescriptorType 5
bEndpointAddress 0x8b EP 11 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 6
Device Qualifier (for other device speed)
bLength 10
bDescriptorType 6
bcdUSB 2.00
bDeviceClass 255 Vendor Specific Class
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
bNumConfigurations 1
Device Status 0x0000
(Bus Powered)
Bus 3 Device 1 ID 1d6b0002 Linux Foundation 2.0 root hub
Device Descriptor
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 9 Hub
bDeviceSubClass 0 Unused
bDeviceProtocol 1 Single TT
bMaxPacketSize0 64
idVendor 0x1d6b Linux Foundation
idProduct 0x0002 2.0 root hub
bcdDevice 3.00
iManufacturer 3 Linux 3.0.8-FriendlyARM dummy_hcd
iProduct 2 Dummy host controller
iSerial 1 dummy_hcd
bNumConfigurations 1
Configuration Descriptor
bLength 9
bDescriptorType 2
wTotalLength 25
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xe0
Self Powered
Remote Wakeup
MaxPower 0mA
Interface Descriptor
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 9 Hub
bInterfaceSubClass 0 Unused
bInterfaceProtocol 0 Full speed (or root) hub
iInterface 0
Endpoint Descriptor
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0004 1x 4 bytes
bInterval 12
Hub Descriptor
bLength 9
bDescriptorType 41
nNbrPorts 1
wHubCharacteristic 0x0001
Per-port power switching
Ganged overcurrent protection
TT think time 8 FS bits
bPwrOn2PwrGood 0 * 2 milli seconds
bHubContrCurrent 0 milli Ampere
DeviceRemovable 0xff
PortPwrCtrlMask 0xff
Hub Port Status
Port 1 0000.0503 highspeed power enable connect
Device Status 0x0003
Self Powered
Remote Wakeup Enabled
Bus 2 Device 1 ID 1d6b0001 Linux Foundation 1.1 root hub
Device Descriptor
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 9 Hub
bDeviceSubClass 0 Unused
bDeviceProtocol 0 Full speed (or root) hub
bMaxPacketSize0 64
idVendor 0x1d6b Linux Foundation
idProduct 0x0001 1.1 root hub
bcdDevice 3.00
iManufacturer 3 Linux 3.0.8-FriendlyARM ohci_hcd
iProduct 2 EXYNOS OHCI Host Controller
iSerial 1 s5p-ohci
bNumConfigurations 1
Configuration Descriptor
bLength 9
bDescriptorType 2
wTotalLength 25
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xe0
Self Powered
Remote Wakeup
MaxPower 0mA
Interface Descriptor
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 9 Hub
bInterfaceSubClass 0 Unused
bInterfaceProtocol 0 Full speed (or root) hub
iInterface 0
Endpoint Descriptor
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0002 1x 2 bytes
bInterval 255
Hub Descriptor
bLength 9
bDescriptorType 41
nNbrPorts 1
wHubCharacteristic 0x0002
No power switching (usb 1.0)
Ganged overcurrent protection
bPwrOn2PwrGood 2 * 2 milli seconds
bHubContrCurrent 0 milli Ampere
DeviceRemovable 0x00
PortPwrCtrlMask 0xff
Hub Port Status
Port 1 0000.0100 power
Device Status 0x0003
Self Powered
Remote Wakeup Enabled
Bus 1 Device 1 ID 1d6b0002 Linux Foundation 2.0 root hub
Device Descriptor
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 9 Hub
bDeviceSubClass 0 Unused
bDeviceProtocol 0 Full speed (or root) hub
bMaxPacketSize0 64
idVendor 0x1d6b Linux Foundation
idProduct 0x0002 2.0 root hub
bcdDevice 3.00
iManufacturer 3 Linux 3.0.8-FriendlyARM ehci_hcd
iProduct 2 S5P EHCI Host Controller
iSerial 1 s5p-ehci
bNumConfigurations 1
Configuration Descriptor
bLength 9
bDescriptorType 2
wTotalLength 25
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xe0
Self Powered
Remote Wakeup
MaxPower 0mA
Interface Descriptor
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 9 Hub
bInterfaceSubClass 0 Unused
bInterfaceProtocol 0 Full speed (or root) hub
iInterface 0
Endpoint Descriptor
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0004 1x 4 bytes
bInterval 12
Hub Descriptor
bLength 9
bDescriptorType 41
nNbrPorts 1
wHubCharacteristic 0x0009
Per-port power switching
Per-port overcurrent protection
bPwrOn2PwrGood 10 * 2 milli seconds
bHubContrCurrent 0 milli Ampere
DeviceRemovable 0x00
PortPwrCtrlMask 0xff
Hub Port Status
Port 1 0000.0100 power
Device Status 0x0003
Self Powered
Remote Wakeup Enabled
[root@FriendlyARM plg]#
3. g_zero.ko载入内核,dmesg无错误信息,如下:
[ 495.979552] zero gadget: adding config #3 'source/sink'/bf1fad28
[ 495.979569] zero gadget: adding 'source/sink'/d9c30080 to config 'source/sink'/bf1fad28
[ 495.979586] zero gadget: dual speed source/sink: IN/ep2-bulk, OUT/ep1-bulk
[ 495.979596] zero gadget: cfg 3/bf1fad28 speeds: high full
[ 495.979605] zero gadget: interface 0 = source/sink/d9c30080
[ 495.979615] zero gadget: adding config #2 'loopback'/bf1fada8
[ 495.979625] zero gadget: adding 'loopback'/d9c30880 to config 'loopback'/bf1fada8
[ 495.979637] zero gadget: dual speed loopback: IN/ep2-bulk, OUT/ep1-bulk
[ 495.979646] zero gadget: cfg 2/bf1fada8 speeds: high full
[ 495.979655] zero gadget: interface 0 = loopback/d9c30880
[ 495.979664] zero gadget: Gadget Zero, version: Cinco de Mayo 2008
[ 495.979724] zero gadget: zero ready
[ 495.998990] Registered gadget driver 'zero'
4. usb.c我修改的那一段,某个版本如下:
/* s3c-udc, high speed. by Young */
} else if
(stat (DEVNAME = "s3c-udc", &statb) == 0) {
HIGHSPEED = 1;
device_desc.bcdDevice = __constant_cpu_to_le16 (0x0100);
fs_source_desc.bEndpointAddress
= hs_source_desc.bEndpointAddress
= USB_DIR_IN | 2;
EP_IN_NAME = "ep2-bulk";
fs_sink_desc.bEndpointAddress
= hs_sink_desc.bEndpointAddress
=USB_DIR_OUT | 1;
EP_OUT_NAME = "ep1-bulk";
source_sink_intf.bNumEndpoints = 3;
fs_status_desc.bEndpointAddress
= hs_status_desc.bEndpointAddress
= USB_DIR_IN | 3;
EP_STATUS_NAME = "ep3-int";
}