From owner-freebsd-usb@FreeBSD.ORG Fri Feb 8 23:00:54 2013 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id E1435267 for ; Fri, 8 Feb 2013 23:00:54 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe08.c2i.net [212.247.154.226]) by mx1.freebsd.org (Postfix) with ESMTP id 6F12183B for ; Fri, 8 Feb 2013 23:00:53 +0000 (UTC) X-T2-Spam-Status: No, hits=-0.2 required=5.0 tests=ALL_TRUSTED, BAYES_50 Received: from [176.74.213.204] (account mc467741@c2i.net HELO laptop015.hselasky.homeunix.org) by mailfe08.swip.net (CommuniGate Pro SMTP 5.4.4) with ESMTPA id 377296742; Sat, 09 Feb 2013 00:00:46 +0100 From: Hans Petter Selasky To: freebsd-usb@freebsd.org Subject: Re: Reading 1024 bytes from mass storage device using 3 frames gives USB_ERR_STALLED Date: Sat, 9 Feb 2013 00:01:57 +0100 User-Agent: KMail/1.13.7 (FreeBSD/9.1-STABLE; KDE/4.8.4; amd64; ; ) References: <1360360082956-5785167.post@n5.nabble.com> In-Reply-To: <1360360082956-5785167.post@n5.nabble.com> X-Face: ?p&W)c(+80hU; '{.$5K+zq{oC6y| /D'an*6mw>j'f:eBsex\Gi, Cc: "aman.sawrup" X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Feb 2013 23:00:54 -0000 On Friday 08 February 2013 22:48:02 aman.sawrup wrote: > Hello, > > We have ported the FreeBSD USB stack to my employers proprietary RTOS. The > code was taken from the MAIN branch a little while after RELENG_8_BP tag > was created. > > I'm trying to read data from the following mass storage device umass0: > > ehci0: [FILTER+ITHREAD] > usbus0: EHCI version 1.0 > usbus0: 480Mbps High Speed USB v2.0 > ugen0.1: at usbus0 > uhub0: on usbus0 > uhub0: 2 ports with 2 removable, self powered > ugen0.2: at usbus0 > uhub1: on > usbus0 > uhub1: 8 ports with 8 removable, self powered > ugen0.3: at usbus0 > umass0: on > usbus0 > umass0: SCSI over Bulk-Only; quirks = 0x4800 > > Reading data one frame per transfer works. For example, if I want to read > 512 bytes that is physically contiguous and is placed in a single frame, > that works fine. > > However, when attempting to read 1024 bytes, that is not physically > contiguous, using 3 frames for the same transfer, I get USB_ERR_STALLED. I > have the frames setup as follows: > frame[0] = 200 bytes > frame[1] = 512 bytes > frame[2] = 312 bytes Hi, The frame lengths must be a multiple of the wMaxPacketSize (typically 64 or 512). Each frame is encoded like one or more USB packets independent of the next one. I.E. USB packet data may not cross a frame. This is not supported by the EHCI/OHCI and UHCI hardware, and the USB stack will not make a fixup buffer for this. The USB stack returns the device independent multiplier length for this purpose when calling usbd_xfer_max_framelen(). Only when (frame[n] % usbd_xfer_max_framelen() == 0) it will work like you want. --HPS