Tiny Core Linux

Tiny Core Base => Raspberry Pi => Topic started by: kkrpeq on April 13, 2022, 08:49:01 PM

Title: libusb not showing devices
Post by: kkrpeq on April 13, 2022, 08:49:01 PM
Hello,

I am trying to use piCore on a RPi 02W to perform usb communication with an usb 2.0 device.
However, libusb was not able to find any device I connected to the RPi. The output of "sudo lsusb" shows only the built in usb hub,  and not my device:

Protocol spec without prior Class and Subclass spec at line 23179
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

"sudo lsusb -t" and "dmesg" also show only the hub.

Am I missing something?
Title: Re: libusb not showing devices
Post by: curaga on April 14, 2022, 02:19:09 AM
No, any drivers missing would not affect lsusb or dmesg. You have a physical problem with the connection, power, or usb device.
Title: Re: libusb not showing devices
Post by: kkrpeq on April 15, 2022, 12:58:28 AM
I have been doing some tests with two usb devices, namely DeviceA and DeviceB. I know they both work because I can use them on Mac and Windows.

If I plug in DeviceA, the RPi recognizes it as expected, and the device works properly.
If I plug in DeviceB, the RPi stops recognizing usb devices. Even if I remove DeviceB and insert DeviceA, it will not recognize anything.

Upon further inspection, it seems the RPi is cutting off the power to the usb devices whenever I insert (or try to use) DeviceB. I am verifying this by using this command:

Code: [Select]
cat /sys/devices/platform/soc/3f980000.usb/buspower
Bus Power = 0x0

I can turn the power on by writing 0x1 to buspower:

Code: [Select]
echo 0x1 > /sys/devices/platform/soc/3f980000.usb/buspower
But it will turn off again if DeviceB is connected.
I have tried using an external/exclusive power supply for DeviceB, but it still didn't work.
Is there any option in config.txt, bootcode, or something similar that might help?
Title: Re: libusb not showing devices
Post by: Rich on April 15, 2022, 01:28:21 AM
Hi kkrpeq
... I have tried using an external/exclusive power supply for DeviceB, but it still didn't work. ...
Not sure what you mean by that.

Try placing a powered hub between  DeviceB  and your  RPi .
Title: Re: libusb not showing devices
Post by: kkrpeq on April 15, 2022, 01:58:38 AM
... I have tried using an external/exclusive power supply for DeviceB, but it still didn't work. ...
Not sure what you mean by that.

I used an usb adapter that has an auxiliary power inlet. The +5V supplied to the usb device does not come from the RPi, instead it comes from another power supply.
It is like a powered hub, but without the "hub" part. Here is a picture of the adapter:

(https://www.audiophonics.fr/33078-large_default/cable-usb-a-femelle-vers-micro-usb-male-avec-entree-alimentation-auxiliaire.jpg)

Try placing a powered hub between  DeviceB  and your  RPi .

I just tried using an actual powered hub. Strangely enough, the hub shows the same behaviour as DeviceB: when I connect the hub to the RPi (even if the hub has no devices connected to it), Bus Power is automatically set to 0x0.
Title: Re: libusb not showing devices
Post by: curaga on April 15, 2022, 02:51:31 AM
edit: Seems your rpi's usb could be broken, if the hub alone shows the same behavior. Try another rpi?
Title: Re: libusb not showing devices
Post by: kkrpeq on April 15, 2022, 04:18:36 AM
I added dwc_otg.speed=1 at the end of my cmdline.txt, and now DeviceB is being detected by lsusb. Also, Bus Power was not automatically set to 0x0.
However this parameter limits the usb speed to only 12Mbps, while usb 2.0 can do up to 480Mbps.
Maybe there is a better solution?

References:

https://raspberrypi.stackexchange.com/questions/1886/what-kernel-parameters-are-available-for-fixing-usb-problems

https://www.cl.cam.ac.uk/~atm26/ephemeral/rpi/dwc_otg/doc/html/module%20parameters.html
Title: Re: libusb not showing devices
Post by: gadget42 on April 15, 2022, 06:23:49 AM
interesting...good to know...you would think they would have fixed it after so many years...

post from 2020:
https://forums.raspberrypi.com/viewtopic.php?t=262852

post from 2014:
https://ludovicrousseau.blogspot.com/2014/04/usb-issues-with-raspberry-pi.html

post from 2012:
https://raspberrypi.stackexchange.com/questions/1886/what-kernel-parameters-are-available-for-fixing-usb-problems

perhaps for some rest period viewing:
https://www.youtube.com/watch?v=4PoWAsBOsFs
and/or:
https://www.youtube.com/watch?v=613yEF6SrNo

sharing is caring
Title: Re: libusb not showing devices
Post by: kkrpeq on April 16, 2022, 01:53:19 AM
What bugs me the most is that I got DeviceB working on Raspberry OS a few times before, so I thought the problem was a tiny core issue.
But now I tried Raspberry OS again and it shows the same problem.
While setting dwc_otg.speed=1 succeeded in making DeviceB recognizable by lsusb, I am having errors when performing bulk transfers.  :(
Title: Re: libusb not showing devices
Post by: Rich on April 16, 2022, 10:43:31 AM
Hi kkrpeq
I sounds like it may be a power supply issue for the RPi. It could be the power supply is failing and no longer providing
a stable output. Or maybe something on the RPi changed causing it to pull more current than it used to.

Try reducing the power consumption by lowering the CPU frequency. Then see if the USB system behaves any better.

Install cpupower.tcz:
Code: [Select]
tce-load -wi cpupower
Then:
Check the info:
Code: [Select]
cpupower frequency-info
Set the governor to userspace so that we can set the frequency:
Code: [Select]
sudo cpupower frequency-set --governor userspace
Set the maximum frequency:
Code: [Select]
sudo cpupower frequency-set --max 600MHz
Check the info:
Code: [Select]
cpupower frequency-info.It should say: "Current policy: frequency should be within 600 MHz and 600 MHz."

Found here:
https://raspberrypi.stackexchange.com/a/133666

Title: Re: libusb not showing devices
Post by: kkrpeq on April 16, 2022, 05:46:42 PM
Without changing any setting, I tried it again with tiny core and the powered hub, and now it worked. I changed only the way the cables are connected maybe? Indeed it looks like a hardware/circuitry/power issue.

Try reducing the power consumption by lowering the CPU frequency. Then see if the USB system behaves any better.

Thanks for the tutorial. I can see the message "Current policy: frequency should be within 600 MHz and 600 MHz", however DeviceB still isn't recognized when I connect it directly to the RPi.
Title: Re: libusb not showing devices
Post by: Rich on April 16, 2022, 07:45:58 PM
Hi kkrpeq
... I changed only the way the cables are connected maybe? ...
I looked up the specs for the  RPi 02W.  It lists 2 micro USB ports. One is used to power up the RPi, the other is for
data transfers. They are not interchangeable.

Also, the powered hub should have it's own power supply, separate from the one powering the RPi.
Title: Re: libusb not showing devices
Post by: Paul_123 on April 17, 2022, 08:30:23 PM
The bulk transfer issue is likely something completely different.  With exception of the rpi4 , all rpi boards suffer from a usb flaw.

I would try this on command line.

dwc_otg.fiq_fsm_mask=0xF dwc_otg.lpm_enable=0

Title: Re: libusb not showing devices
Post by: patrikg on April 18, 2022, 02:26:09 AM
Isn't the flaw that the usb control circuit shares the same circuit with the ethernet.
So my hypothesis is, if you have a raspberry pi without the ethernet it should be fine.
Title: Re: libusb not showing devices
Post by: Paul_123 on April 18, 2022, 06:42:54 AM
No,  the flaw is in the usb design.  The flaw is accentuated if you have high Ethernet throughput and usb throughout.

Without The FIQ handler, even a keyboard connected to usb can be glitchy.
Title: Re: libusb not showing devices
Post by: gadget42 on April 18, 2022, 10:21:50 AM
additional information from searching the web for "dwc_otg.fiq_fsm_mask=0xF dwc_otg.lpm_enable=0"
https://raspberrypi.stackexchange.com/questions/1886/what-kernel-parameters-are-available-for-fixing-usb-problems
https://forums.raspberrypi.com/viewtopic.php?t=70437&start=225
Title: Re: libusb not showing devices
Post by: kkrpeq on May 02, 2022, 08:38:20 PM
I have tried a bunch of different bootcodes, but none worked.
What did work was shortening the USB cable of DeviceB. Although the original cable length was within the specs of USB 2.0, I suppose the USB controller in the Pi needs a very clean signal to work properly, and the controller could not handle the signal noise and loss induced by the cable. In this sense, the USB hub acts as a "repeater", "cleaning" the digital signal.
Title: Re: libusb not showing devices
Post by: Rich on May 02, 2022, 09:03:22 PM
Hi kkrpeq
... What did work was shortening the USB cable of DeviceB. Although the original cable length was within the specs of USB 2.0, ...
It may just have been a defective cable.