Hi,
I'm writing a new usb-storage subdriver to support card readers based on the
Alauda chip.
I've sniffed some data and I am building up an idea of how the thing works. I
have attempted to put pen to paper but I am having trouble sending anything on
the control pipe.
When I plug it in, I get:
usb 2-3: new full speed USB device using ohci_hcd and address 24
ohci_hcd 0000:00:02.0: GetStatus roothub.portstatus [2] = 0x00100103 PRSC PPS
PES CCS
usb 2-3: default language 0x0409
usb 2-3: new device strings: Mfr=1, Product=2, SerialNumber=0
usb 2-3: Product: USB Media Adapter
usb 2-3: Manufacturer: OLYMPUS OPTICAL CO.,LTD.
usb 2-3: hotplug
usb 2-3: adding 2-3:1.0 (config #1, interface 0)
usb 2-3:1.0: hotplug
usb-storage 2-3:1.0: usb_probe_interface
usb-storage 2-3:1.0: usb_probe_interface - got id
usb-storage: USB Mass Storage device detected
usb-storage: -- associate_dev
usb-storage: Vendor: 0x07b4, Product: 0x010a, Revision: 0x0102
usb-storage: Interface Subclass: 0x00, Protocol: 0x00
usb-storage: Transport: Olympus Alauda Control/Bulk
usb-storage: Protocol: Transparent SCSI
usb-storage: usb_stor_bulk_transfer_buf: xfer 9 bytes
usb-storage: Status code 0; transferred 9/9
usb-storage: -- transfer complete
usb-storage: usb_stor_bulk_transfer_buf: xfer 30 bytes
usb-storage: Status code 0; transferred 30/30
usb-storage: -- transfer complete
usb-storage: usb_stor_ctrl_transfer: rq=08 rqtype=00 value=0000 index=01 len=2
usb-storage: Status code -32; transferred 0/2
usb-storage: -- stall on control pipe
usb-storage: init_alauda: ctrl #1 failed
I have attached the early driver file used to make this happen. It includes an
ugly hack to get the second bulk command going out of EP1 (the send_bulk_pipe
goes to EP3) -- I'm not sure what the bulk commands do at this stage, or if
they are even needed. However, whether they are there or not, I always get the
control pipe stall :(
I have also attached the beginning section of the sniffed data that I am
trying to copy!
I'd be very grateful for any help getting this off the ground.
Thanks!
Daniel
/*
* Driver for Alauda-based card readers
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "usb.h"
#include "transport.h"
#include "protocol.h"
#include "debug.h"
#include "alauda.h"
int init_alauda(struct us_data *us)
{
int rc;
unsigned char *data = us->iobuf;
unsigned char cmd1[] = { 0x40, 0x54, 0, 0, 0, 0, 0x1e, 0, 0x01 };
unsigned char cmd2[] = {
0, 0xdc, 0x02, 0, 0, 0x10, 0, 0x20, 0, 0x01,
0, 0xd3, 0x02, 0, 0, 0x10, 0, 0x20, 0, 0x01,
0, 0xd5, 0x02, 0, 0, 0x10, 0, 0x10, 0, 0,
};
int ep1;
struct usb_host_interface *altsetting = us->pusb_intf->cur_altsetting;
struct usb_endpoint_descriptor *ep;
ep = &altsetting->endpoint[0].desc;
ep1 = usb_sndbulkpipe(us->pusb_dev, ep->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, cmd1, 9, NULL);
if (rc != USB_STOR_XFER_GOOD)
US_DEBUGP("init_alauda: bulk #1 failed\n");
rc = usb_stor_bulk_transfer_buf(us, ep1, cmd2, 30, NULL);
if (rc != USB_STOR_XFER_GOOD)
US_DEBUGP("init_alauda: bulk #2 failed\n");
rc = usb_stor_ctrl_transfer(us, us->recv_ctrl_pipe, 0x08, 0, 0, 1,
data, 2);
if (rc != USB_STOR_XFER_GOOD)
US_DEBUGP("init_alauda: ctrl #1 failed\n");
US_DEBUGP("Ctrl read %02X %02X\n", data[0], data[1]);
return USB_STOR_TRANSPORT_GOOD;
}
int alauda_transport(struct scsi_cmnd *srb, struct us_data *us)
{
return USB_STOR_TRANSPORT_GOOD;
}
[0 ms] UsbSnoop compiled on Jan 18 2003 22:41:32 loading
[0 ms] UsbSnoop - DriverEntry(f8828c40) : Windows NT WDM version 1.32
[1 ms] UsbSnoop - AddDevice(f8828f50) : DriverObject 81ad9240, pdo 81b680f0
[1 ms] UsbSnoop - MyDispatchPNP(f8828ee0) : IRP_MJ_PNP
(IRP_MN_QUERY_CAPABILITIES)
[1 ms] UsbSnoop - DispatchAny(f8826610) : IRP_MJ_PNP (0x00000018)
[1 ms] UsbSnoop - MyDispatchPNP(f8828ee0) : IRP_MJ_PNP (0x00000018)
[1 ms] UsbSnoop - DispatchAny(f8826610) : IRP_MJ_PNP
(IRP_MN_QUERY_RESOURCE_REQUIREMENTS)
[1 ms] UsbSnoop - MyDispatchPNP(f8828ee0) : IRP_MJ_PNP
(IRP_MN_QUERY_RESOURCE_REQUIREMENTS)
[1 ms] UsbSnoop - DispatchAny(f8826610) : IRP_MJ_PNP
(IRP_MN_FILTER_RESOURCE_REQUIREMENTS)
[1 ms] UsbSnoop - MyDispatchPNP(f8828ee0) : IRP_MJ_PNP
(IRP_MN_FILTER_RESOURCE_REQUIREMENTS)
[1 ms] UsbSnoop - DispatchAny(f8826610) : IRP_MJ_PNP (IRP_MN_START_DEVICE)
[1 ms] UsbSnoop - MyDispatchPNP(f8828ee0) : IRP_MJ_PNP (IRP_MN_START_DEVICE)
[1 ms] UsbSnoop - DispatchAny(f8826610) : IRP_MJ_INTERNAL_DEVICE_CONTROL
[1 ms] UsbSnoop - MyDispatchInternalIOCTL(f8827e80) : fdo=81b680f0,
Irp=81b6fb40, IRQL=0
[1 ms] >>> URB 1 going down >>>
-- URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE:
TransferBufferLength = 00000012
TransferBuffer = 81d503b8
TransferBufferMDL = 00000000
Index = 00000000
DescriptorType = 00000001 (USB_DEVICE_DESCRIPTOR_TYPE)
LanguageId = 00000000
[1 ms] UsbSnoop - DispatchAny(f8826610) : IRP_MJ_SYSTEM_CONTROL
[1 ms] UsbSnoop - DispatchAny(f8826610) : IRP_MJ_SYSTEM_CONTROL
[4 ms] UsbSnoop - MyInternalIOCTLCompletion(f8827db0) : fido=00000000,
Irp=81b6fb40, Context=81b10bb8, IRQL=2
[4 ms] <<< URB 1 coming back <<<
-- URB_FUNCTION_CONTROL_TRANSFER:
PipeHandle = 81b72c20
TransferFlags = 0000000b (USBD_TRANSFER_DIRECTION_IN,
USBD_SHORT_TRANSFER_OK)
TransferBufferLength = 00000012
TransferBuffer = 81d503b8
TransferBufferMDL = 81ae2c60
00000000: 12 01 00 01 00 00 00 40 b4 07 0a 01 02 01 01 02
00000010: 00 01
UrbLink = 00000000
SetupPacket =
00000000: 80 06 00 01 00 00 12 00
[4 ms] UsbSnoop - DispatchAny(f8826610) : IRP_MJ_INTERNAL_DEVICE_CONTROL
[4 ms] UsbSnoop - MyDispatchInternalIOCTL(f8827e80) : fdo=81b680f0,
Irp=81b6fb40, IRQL=0
[4 ms] >>> URB 2 going down >>>
-- URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE:
TransferBufferLength = 00000209
TransferBuffer = 819acdf0
TransferBufferMDL = 00000000
Index = 00000000
DescriptorType = 00000002 (USB_CONFIGURATION_DESCRIPTOR_TYPE)
LanguageId = 00000000
[8 ms] UsbSnoop - MyInternalIOCTLCompletion(f8827db0) : fido=00000000,
Irp=81b6fb40, Context=81c24278, IRQL=2
[8 ms] <<< URB 2 coming back <<<
-- URB_FUNCTION_CONTROL_TRANSFER:
PipeHandle = 81b72c20
TransferFlags = 0000000b (USBD_TRANSFER_DIRECTION_IN,
USBD_SHORT_TRANSFER_OK)
TransferBufferLength = 00000027
TransferBuffer = 819acdf0
TransferBufferMDL = 81ae2c60
00000000: 09 02 27 00 01 01 00 80 28 09 04 00 00 03 ff 00
00000010: 00 00 07 05 01 02 40 00 00 07 05 82 02 40 00 00
00000020: 07 05 03 02 40 00 00
UrbLink = 00000000
SetupPacket =
00000000: 80 06 00 02 00 00 09 02
[8 ms] UsbSnoop - DispatchAny(f8826610) : IRP_MJ_INTERNAL_DEVICE_CONTROL
[8 ms] UsbSnoop - MyDispatchInternalIOCTL(f8827e80) : fdo=81b680f0,
Irp=81b6fb40, IRQL=0
[8 ms] >>> URB 3 going down >>>
-- URB_FUNCTION_SELECT_CONFIGURATION:
ConfigurationDescriptor = 0x819acdf0 (configure)
ConfigurationDescriptor : bLength = 9
ConfigurationDescriptor : bDescriptorType = 0x00000002
ConfigurationDescriptor : wTotalLength = 0x00000027
ConfigurationDescriptor : bNumInterfaces = 0x00000001
ConfigurationDescriptor : bConfigurationValue = 0x00000001
ConfigurationDescriptor : iConfiguration = 0x00000000
ConfigurationDescriptor : bmAttributes = 0x00000080
ConfigurationDescriptor : MaxPower = 0x00000028
ConfigurationHandle = 0x00000000
Interface[0]: Length = 76
Interface[0]: InterfaceNumber = 0
Interface[0]: AlternateSetting = 0
[88 ms] UsbSnoop - MyInternalIOCTLCompletion(f8827db0) : fido=00000000,
Irp=81b6fb40, Context=81b6e6d8, IRQL=0
[89 ms] <<< URB 3 coming back <<<
-- URB_FUNCTION_SELECT_CONFIGURATION:
ConfigurationDescriptor = 0x819acdf0 (configure)
ConfigurationDescriptor : bLength = 9
ConfigurationDescriptor : bDescriptorType = 0x00000002
ConfigurationDescriptor : wTotalLength = 0x00000027
ConfigurationDescriptor : bNumInterfaces = 0x00000001
ConfigurationDescriptor : bConfigurationValue = 0x00000001
ConfigurationDescriptor : iConfiguration = 0x00000000
ConfigurationDescriptor : bmAttributes = 0x00000080
ConfigurationDescriptor : MaxPower = 0x00000028
ConfigurationHandle = 0x81af2628
Interface[0]: Length = 76
Interface[0]: InterfaceNumber = 0
Interface[0]: AlternateSetting = 0
Interface[0]: Class = 0x000000ff
Interface[0]: SubClass = 0x00000000
Interface[0]: Protocol = 0x00000000
Interface[0]: InterfaceHandle = 0x81cafe80
Interface[0]: NumberOfPipes = 3
Interface[0]: Pipes[0] : MaximumPacketSize = 0x00000040
Interface[0]: Pipes[0] : EndpointAddress = 0x00000001
Interface[0]: Pipes[0] : Interval = 0x00000000
Interface[0]: Pipes[0] : PipeType = 0x00000002 (UsbdPipeTypeBulk)
Interface[0]: Pipes[0] : PipeHandle = 0x81cafe9c
Interface[0]: Pipes[0] : MaxTransferSize = 0x00010000
Interface[0]: Pipes[0] : PipeFlags = 0x00000000
Interface[0]: Pipes[1] : MaximumPacketSize = 0x00000040
Interface[0]: Pipes[1] : EndpointAddress = 0x00000082
Interface[0]: Pipes[1] : Interval = 0x00000000
Interface[0]: Pipes[1] : PipeType = 0x00000002 (UsbdPipeTypeBulk)
Interface[0]: Pipes[1] : PipeHandle = 0x81cafebc
Interface[0]: Pipes[1] : MaxTransferSize = 0x00010000
Interface[0]: Pipes[1] : PipeFlags = 0x00000000
Interface[0]: Pipes[2] : MaximumPacketSize = 0x00000040
Interface[0]: Pipes[2] : EndpointAddress = 0x00000003
Interface[0]: Pipes[2] : Interval = 0x00000000
Interface[0]: Pipes[2] : PipeType = 0x00000002 (UsbdPipeTypeBulk)
Interface[0]: Pipes[2] : PipeHandle = 0x81cafedc
Interface[0]: Pipes[2] : MaxTransferSize = 0x00010000
Interface[0]: Pipes[2] : PipeFlags = 0x00000000
[91 ms] UsbSnoop - DispatchAny(f8826610) : IRP_MJ_INTERNAL_DEVICE_CONTROL
[91 ms] UsbSnoop - MyDispatchInternalIOCTL(f8827e80) : fdo=81b680f0,
Irp=81b6fb40, IRQL=0
[91 ms] >>> URB 4 going down >>>
-- URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER:
PipeHandle = 81cafedc [endpoint 0x00000003]
TransferFlags = 00000002 (USBD_TRANSFER_DIRECTION_OUT,
USBD_SHORT_TRANSFER_OK)
TransferBufferLength = 00000009
TransferBuffer = f8975974
TransferBufferMDL = 00000000
00000000: 40 54 00 00 00 00 1e 00 01
UrbLink = 00000000
[91 ms] UsbSnoop - MyInternalIOCTLCompletion(f8827db0) : fido=00000000,
Irp=81b6fb40, Context=81c24278, IRQL=2
[91 ms] <<< URB 4 coming back <<<
-- URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER:
PipeHandle = 81cafedc [endpoint 0x00000003]
TransferFlags = 00000002 (USBD_TRANSFER_DIRECTION_OUT,
USBD_SHORT_TRANSFER_OK)
TransferBufferLength = 00000009
TransferBuffer = f8975974
TransferBufferMDL = 81af87a8
UrbLink = 00000000
[91 ms] UsbSnoop - DispatchAny(f8826610) : IRP_MJ_INTERNAL_DEVICE_CONTROL
[91 ms] UsbSnoop - MyDispatchInternalIOCTL(f8827e80) : fdo=81b680f0,
Irp=81b6fb40, IRQL=0
[91 ms] >>> URB 5 going down >>>
-- URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER:
PipeHandle = 81cafe9c [endpoint 0x00000001]
TransferFlags = 00000002 (USBD_TRANSFER_DIRECTION_OUT,
USBD_SHORT_TRANSFER_OK)
TransferBufferLength = 0000001e
TransferBuffer = f89759ac
TransferBufferMDL = 00000000
00000000: 00 dc 02 00 00 10 00 20 00 01 00 d3 02 00 00 10
00000010: 00 20 00 01 00 d5 02 00 00 10 00 10 00 00
UrbLink = 00000000
[92 ms] UsbSnoop - MyInternalIOCTLCompletion(f8827db0) : fido=00000000,
Irp=81b6fb40, Context=81abe400, IRQL=2
[92 ms] <<< URB 5 coming back <<<
-- URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER:
PipeHandle = 81cafe9c [endpoint 0x00000001]
TransferFlags = 00000002 (USBD_TRANSFER_DIRECTION_OUT,
USBD_SHORT_TRANSFER_OK)
TransferBufferLength = 0000001e
TransferBuffer = f89759ac
TransferBufferMDL = 81af87a8
UrbLink = 00000000
[92 ms] UsbSnoop - DispatchAny(f8826610) : IRP_MJ_PNP
(IRP_MN_QUERY_CAPABILITIES)
[92 ms] UsbSnoop - MyDispatchPNP(f8828ee0) : IRP_MJ_PNP
(IRP_MN_QUERY_CAPABILITIES)
[92 ms] UsbSnoop - DispatchAny(f8826610) : IRP_MJ_PNP
(IRP_MN_QUERY_PNP_DEVICE_STATE)
[92 ms] UsbSnoop - MyDispatchPNP(f8828ee0) : IRP_MJ_PNP
(IRP_MN_QUERY_PNP_DEVICE_STATE)
[92 ms] UsbSnoop - DispatchAny(f8826610) : IRP_MJ_PNP
(IRP_MN_QUERY_DEVICE_RELATIONS)
[92 ms] UsbSnoop - MyDispatchPNP(f8828ee0) : IRP_MJ_PNP
(IRP_MN_QUERY_DEVICE_RELATIONS)
[93 ms] UsbSnoop - DispatchAny(f8826610) : IRP_MJ_PNP
(IRP_MN_QUERY_CAPABILITIES)
[93 ms] UsbSnoop - MyDispatchPNP(f8828ee0) : IRP_MJ_PNP
(IRP_MN_QUERY_CAPABILITIES)
[93 ms] UsbSnoop - DispatchAny(f8826610) : IRP_MJ_PNP
(IRP_MN_QUERY_CAPABILITIES)
[93 ms] UsbSnoop - MyDispatchPNP(f8828ee0) : IRP_MJ_PNP
(IRP_MN_QUERY_CAPABILITIES)
[94 ms] UsbSnoop - DispatchAny(f8826610) : IRP_MJ_INTERNAL_DEVICE_CONTROL
[94 ms] UsbSnoop - MyDispatchInternalIOCTL(f8827e80) : fdo=81b680f0,
Irp=81ae0798, IRQL=0
[94 ms] >>> URB 6 going down >>>
-- URB_FUNCTION_VENDOR_DEVICE:
TransferFlags = 00000001 (USBD_TRANSFER_DIRECTION_IN,
~USBD_SHORT_TRANSFER_OK)
TransferBufferLength = 00000002
TransferBuffer = f5283d3c
TransferBufferMDL = 00000000
UrbLink = 00000000
RequestTypeReservedBits = 00000000
Request = 00000008
Value = 00000000
Index = 00000001
[95 ms] UsbSnoop - MyInternalIOCTLCompletion(f8827db0) : fido=00000000,
Irp=81ae0798, Context=81adb0a8, IRQL=2
[95 ms] <<< URB 6 coming back <<<
-- URB_FUNCTION_CONTROL_TRANSFER:
PipeHandle = 81b72c20
TransferFlags = 0000000b (USBD_TRANSFER_DIRECTION_IN,
USBD_SHORT_TRANSFER_OK)
TransferBufferLength = 00000002
TransferBuffer = f5283d3c
TransferBufferMDL = 81ae2c60
00000000: 80 01
UrbLink = 00000000
SetupPacket =
00000000: c0 08 00 00 01 00 02 00