From owner-freebsd-usb@freebsd.org Fri Jun 26 11:51:59 2020 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 EFA093554E2 for ; Fri, 26 Jun 2020 11:51:59 +0000 (UTC) (envelope-from jbe-mlist@magnetkern.de) Received: from sapphire.magnetkern.de (sapphire.magnetkern.de [185.228.139.199]) by mx1.freebsd.org (Postfix) with ESMTP id 49tZxB6RwYz4VSr for ; Fri, 26 Jun 2020 11:51:58 +0000 (UTC) (envelope-from jbe-mlist@magnetkern.de) Received: from titanium (p5dd45c70.dip0.t-ipconnect.de [93.212.92.112]) by sapphire.magnetkern.de (Postfix) with ESMTPSA id 224F21516; Fri, 26 Jun 2020 11:51:52 +0000 (UTC) Date: Fri, 26 Jun 2020 13:51:51 +0200 From: Jan Behrens To: Hans Petter Selasky , CeDeROM Cc: "freebsd-usb@FreeBSD.org" Subject: Re: USB reset fails when using a LimeSDR Mini on FreeBSD Message-Id: <20200626135151.e5542cf97fad213c4ad661f2@magnetkern.de> In-Reply-To: <0ec3e5a3-7f31-d1cd-6862-6066c431aa80@selasky.org> References: <20200625121052.e9f7e7cbeb68fad264ec80a9@magnetkern.de> <20200625200849.6af81489a80c2f97d4f89ee6@magnetkern.de> <20200625224522.44d6584465cb6e20d17be320@magnetkern.de> <0ec3e5a3-7f31-d1cd-6862-6066c431aa80@selasky.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; amd64-portbld-freebsd12.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 49tZxB6RwYz4VSr X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of jbe-mlist@magnetkern.de designates 185.228.139.199 as permitted sender) smtp.mailfrom=jbe-mlist@magnetkern.de X-Spamd-Result: default: False [-1.93 / 15.00]; TO_DN_EQ_ADDR_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; MV_CASE(0.50)[]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[text/plain]; R_SPF_ALLOW(-0.20)[+mx]; DMARC_NA(0.00)[magnetkern.de]; NEURAL_HAM_LONG(-0.99)[-0.994]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_SHORT(-0.29)[-0.289]; NEURAL_HAM_MEDIUM(-0.95)[-0.947]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:197540, ipnet:185.228.136.0/22, country:DE]; RCVD_COUNT_TWO(0.00)[2]; MID_RHS_MATCH_FROM(0.00)[]; RECEIVED_SPAMHAUS_PBL(0.00)[93.212.92.112:received] X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Jun 2020 11:52:00 -0000 On Fri, 26 Jun 2020 10:58:20 +0200 Hans Petter Selasky wrote: > USB_ERR_IOERROR: Where did you get this error code from? I checked the error code returned in my case by modifying the source of the Lime Suite: { int status = libusb_reset_device(dev_handle); fprintf(stderr, "DEBUG status: %i\n", status); if (libusb_reset_device(dev_handle)!=0) return ReportError(-1, "USB reset failed", libusb_strerror(libusb_error(r))); } I got: DEBUG status: -99 Checking with libusb source, this seems to be LIBUSB_ERROR_OTHER: https://github.com/libusb/libusb/blob/e782eeb2514266f6738e242cdcb18e3ae1ed06fa/libusb/libusb.h#L1098 I figured out this error might (amongst other reasons) also be raised when there is an EACCES system error. As my /dev/usb/2.2.* devices were all owned by my user (using chown) and their ownership was not reset during testing, I tested what happens if I run the library calls with root privileges. I made the discovery that running the library as root works just fine! So maybe the problem is that calling libusb_reset_device attempts to recreate the /dev entries and has insufficient privileges? (Even though access rights for the individual files are granted.) Adding the entries Tomek (CeDeROM) proposed for granting privileges to the operator group (and being member of the group) didn't help either. > > This error code is carefully chosen to indicate that the USB device did > not respond at all to the USB set address command, which is mandatory to > implement. Likely the USB firmware on the device is not up and running, > or there is a timing issue or bug in the firmware. > > --HPS Nonetheless, there might be timing issues. In addition to the error returned by libusb_reset_device, I get a lot of: LIBUSB_FUNCTION: libusb_handle_events_timeout_completed enter LIBUSB_FUNCTION: libusb10_handle_events_sub enter LIBUSB_FUNCTION: libusb_handle_events_timeout_completed enter LIBUSB_FUNCTION: libusb10_handle_events_sub enter [...] See also my original post on the myriadrf.org Forum, with a full error output: https://discourse.myriadrf.org/t/limesdr-mini-with-freebsd/6230 Regards, Jan Behrens