(Solved) USB "hot swap" locking up OSMC

The system config:

  • RPi2
  • Samsung Memory 32GB Evo MicroSDHC UHS-I Grade 1 Class 10
  • latest OSMC release version 2015.06-1 (not using the beta SD driver)
  • no USB memory stick
  • ethernet connected (no USB wifi dongle)
  • issue caused with any usb interface device (Roswell remote, keyboard, mouse)

The issue:
my rpi is behind a TV in a cubby with no visible wires. I occasionally want to use a keyboard for config purposes. When i unplug my remote dongle and plug in the keyboard, the system interface freezes (I think i can still ssh in). I can run an experiment and produce log files tonight. That is, unless this is a well known issue that i failed to find when i searched (my appologies if that be the case).

What power source do you use? Do not use the usb port on the tv. Use the official psu instead.

I’m definitely not powering from the TV. I have a Belkin surge protector that has two usb ports and 2.1A total current rating (10 Watt) and i only use one of them so all 2.1A can be supplied to the RPi2. I have no rainbow square in the corner of the screen :slight_smile:

Belkin supply:


I just read (on an OSMC forum post) that there is an issue with hot swapping usb on the RPi:

Also from the raspberrypi.org site:
USB causing Pi to crash - Raspberry Pi Forums
At least one person had a similar issue that was fixed with a different power supply. Between these two posts on raspberrypi.org, it seems that it is indeed power related and a practice that is not recommended.

Possible solution:
In the raspberrypi.org forum post at the link provided by @ActionA and as pointed out in ActionA’s post, it is suggested that if you want to hot swap / hot plug, you should use a powered USB hub.

It’s possible that the power supply can’t put all the current on one output. I’ve often seen specs for current on each output individually for multiple output supplies. It could be a power problem, which a powered hub would solve.

Great feedback, very insightful on your part. And for the most part, i agree. However, i’m banking on the Belkin name and the fact that tablets and newer smart phones use 2A usb supplies and some even warn you when they cannot pull the full 2A without dropping the voltage. I’ve read a lot of reviews and nothing leads me to believe this one doesn’t supply that full 2A to the single usb port being used. And just in case the thought crosses your mind, i’m so tight with space that i cannot plug the Pi supply that i have into the belkin surge protector without interference.

Nonetheless, i think my particular problem is definitely a case of usb rail dips when i plug in the new device. I suspect that it is a pi issue, that is, the usb phy circuit has a slow response time and no matter how much current my source can supply, there is the chance of this happening. I can run some experiments to try and isolate the issue, but the bottom line is, i can accomplish what i need without pluggin / unplugging usb devices (a little more cumbersome, but i do it infrequently). I thought it was an OSMC issue, but i’m now convinced it is not.

Edit - But… if anyone has a traditional PC (plenty of usb rail current reserves) AND sees this happening, then it would be worth producing some log files and checking things out.

Excuse my scepticism, but until I’ve seen this speculation backed up by an actual under load voltage measurement (difficult to do on the Pi 2 as they removed TP1 and TP2) then I will take this with a very large grain of salt.

The fact is that the vast majority of USB “chargers” are not well regulated, and drop well below 5v before reaching their rated current. This is proven over and over again when put to the test. The Pi (and Pi 2 in particular) is much more fussy about the voltage than a phone or tablet is when charging. Remember that a phone or tablet has a battery to help run it (which effectively acts as a really large filter capacitor) while the Pi relies entirely on the external supply and still has undersized filter capacitors.

The original Pi B (and A) did not support hot swapping of USB at all. You typically got away with it for something like a wired keyboard which draws less than 100mA, but never with a wifi adaptor or other more power consuming device.

The end result was almost always a spontaneous reboot when you connected the device as the USB 5v rail was directly connected to the 5v supply and coupled with the voltage dip under load of typical adaptors and insufficient capacitor size on the Pi’s 5V rail the voltage dip would crash the CPU.

In the Pi B+ and Pi 2 B the power supply circuitry was completely reworked and as well as now having a switching regulator instead of linear the USB ports are now isolated via a current limiter which can be switched to 600mA or 1.2A in software (max_usb_current in config.txt)

In the default 600mA setting this means that if a USB device draws too high a surge of current when initially connected it will typically not crash the CPU, but it often will crash the USB device itself. If you enable max_usb_current=1 the limit is increased to 1.2A (combined for all 4 USB ports) which can help the USB device itself not to crash when connected but if the power supply is not sufficient it will increase the chance that the CPU and thus the whole system crashes.

So on a B+ / Pi 2 hot swapping of USB is much more reliable but it can still cause hangs no matter how good your power supply is. On my Pi 2 with official Pi foundation power supply plugging in one particular wifi adaptor I have or my Flirc receiver often does cause a spontaneous reboot even though most of my other devices will hotplug fine.

Also if you have multiple devices connected, chances of hotplugging successfully are reduced due to the increased combined current drain.

Hotplugging on the Pi B+ and Pi 2 is something that will more often than not work OK, but definitely isn’t guaranteed and with some devices there is no way to succesfully hotplug them.

Thanks everyone. I’m pretty sure it’s safe to say that if you see this behavior, it is most likely not OSMC and most likely would be fixed by using a powered usb hub.

On a more general note, i REALLY appreciate EVERYONE’S helpfulness on these forums. You guys are really good and know your stuff well. You are courteous, informative, patient and kind. Most importantly, we all have the same goal.