(Solved) USB "hot swap" locking up OSMC

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.