USB - more everyday

From Helpful
Jump to navigation Jump to search

⚠ This is for beginners and very much by a beginner / hobbyist

It's intended to get an intuitive overview for hobbyist needs. It may get you started, but to be able to do anything remotely clever, follow a proper course or read a good book.


Some basics and reference: Volts, amps, energy, power · batteries · resistors · transistors · fuses · diodes · capacitors · inductors and transformers · ground

Slightly less basic: amplifier notes · varistors · changing voltage · baluns · frequency generation · Transmission lines · skin effect


And some more applied stuff:

IO: Input and output pins · wired local IO · wired local-ish IO · ·  Various wireless · 802.11 (WiFi) · cell phone

Sensors: General sensor notes, voltage and current sensing · Knobs and dials · Pressure sensing · Temperature sensing · humidity sensing · Light sensing · Movement sensing · Capacitive sensing · Touch screen notes

Actuators: General actuator notes, circuit protection · Motors and servos · Solenoids

Noise stuff: Stray signals and noise · sound-related noise names · electronic non-coupled noise names · electronic coupled noise · ground loop · strategies to avoid coupled noise · Sampling, reproduction, and transmission distortions

Audio and video notes: See avnotes

USB: everyday · power · connectors · lower level · misc

Platform specific: : Microcontroller and computer platforms ·· Arduino and AVR notes · ESP series notes · STM32 series notes · Teensy series notes


Less sorted: Ground · device voltage and impedance (+ audio-specific) · electricity and humans · Soldering · landline phones · pulse modulation · PLL · Multimeter notes · signal reflection · Project boxes · resource metering · Radio and SDR · vacuum tubes · Unsorted stuff · 'E-fuse'

Some stuff I've messed with: Avrusb500v2 · GPS · Hilo GPRS · JY-MCU · DMX · Thermal printer ·

See also Category:Electronics.

This article/section is a stub — some half-sorted notes, not necessarily checked, not necessarily correct. Feel free to ignore, or tell me about it.

Unplugging USB

This article/section is a stub — some half-sorted notes, not necessarily checked, not necessarily correct. Feel free to ignore, or tell me about it.

"Do you need to 'Safely Remove Hardware'?"

tl;dr:

depends on the driver
depends on the device
mostly it's fine, though it's not a guarantee, and a few specific things can cause issues
if it involves storage, you may break off in the middle of a write.


For the USB bus itself, it's fine. USB was made to be hot-pluggable. Nothing will spark, and the host will almost certainly figure out a device left.


That says nothing about the function.

  • If the driver was not considering the possibility of a device leaving, that may cause trouble.
this is rare; it's part of the USB SDK to handle this
  • If an application was not considering the possibility of a device leaving, that may cause trouble.
many APIs (video, audio, whatnot) also include devices leaving. It's something you ought to handle, but some programs do not.


The real question is what the thing on top is doing.

  • If this is a keyboard, mouse, webcam, MIDI interface, the data isn't as important as the fact that the device is no longer there to be used
  • If the thing the device was doing involved storage, there is a chance you broke off in the middle of writing
and that may leave that storage in a bad state
  • (with some minor footnotes, such as that standard USB storage / video / HID class are more of a know quantity than drivers for custom hardware that to you has the same function)


For storage

For a sound card, webcam, keyboard or mouse or such, you won't care to completely lose the packets it's currently transferring.

For storage, on the other hand, you usually will - anything from a USB stick, memory card, external hard drive, connected cameras in storage mode.

Disconnecting a drive while running originally previously wasn't a thing, so filesystem APIs assume that a file stays open and available until the program that opened it says it is done.


Yanking while reading from a external storage will almost certainly make the reading program unhappy, yet the storage itself is typically fine.

Yanking while writing is usually bad.

Most filesystems write file data in-place (meaning they do not implement a guaranteed recovery)
A number of filesystems are a little more robust about filesystem metadata - but you shouldn't assume it


There is a common optimization in "keep the last seconds worth of data before actually writing it" (see writeback versus writethrough). This optimization is usually disabled for USB-connected storage - except when it's not.


Also, certain kinds of storage (non-ssd flash) erases a block before rewriting it, so there is a time at which only the host knows the data. So you can expect USB flash sticks to corrupts a little more easily while writing (SSDs, while based on Flash as well, have a more complex, smarter controller that avoids at part of that issue and should be more recoverable).

USB Device Not Recognized / Device has malfunctioned

Shown in a balloon near the task bar, with the addition that "One of the USB devices attached to this computer has malfunctioned, and windows does not recognize it."

(In some cases, if the balloon message is disabled, the device only shows up as an "Unknown Device" in the device manager.)(verify)


My summary so far is that there are many possible causes, it's hard to say which one it is, and most solutions are not very clearly good ones. Reinstalling usually won't help.


Possible problems/solutions

Things you can check easily enough:

  • broken device
    • test: try in other computers - and to be sure, also with varying OSes (some devices don't have drivers for older/specific OSes)
  • broken cable (cables get stepped, yanked, etc.)
    • if it's interchangeable, try another one.
    • If it's not interchangeable, try wiggling it to see if it accidentally makes a good contact. It's not a very good test in that it not working means nothing, but if it turns up temporarily, you know that a bit of DIYing may well fix the problem.
  • broken USB socket
    • Test: Try other things in the same port, and try this device in other ports
    • Note: each pair of ports is usually the same internal hub, so only trying the one right next to it is not the best test.
    • Basic mice are the most useful test devices, as they are low-power and do not require drivers to work
  • USB port in a weird state (e.g. the previous device drew too much power and triggered the polyfuse. But there is another reason or two)
    • (some are more sensitive/careful than others. Macbook polyfuses were apparently known for triggering quickly)
    • Test/fix: Turn computer off completely, and then leave the power cord/battery out for a few minutes (that much is rarely necessary, but sometimes it is and it takes less time to wait a bit longer once than to reboot again)
  • USB knows you are crossing the limit of power it can give out, and refuses the next device
    • more likely to happen on a non-powered hub
    • Test: try plugging the device into the computer itself (or into a powered hub that has no high-powered devices)
      • Front ports may sometimes be non-powered hubs, so a back (motherboard) port may be a better test.
    • Test: try a mouse in the same port - it's low-power and so very likely to work if the port's not broken.


Harder to check well:

  • stupid/missing driver for the particular device
    • Test: Try again after a restart, try with different OS, try with a different driver,
  • stupid power management bug (happens on some hardware)
    • There is/was a bug in XP(/Vista?) where power-suspended USB ports are not re-enabled properly, and there were mixed reports about Microsoft's patches (verify). Some people report that disable this port suspending feature helps.
  • windows USB driver set/setup got wonky.
    • Bit of a last resort thing to check
    • Test/fix: Uninstall as many related drivers as you can before plugging the devices back in.
  • some devices don't like sleep/hibernate, regardless of version of anything
and may stay confused until a reboot


It seems that certain devices are likelier to trigger this problem.





It seems that Windows's collection of drivers for USB devices (one or more) can get wonky. It may be that reinstalling all of these can help. Remove controllers drives last, so peripherals drivers first. Then rebooting and let it re-detect and re-install everything.

See also

Why do some devices only work on PC ports, not from hubs?

Notes on slow USB3

PTP, MTP, and more

USB OTG