Re: Interoperability problem with g_file_storage.

Alan Stern <[email protected]>
Newsgroups gmane.linux.usb.user
Message-ID <[email protected]>
On Fri, 24 Aug 2007, Samuel Hangouët wrote:

> Hi,
> 
> I'm currently using the driver g_file_storage on a gumstix product (see 
> http://gumstix.org).
> 
> This driver works fine when the option stall=N is set.
> 
> However, I encountered a problem when I plug it in a JVC micro HiFi.
> 
> With debug mode enabled, g_file_storage prints the following message in 
> kernel log:
> 
> 
>  g_file_storage gadget: bulk-out, length 31:
>       0:  55 53 42 43 03 00 00 00  12 00 00 00 80 00 05 03
>      10:  00 00 00 12 00 00 00 10  00 00 00 00 00 00 00
>  g_file_storage gadget: non-meaningful CBW: lun = 0, flags = 0x80, cmdlen 5
> 
> (see full log at the end of this email)
> 
> In the command send by the HiFi equipment, the length of the CBWCB is 
> equal to 5,
> which makes g_file_storage module reject the message in file_storage.c 
> at line 3009 :
> 
>         /* Is the CBW meaningful? */
>         if (cbw->Lun >= MAX_LUNS || cbw->Flags & ~USB_BULK_IN_FLAG ||
>                         cbw->Length < 6 || cbw->Length > MAX_COMMAND_SIZE) {
>                 DBG(fsg, "non-meaningful CBW: lun = %u, flags = 0x%x, "
>                                 "cmdlen %u\n",
>                                 cbw->Lun, cbw->Flags, cbw->Length);
> 
> I wonder why there is a 6 in here.
> 
> Indeed, the BBB Mass-Storage standard specifies:
> 
> """
> bCBWCBLength:
>    The valid length of the CBWCB in bytes. This defines the valid length 
> of the command block. The
>    only legal values are 1 through 16 (01h through 10h). All other 
> values are reserved.
> """

You looked at the wrong part of the standard.  6.2.2 defines when the 
CBW is meaningful; the third requirement is:

	Both bCBWCBLength and the content of the CBWCB are in
	accordance with bInterfaceSubClass.

In this case the relevant standard is SCSI SPC-2.  It includes the 
definition of the REQUEST SENSE command, and the definition says that 
the command length is 6 bytes, not 5.  In fact, none of the commands 
accepted by g_file_storage have length < 6.

> and if I replaced this 6 by 1, everything works fine.

Really?  It should failed this test in check_command():

	/* Verify the length of the command itself */
	if (cmnd_size != fsg->cmnd_size) {

		/* Special case workaround: MS-Windows issues REQUEST SENSE
		 * with cbw->Length == 12 (it should be 6). */
		if (fsg->cmnd[0] == SC_REQUEST_SENSE && fsg->cmnd_size == 12)
			cmnd_size = fsg->cmnd_size;
		else {
			fsg->phase_error = 1;
			return -EINVAL;
		}
	}

Here cmnd_size would be 6 and fsg->cmnd_size would be 5.

Alan Stern


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.