R.E.
Posts: 9
Joined: Thu Sep 23, 2021 1:31 am

USB device requires unplugging and re-plugging to make it work after reboot.

Fri Sep 24, 2021 9:38 pm

I am trying to get a device called ThingMagic USB Pro UHF Reader to work properly with a Raspberry Pi 4. For the most part, everything works perfectly fine, until I reboot or turn on / off the Pi, at that point, the device in no longer recognized and I must unplug and re-plug it in order to get it to work again.

Please note that someone else doing the same thing with a Raspberry Pi 3 said that the Pi 3 works perfectly fine, so this appears to be an issue with the Pi 4. I am new to Linux / Raspberry Pi so I have no idea what I am doing, however below is some information that I hope will help troubleshoot the issue.

On the snippet below, the first lsusb command was issued after I rebooted the Pi, the second lsusb command was issued after I unplugged and re-plugged the ThinggMagic device:

Code: Select all

pi@raspberrypi:~ $ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 007: ID 413c:2003 Dell Computer Corp. Keyboard
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
pi@raspberrypi:~ $ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 007: ID 413c:2003 Dell Computer Corp. Keyboard
Bus 001 Device 008: ID 2008:1004  
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

So basically, it looks like the ThingMagic device is recognized as: Bus 001 Device 008: ID 2008:1004

When I connect to the ThingMagic device via code (using .NET C#), I have to supply the following string to the connection command: /dev/ttyACM0

Some more info:

Code: Select all

pi@raspberrypi:~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL=http://www.raspbian.org/RaspbianBugs

Could someone please help me to try to get the ThingMagic device to work after I reboot or turn on / off the Pi in a way that I am not required to unplug and re-plug the ThingMagic device?

Thank you.

User avatar
HawaiianPi
Posts: 6527
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: USB device requires unplugging and re-plugging to make it work after reboot.

Fri Sep 24, 2021 10:32 pm

The Pi4 powers off its USB-A ports when restarting and that may affect the operation of some USB devices. You can add an additional parameter to the bootloader configuration to either change the time, or eliminate the USB port power off altogether.

Add USB_MSD_PWR_OFF_TIME=0 to your bootloader configuration to eliminate power off on reboots, or change the time to a shorter or longer value and see if it helps. I believe the default is 1000 and the value is milliseconds (1000ms = 1 second).

After making the changes your bootloader configuration should look like this (assuming all else is default).

Code: Select all

$ rpi-eeprom-config
[all]
BOOT_UART=0
WAKE_ON_GPIO=1
POWER_OFF_ON_HALT=0
USB_MSD_PWR_OFF_TIME=0
With the value of '0' replaced with whatever you chose.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups, and where is that annoying music coming from?

R.E.
Posts: 9
Joined: Thu Sep 23, 2021 1:31 am

Re: USB device requires unplugging and re-plugging to make it work after reboot.

Sat Sep 25, 2021 1:00 am

Thanks for your help, unfortunately the suggestion did not work, setting the value to the min value (zero) or the max value (5000) had no effect.

Given that the ThingMagic device works just fine on a Pi 3, does it means that there is a bug in the Pi 4? If yes, were can this bug be reported?

Thanks again.

R.E.
Posts: 9
Joined: Thu Sep 23, 2021 1:31 am

Re: USB device requires unplugging and re-plugging to make it work after reboot.

Sat Sep 25, 2021 2:07 am

Some more info from dmesg in case it helps. See attached.
Attachments
dmesg2.gif
dmesg2.gif (126.66 KiB) Viewed 879 times

aBUGSworstnightmare
Posts: 3631
Joined: Tue Jun 30, 2015 1:35 pm

Re: USB device requires unplugging and re-plugging to make it work after reboot.

Sat Sep 25, 2021 4:53 am

R.E. wrote:
Sat Sep 25, 2021 2:07 am
Some more info from dmesg in case it helps. See attached.
better to copy that from your trerminal and past it as a CODE section.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4125
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: USB device requires unplugging and re-plugging to make it work after reboot.

Mon Sep 27, 2021 6:41 pm

I'm not the best RPi engineer to help you, but you could help others by answering a few questions:
1. How much current does the reader draw (downloading the spec sheet requires registration...)?
2. Which power supply are you using?
3. Does powering on without the keyboard plugged in and adding it later make a difference?

R.E.
Posts: 9
Joined: Thu Sep 23, 2021 1:31 am

Re: USB device requires unplugging and re-plugging to make it work after reboot.

Mon Sep 27, 2021 7:26 pm

1. How much current does the reader draw (downloading the spec sheet requires registration...)?

See attached screenshot showing power requirements below, also link to full spec sheet here: https://rfid.atlasrfidstore.com/hubfs/1 ... 0JADAK.pdf

Please note that when the Pi boots the ThingMagic device its at idle power. The full power is only required when reading / writing RFID tags.

2. Which power supply are you using?

Official Raspberry Pi power supply
-AC 100-240V 50/60Hz input with US plugs
-DC 5.1V 3A output
-15.3W maximum output power
-1.5m 18 AWG cable
-USB-C output connector

3. Does powering on without the keyboard plugged in and adding it later make a difference?

Unfortunately it does not, even if I unplug everything and just leave the ThingMagic unit the Pi will not recognize it at boot.

---------------------------------------------------------------------------------------------------------

It seems that you are leaning towards this being a power issue but if that was the case, then why would the ThingMagic device work without an issue on the Pi 3?

Thank you very much for your help.
Attachments
Power.png
Power.png (29.68 KiB) Viewed 722 times

User avatar
scruss
Posts: 4377
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: USB device requires unplugging and re-plugging to make it work after reboot.

Mon Sep 27, 2021 7:57 pm

I can't answer why it works on a Raspberry Pi 3 but not on another board, but could you please provide the output of

Code: Select all

lsusb -d 2008:1004 -v | grep MaxPower
?

If it's less than about 1200 mA (yes, I know that's a current, but MaxPower lists current in mA for $reasons), then that's less than the device's stated maximum power. USB will only give the amount of power that's negotiated on connection, and it's not uncommon for devices to ask for too little, and assume the hardware will be lenient. Raspberry Pis don't have power to spare, and often disconnect a USB device if it pulls too much power.

The device appears to be designed to take an external second power supply. To run it reliably with a Raspberry Pi, you'll need that extra USB power in (from a different source, preferable a USB wall power adapter).
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

R.E.
Posts: 9
Joined: Thu Sep 23, 2021 1:31 am

Re: USB device requires unplugging and re-plugging to make it work after reboot.

Mon Sep 27, 2021 9:23 pm

The output of the command is: MaxPower 500mA.

By the way, I have one of those USB Meters (https://www.adafruit.com/product/2690), I am not sure how accurate those things are are but when I plug the meter on it always shows 80 milliamps, it never goes up above that unless I start reading and writing RFID tags.

By the way, you are correct, the ThingMagic device comes with a USB cable with two USB-A connectors at one end (the end that plugs to the Pi) to get all the power it needs, however, the second connector is really only necessary if you are reading / writing RFID tags using maximum power.

And in case it helps, even if I connect both cables to the Pi the device is not recognize after booting. I suppose I could try connecting the second USB port to an external USB hub... just not sure if doing that will damage the ThingMagic device in some way...

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4125
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: USB device requires unplugging and re-plugging to make it work after reboot.

Mon Sep 27, 2021 9:29 pm

Connect both plugs to a powered hub that is in turn connected to the Pi, if only to rule power out as being the cause.

R.E.
Posts: 9
Joined: Thu Sep 23, 2021 1:31 am

Re: USB device requires unplugging and re-plugging to make it work after reboot.

Mon Sep 27, 2021 9:57 pm

Got it, I will need some time to go and get a USB hub (I don't have one) so I am able to test the theory.

One thing that I should mention is that I plugged the second USB cable to the Pi while the USB meter was connected to the other UBS cable and the current dropped to half of the original current (down to 40 milliamps)... Even during boot the current stayed at or below 40 milliamps.

Thanks.

R.E.
Posts: 9
Joined: Thu Sep 23, 2021 1:31 am

Re: USB device requires unplugging and re-plugging to make it work after reboot.

Tue Sep 28, 2021 12:08 am

Ok, so I went and got a USB hub (https://www.bestbuy.com/site/insignia-4 ... Id=5631038). I then proceeded to connect the USB hub to its external power supply and the Pi USB port. I then rebooted the Pi and this time the ThingMagic device showed up... however... I then proceed and disconnected the hub external power (the hub was getting its power exclusively from the Pi USB port), rebooted the Pi and once again, the ThingMagic device showed up. So external or no external power, things worked.

This tells me that power is not the problem, the problem appears to be with the Pi unable to figure out how to handle the ThingMagic device from a logical perspective. What I find weird is that it has no problem figuring the ThingMagic device with the added complexity of a USB hub in between, kind of wicked if you ask me!

Any thought on where to go from here?

User avatar
scruss
Posts: 4377
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: USB device requires unplugging and re-plugging to make it work after reboot.

Tue Sep 28, 2021 12:47 am

R.E. wrote:
Mon Sep 27, 2021 9:23 pm
The output of the command is: MaxPower 500mA.

By the way, I have one of those USB Meters (https://www.adafruit.com/product/2690), I am not sure how accurate those things are are but when I plug the meter on it always shows 80 milliamps, it never goes up above that unless I start reading and writing RFID tags.
So how high does it go when you're reading/writing tags?

Thanks for the MaxPower setting. That means if the device draws more than 2.5 W (= 5 V * 500 mA) the Raspberry Pi can disconnect it.

I suspect the device might be very briefly powering up at beyond 500 mA and disconnecting.

Use external supplementary power (not a hub) and it should be fine.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

R.E.
Posts: 9
Joined: Thu Sep 23, 2021 1:31 am

Re: USB device requires unplugging and re-plugging to make it work after reboot.

Tue Sep 28, 2021 12:58 am

scruss wrote:
Tue Sep 28, 2021 12:47 am
Use external supplementary power (not a hub) and it should be fine.
Can you be more specific on how to go about providing external supplementary power? The ThingMagic unit does not have a separate way of providing power to it, its only power comes from USB ports.

Also, something does not add up, I mean, why is ThingMagic device not having the issue when its plugged to the hub? Remember, my current configuration works by connecting the Pi to the USB hub and then the hub to the ThingMagic device (forgoing any external power supply to the USB hub). Should the issue not still persist in that case?

Thanks.

User avatar
scruss
Posts: 4377
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: USB device requires unplugging and re-plugging to make it work after reboot.

Tue Sep 28, 2021 11:29 am

R.E. wrote:
Tue Sep 28, 2021 12:58 am
Can you be more specific on how to go about providing external supplementary power? The ThingMagic unit does not have a separate way of providing power to it, its only power comes from USB ports.
You said it has two USB ports: use one for data, and use an A-A cable to a USB wall wart to power it.
Also, something does not add up, I mean, why is ThingMagic device not having the issue when its plugged to the hub?
Dunno. Hubs usually add a layer of buffering between the device and the computer. The ThingMagic is negotiating too low a maximum current for its maximum power, so its operation is going to be dodgy at best.

(ps: we're volunteers, please be nice)
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

R.E.
Posts: 9
Joined: Thu Sep 23, 2021 1:31 am

Re: USB device requires unplugging and re-plugging to make it work after reboot.

Tue Sep 28, 2021 2:49 pm

My apologies, it was no my intention to sound harsh, whatever you read as harsh in my previous post, that wasn't my intent!

By the way, I ended up connecting the power USB cable of the ThingMagic device to an external power source but that still didn't work, for some reason, there was no current coming out of the external power source (at least that is what my USB current meter said). Not sure why, perhaps the circuits are being isolated somehow. I did test the external power source and it was working correctly.

At this point, I have sent an email to the company that makes the units to see if they can help, I will post here if they come back with an answer.

Before I close this issue, I have one more quick question if you don't' mind. Is it possible to do something so that the Pi can boot up in some kind of verbose mode that allows me to see exactly what is going on during the boot cycle? My hope is that I could see some kind of message saying that the device got disconnected due to excessive current.

Thanks.

User avatar
scruss
Posts: 4377
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: USB device requires unplugging and re-plugging to make it work after reboot.

Wed Sep 29, 2021 1:34 am

dmesg is verbose mode - it's everything the kernel sees. Trace through the lines based on the device: on the screenshot you posted, that was "usb 1-1.4". It may be different on other reboots, but you should see it being recognized, the kernel going off and loading a driver for it, then afterwards, maybe problems - all with the "usb 1-1.4" line (or whatever it becomes). The final "unable to enumerate" error is the kernel giving up: your device has done something unexpected, and the kernel is refusing to talk to it any more

Maybe try rebooting with the device plugged in through the USB current meter. If on restart/power up it draws more than 500 mA even for a tiny amount of time, the kernel is likely to disconnect it.

I understand your frustration, but problems like this are almost impossible to diagnose without having the identical device in front of us. USB disconnection issues can often be traced back to power problems. Sometimes hubs fix or mask the problem, sometimes they don't: depends on hub type, configuration and (in the old days) kernel version. The Raspberry Pi 4 has a different USB system than the 3, so what might work on a 3 might not on a 4. All things impossible to diagnose without identical hardware.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

Return to “Interfacing (DSI, CSI, I2C, etc.)”