From owner-freebsd-usb@freebsd.org Fri Dec 20 13:26:53 2019 Return-Path: Delivered-To: freebsd-usb@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 344F31D9CD4 for ; Fri, 20 Dec 2019 13:26:53 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [IPv6:2a01:4f8:c17:6c4b::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 47fTzw1mbkz3y9W for ; Fri, 20 Dec 2019 13:26:51 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2016.home.selasky.org (unknown [62.141.129.235]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 170B5260300; Fri, 20 Dec 2019 14:25:48 +0100 (CET) Subject: Re: Timeouts during initial Mode Sense commands To: denverh@comcast.net, freebsd-usb@freebsd.org References: <98b6599e-5027-48c9-4230-47bc0f087180@comcast.net> From: Hans Petter Selasky Message-ID: Date: Fri, 20 Dec 2019 14:23:40 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:68.0) Gecko/20100101 Thunderbird/68.1.2 MIME-Version: 1.0 In-Reply-To: <98b6599e-5027-48c9-4230-47bc0f087180@comcast.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 47fTzw1mbkz3y9W X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of hps@selasky.org designates 2a01:4f8:c17:6c4b::2 as permitted sender) smtp.mailfrom=hps@selasky.org X-Spamd-Result: default: False [-4.94 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+a:mail.turbocat.net]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; DMARC_NA(0.00)[selasky.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; IP_SCORE(-2.64)[ip: (-9.19), ipnet: 2a01:4f8::/29(-2.44), asn: 24940(-1.56), country: DE(-0.02)]; FREEMAIL_TO(0.00)[comcast.net]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:24940, ipnet:2a01:4f8::/29, country:DE]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Dec 2019 13:26:53 -0000 On 2019-12-20 13:54, Denver Hull wrote: > Hans Petter Selasky wrote: >> On 2019-12-19 01:11, Denver Hull wrote: >>> Hello, >>> >>> I have several different microcontroller boards that are supposed to >>> appear as storage devices when plugged in.  They work fine on Linux >>> systems, but on FreeBSD 11.3 and 12.1 they don't show up at all. >>> Here's what dmesg shows for one of them: >>> >>> ugen1.3: at usbus1 >>> umodem0 on uhub1 >>> umodem0: on usbus1 >>> umodem0: data interface 1, has no CM over data, has no break >>> umass3 on uhub1 >>> umass3: on usbus1 >>> umass3:  SCSI over Bulk-Only; quirks = 0x0000 >>> umass3:5:3: Attached to scbus5 >>> uaudio0 on uhub1 >>> uaudio0: on usbus1 >>> uaudio0: No playback. >>> uaudio0: No recording. >>> uaudio0: MIDI sequencer. >>> uaudio0: No HID volume keys found. >>> ums2 on uhub1 >>> ums2: on usbus1 >>> ums2: 16 buttons and [XYZ] coordinates ID=2 >>> (da3:umass-sim3:3:0:0): got CAM status 0x44 >>> (da3:umass-sim3:3:0:0): fatal error, failed to attach to device >>> g_access(944): provider da3 has error 6 set >>> g_access(944): provider da3 has error 6 set >>> g_access(944): provider da3 has error 6 set >>> g_access(944): provider da3 has error 6 set >>> g_access(944): provider da3 has error 6 set >>> >>> There's a definite delay after the last ums message.  I used >>> camcontrol debug in single user mode on a bare 12.1 system to get a >>> little more information about what was happening.  It looks like the >>> initial Inquiry and Test Unit Ready commands succeed, but the next >>> Mode Sense command times out, as well as all subsequent commands. >>> There are several seconds of inactivity between retries, and there's >>> no sense data, so I'm assuming that indicates timeout. >>> >>> At this point I'm not sure how best to proceed to get these devices >>> to work, so any help will be appreciated. >>> >> >> Did you try setting one or more quirks for these devices using usbconfig? >> >> UQ_MSC_NO_TEST_UNIT_READY >> UQ_MSC_NO_RS_CLEAR_UA >> UQ_MSC_NO_START_STOP >> UQ_MSC_NO_GETMAXLUN >> UQ_MSC_NO_INQUIRY >> UQ_MSC_NO_INQUIRY_EVPD >> UQ_MSC_NO_PREVENT_ALLOW >> UQ_MSC_NO_SYNC_CACHE >> UQ_MSC_SHUTTLE_INIT >> UQ_MSC_ALT_IFACE_1 >> UQ_MSC_FLOPPY_SPEED >> UQ_MSC_IGNORE_RESIDUE >> UQ_MSC_WRONG_CSWSIG >> UQ_MSC_RBC_PAD_TO_12 >> UQ_MSC_READ_CAP_OFFBY1 >> UQ_MSC_FORCE_SHORT_INQ >> >> If you run "usbdump -i usbusX -f Y -s 65536 -vvv" you might see the >> last failing SCSI command. X.Y are numbers after ugen for your device. >> >> Likely your device has a software bug in its USB/SCSI implementation, >> which is quite common unfortunately. >> >> --HPS >> > After I sent the previous message I did try UQ_MSC_NO_TEST_UNIT_READY. > Although the system reports "quirks = 0001", the initial TUR is still > being issued during the probe sequence.  I tried the usbdump command you > suggested, and I can clearly see where the timeouts are, and frames that > begin with "USBC" seem to contain a SCSI CDB.  But there's a lot of > other stuff in between that I haven't been able to figure out, so I've > attached a sample.  Hopefully it will help. > Hi, All the USBC's are raw SCSI commands, which use the following layout: > /* Command Block Wrapper */ > typedef struct { > uDWord dCBWSignature; > #define CBWSIGNATURE 0x43425355 > uDWord dCBWTag; > uDWord dCBWDataTransferLength; > uByte bCBWFlags; > #define CBWFLAGS_OUT 0x00 > #define CBWFLAGS_IN 0x80 > uByte bCBWLUN; > uByte bCDBLength; > #define CBWCDBLENGTH 16 > uByte CBWCDB[CBWCDBLENGTH]; > } __packed umass_bbb_cbw_t; We had a SoC to add support for the usbdump format to wireshark: https://wiki.freebsd.org/SummerOfCode2017/usbdump-wireshark You might find that useful. My first suspicion is that your device is not fully USB class compliant, and that's why it is STALLING and failing to recover. --HPS