From nobody Tue Oct 11 04:18:57 2022 X-Original-To: freebsd-usb@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MmjX765VQz4dpmH for ; Tue, 11 Oct 2022 04:31:03 +0000 (UTC) (envelope-from darius@dons.net.au) Received: from midget.dons.net.au (2403-5800-5200-4700-225-90ff-fe47-39b4.ip6.aussiebb.net [IPv6:2403:5800:5200:4700:225:90ff:fe47:39b4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "dons.net.au", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MmjX54hzSz41hp for ; Tue, 11 Oct 2022 04:31:01 +0000 (UTC) (envelope-from darius@dons.net.au) Received: from midget.dons.net.au (localhost [127.0.0.1]) by midget.dons.net.au (8.17.1/8.16.1) with ESMTPS id 29B4JSob036889 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO) for ; Tue, 11 Oct 2022 14:49:28 +1030 (ACDT) (envelope-from darius@dons.net.au) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dons.net.au; s=default; t=1665461976; bh=47eaAyWfdINHRN98I20DoA0pptFiaHKHvRREbrPdqUE=; h=From:Date:Subject:To; b=juuHHsyVvdaB6HXM39lr7nWzoTq+Aq0F4UZVGFAPB5kRTpd0e75vsSO66phIqy+4/ rwlE02KQ3NB7kpUi3PB5+UD6jYyjlkqcT/eVYSBmhVfKp1dJf8WBnrgbSIlqC2n3GR 0MSUNk7in7o5jvFs8BfrUEbUnHl32x0d586bxNpU= Received: (from mailnull@localhost) by midget.dons.net.au (8.17.1/8.16.1/Submit) id 29B4J8gZ036880 for ; Tue, 11 Oct 2022 14:49:08 +1030 (ACDT) (envelope-from darius@dons.net.au) X-MIMEDefang-Relay-a1a524833438212bf543e143edafb27bc4d2c346: 2001:44b8:1d2:8900:4956:5e6c:403d:275f Received: from smtpclient.apple ([IPv6:2001:44b8:1d2:8900:4956:5e6c:403d:275f] [2001:44b8:1d2:8900:4956:5e6c:403d:275f]) by 2403-5800-5200-4700-225-90ff-fe47-39b4.ip6.aussiebb.net (envelope-sender ) (MIMEDefang) with ESMTP id 29B4J2ZB036875; Tue, 11 Oct 2022 14:49:08 +1030 From: "Daniel O'Connor" Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable List-Id: FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-usb List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-usb@freebsd.org X-BeenThere: freebsd-usb@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Date: Tue, 11 Oct 2022 14:48:57 +1030 Subject: Failed control transfer Message-Id: <7FF9CB5C-26B0-4DBA-B7E4-80DBF50A80BB@dons.net.au> To: freebsd-usb@freebsd.org X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: 1.3 (*) No, score=1.3 required=5.0 tests=RDNS_NONE,SPF_HELO_NONE, T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.5 X-Scanned-By: MIMEDefang 2.84 on 10.0.2.1 X-Rspamd-Queue-Id: 4MmjX54hzSz41hp X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=dons.net.au header.s=default header.b=juuHHsyV; dmarc=pass (policy=quarantine) header.from=dons.net.au; spf=pass (mx1.freebsd.org: domain of darius@dons.net.au designates 2403:5800:5200:4700:225:90ff:fe47:39b4 as permitted sender) smtp.mailfrom=darius@dons.net.au X-Spamd-Result: default: False [-3.50 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; DMARC_POLICY_ALLOW(-0.50)[dons.net.au,quarantine]; MV_CASE(0.50)[]; R_SPF_ALLOW(-0.20)[+mx]; R_DKIM_ALLOW(-0.20)[dons.net.au:s=default]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; MLMMJ_DEST(0.00)[freebsd-usb@freebsd.org]; DKIM_TRACE(0.00)[dons.net.au:+]; ARC_NA(0.00)[]; ASN(0.00)[asn:4764, ipnet:2403:5800::/32, country:AU]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; PREVIOUSLY_DELIVERED(0.00)[freebsd-usb@freebsd.org]; MID_RHS_MATCH_FROM(0.00)[] X-ThisMailContainsUnwantedMimeParts: N Hi, I am trying to fix a bug in xc3sprog whereby it can't read the hardware = ID (serial number) from the Xilinx programming tool. It works fine on MacOS and Linux but on FreBSD it fails with ENODEV, = eg.. In [1]: import usb.core In [2]: d =3D usb.core.find(idVendor =3D 0x03fd, idProduct =3D 0x0008) In [4]: d.ctrl_transfer(0xc0, 176, 0x42, 0, 8, 1000) = --------------------------------------------------------------------------= - USBError Traceback (most recent call = last) USBError: [Errno 19] No device Other control commands work fine: In [5]: d.ctrl_transfer(0xc0, 176, 0x50, 258, 2, 100) Out[5]: array('B', [5, 0]) On MacOS it looks like: In [4]: d.ctrl_transfer(0xc0, 176, 0x42, 0, 8, 1000) Out[4]: array('B', [1, 191, 125, 103, 18, 0, 0, 140]) (I did the tests in Python as it's easier for isolation) Also, the device works fine for programming FPGAs and the like so it = seems quite peculiar that only this command fails. I had a dig through the USB kernel stack and libusb code (the Python = code is using libusb.so.3 FWIW) but I could not find anywhere relevant = that set errno to ENODEV. Output of sudo usbdump -d 0.4 -s 65535 -v -v: 04:15:17.243800 usbus0.4 = SUBM-CTRL-EP=3D00000080,SPD=3DHIGH,NFR=3D2,SLEN=3D8,IVAL=3D0 frame[0] WRITE 8 bytes 0000 C0 B0 42 00 00 00 08 00 -- -- -- -- -- -- -- -- |..B..... = | frame[1] READ 8 bytes flags 0x2 04:15:17.246029 usbus0.4 = DONE-CTRL-EP=3D00000080,SPD=3DHIGH,NFR=3D2,SLEN=3D0,IVAL=3D0,ERR=3DSTALLED= frame[0] WRITE 8 bytes frame[1] READ 0 bytes flags 0x2 I ran usbmon on Linux and this is the Wireshark output of the request: Frame 13: 64 bytes on wire (512 bits), 64 bytes captured (512 bits) USB URB [Source: host] [Destination: 1.5.0] URB id: 0xffff9d9103b47440 URB type: URB_SUBMIT ('S') URB transfer type: URB_CONTROL (0x02) Endpoint: 0x80, Direction: IN Device: 5 URB bus id: 1 Device setup request: relevant ('\0') Data: not present ('<') URB sec: 1665455649 URB usec: 867346 URB status: Operation now in progress (-EINPROGRESS) (-115) URB length [bytes]: 8 Data length [bytes]: 0 [Response in: 14] Interval: 0 Start frame: 0 Copy of Transfer Flags: 0x00000200, Dir IN Number of ISO descriptors: 0 [bInterfaceClass: Unknown (0xffff)] Setup Data bmRequestType: 0xc0 bRequest: 176 wValue: 0x0042 wIndex: 0 (0x0000) wLength: 8 And the reply: Frame 14: 72 bytes on wire (576 bits), 72 bytes captured (576 bits) USB URB [Source: 1.5.0] [Destination: host] URB id: 0xffff9d9103b47440 URB type: URB_COMPLETE ('C') URB transfer type: URB_CONTROL (0x02) Endpoint: 0x80, Direction: IN Device: 5 URB bus id: 1 Device setup request: not relevant ('-') Data: present ('\0') URB sec: 1665455649 URB usec: 879077 URB status: Success (0) URB length [bytes]: 8 Data length [bytes]: 8 [Request in: 13] [Time from request: 0.011731000 seconds] Unused Setup Header Interval: 0 Start frame: 0 Copy of Transfer Flags: 0x00000200, Dir IN Number of ISO descriptors: 0 [bInterfaceClass: Unknown (0xffff)] CONTROL response data: 01bf7d671200008c Unfortunately I can't find any reason why it works on MacOS and Linux = but not FreeBSD.. Does anyone have any suggestions? Thanks. -- Daniel O'Connor "The nice thing about standards is that there are so many of them to choose from." -- Andrew Tanenbaum