Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 27 Jun 2020 14:44:19 +0200
From:      Jan Behrens <jbe-mlist@magnetkern.de>
To:        Tomasz CEDRO <tomek@cedro.info>
Cc:        Hans Petter Selasky <hps@selasky.org>, CeDeROM <cederom@tlen.pl>, "freebsd-usb@FreeBSD.org" <freebsd-usb@freebsd.org>
Subject:   Re: USB reset fails when using a LimeSDR Mini on FreeBSD
Message-ID:  <20200627144419.f14371695d9b62ea99106c4a@magnetkern.de>
In-Reply-To: <CAM8r67AF%2BfGiqBr9A0863Za_zR-fG1FxGfNAqEvvafW=wTRmyQ@mail.gmail.com>
References:  <20200625121052.e9f7e7cbeb68fad264ec80a9@magnetkern.de> <CAM8r67DFFeFCHMh6mAxw=x2LKYnFGwasOLgceo-EQSMOvMHbeg@mail.gmail.com> <20200625200849.6af81489a80c2f97d4f89ee6@magnetkern.de> <CAM8r67AE1K9AK%2BaL4RCn6_BWajvzKO7K99bYZMdH0mr-HQdyGw@mail.gmail.com> <20200625224522.44d6584465cb6e20d17be320@magnetkern.de> <0ec3e5a3-7f31-d1cd-6862-6066c431aa80@selasky.org> <20200626135151.e5542cf97fad213c4ad661f2@magnetkern.de> <5c0729f9-9e98-52f7-a5cb-6c5dfd2287a3@selasky.org> <20200626172851.872f3a08fa6e632666683230@magnetkern.de> <CAM8r67AF%2BfGiqBr9A0863Za_zR-fG1FxGfNAqEvvafW=wTRmyQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 26 Jun 2020 17:56:14 +0200
Tomasz CEDRO <tomek@cedro.info> wrote:

> pt., 26 cze 2020, 17:28 użytkownik Jan Behrens <jbe-mlist@magnetkern.de>
> napisał:
> 
> > Does this mean that depending on the device, it will either be a
> > no-operation or a re-enumeration, and in the latter case, root
> > privileges are required, otherwise not?
> >
> > Or did you mean that if you are non-root, it will/should always be a
> > no-operation?
> >
> 
> I guess that root is required for some administrative operations like port
> reset etc that are not really possible to achieve even through /dev/usb*
> permissions.

The question is: Is it correct or wise to return an error status of -99
(LIBUSB_ERROR_OTHER) when the function is called as non-root? Maybe
it's possible to return a more fitting error code? Also note that the
debug level was set to 3, and there was still no hint written to stderr
about any privilege problem:

#if LIBUSBX_API_VERSION < 0x01000106
    libusb_set_debug(ctx, 3); //set verbosity level to 3, as suggested in the documentation
#else
    libusb_set_option(ctx, LIBUSB_OPTION_LOG_LEVEL, 3); //set verbosity level to 3, as suggested in the documentation
#endif

Source: https://github.com/myriadrf/LimeSuite/blob/1c1c202f9a6ae4bb34068b6f3f576f7f8e74c7f1/src/ConnectionFTDI/ConnectionFT601Entry.cpp#L40

> 
> When in trouble always try to test at root especially when working with
> hardware. That may pinpoint the permissions issuses (not only /dev/usb*
> permissions).

You are right, of course. As "chown user /dev/usb/2.2.*" made a
difference (and there wasn't any hint about a privilege problem), I
wrongly assumed that it was not a privilege problem. I'll know better
next time.

Another question that I still have no clear answer to is: Is it
semantically correct to use libusb_reset_device() in the Lime Suite
driver for SoapySDR. The driver runs in the context of user
applications which likely have no root privileges (for a good reason).
I also don't know yet why this library call is made in the driver, and
which purpose it has. See also my most recent post on the myriadrf.org
discussion forum:

https://discourse.myriadrf.org/t/limesdr-mini-with-freebsd/6230/8

I wrote:

"I wonder if FreeBSD’s libusb should (and/or could) be fixed to ensure
libusb_reset_device() can be run as non-root user, or if the Lime Suite
should be fixed to not call libusb_reset_device() at all because it
might be an administrative call that should never be used by a user of
a USB device. I’m not sure what’s right to do. Particularly, I don’t
know why the Lime Suite developers included that call, and I don’t even
fully understand (yet) what it does."

> 
> > What I don't understand is that the Lime Suite SoapySDR module seems to
> > work fine on Linux and other operating systems but makes trouble with
> > FreeBSD. Is it a FreeBSD specific thing that libusb_reset_device()
> > fails if called as non-root?
> >
> 
> Linux as well as other operating systems usually uses dirty and quick
> hacks. FreeBSD treats standards seriously and usually does not have these
> kind of dirty hacks. This is the first difference. Second difference is
> that FreeBSD has its own implementation of LibUSB. There may be a problem
> here bu that would require detailed investigation and proofs. Very nice
> exercise to perform :-

I also prefer to have things implemented cleanly instead of fixing
problems in the wrong place with dirty methods. That is why I would
like to understand if calling libusb_reset_device() is semantically
correct or a wrong thing to do in the LimeSDR (Mini) driver.

> 
> > I could give recommendation to the Lime Suite developers to remove the
> > libusb_reset_device() call on FreeBSD systems if it is not neccessary.
> > However, I would like to understand why it is called and what's its
> > usual purpose, and if there are side effects when removing the call, or
> > whether the call should/could be replaced by a different call that
> > "only" requires device privileges. Also: Why does this work on Linux
> > but fails on FreeBSD? Is the API differently defined?
> 
> 
> Very good approach to understand what is the problem and fix it rarher than
> using dirty hacks just to make things work :-)
> 
> What particular LimeSDR device do you have? Is it expensive? Can you share
> a spare one for testing? Can you acquire access to hardware USB sniffer?

The device I have here for testing isn't mine, so it would be difficult
to mail it. It is the "LimeSDR Mini". I asked on the myriadrf.org Forum
if the manufacturer could provide a free sample for testing. If that
doesn't work, I could also ask friends, but eventually I want to get
one (or two) for myself anyway.

The LimeSDR and LimeSDR Mini seem to have better electrical/radio
characteristics than other available devices. Compared to the Pluto
SDR, the LimeSDR (Mini) comes with better frequency stability out of
the box, i.e. doesn't need to be modded. The LimeSDR also works on
lower frequency bands while the Pluto SDR does not. For my purposes
(general experimenting, trying to do ham radio satellite operation,
operation on different ham radio bands, etc.), the LimeSDR (Mini) seems
to be an awesome device, which is why I would really like if it was
supported by FreeBSD.

> 
> Best regards :-)
> Tomek
> 
> --
> CeDeROM, SQ7MHZ, http://www.tomek.cedro.info

Regards,
Jan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20200627144419.f14371695d9b62ea99106c4a>