How to restart USB subsystem?

I'm developing onto Arduino and sometimes the USB port that is being used stops working. Then I need to plug the device into another USB port. Once all the USB ports stop working I have to restart the machine which is really annoying.

As far as I remember there is a command which is able to restart the USB subsystem individually but I can't remember. How can I restart USBs without restarting the entire system?

I'm using macOS Sierra.

This is different to the question Resetting the USB port on a MacBook Pro as I need software-only solution as my USB ports get frozen - which means they stop working until full system restart. There must be a way of restarting the USB subsystem individually.


Solution 1:

You can reset the USB Bus with the USB Prober.app. It's not included with XCode, but you can download it separately from the Apple Developer Download page. You will need to signup and login.

  1. search for iousbfamily
  2. Download the latest IOUSBFamily Log Release file (at the time of this post it was IOUSBFamiliy Log Release for OS X 10.9.3)
  3. Mount the .dmg and navigate to the directory with IOUSB-XXXXXX-log.
  4. DO NOT install. Just right click the package and "Show Package Contents"
  5. Unzip the Archive.pax.gz; the file USBProber.app will be in /Archive/DevTools/Hardware


Important:

Just launching the app will reset your USB bus. Make sure you you unmount any drives you don't want unceremoniously and improperly removed!

Solution 2:

To reset a USB device, first download the USB Prober.app as explained in this other answer.

Next, you need to figure out the so-called Vendor and Product IDs of the USB device that you want to reset. You can do that with USB Prober, but it may be easier by using the System Profiler app from your Application / Utilities folder: Select USB within the Hardware topic in the left pane, then look for your USB device in the top right pane, select it, and you'll see its Product and Vendor IDs shown below, like this:

System Profiler screenshot

The IDs start are hex codes that start with 0x and have 4 more digits/letters. Make a note of them, with the Vendor ID first.

Inside USB Prober, there's a tool called reenumerate that you have to invoke from Terminal.app (find that in your Application / Utilities folder).

Move or copy the downloaded USB Prober.app to your Utilities folder.

Open Terminal.app, and paste the following line into it:

/Applications/Utilities/USB\ Prober.app/Contents/Resources/reenumerate

Then click into the Terminal window and type the space key, then type the two USB device IDs, Vendor ID first, separated with a comma. If your IDs were 0x174c and 0x55aa, then the line now should read:

...$ /Applications/Utilities/USB\ Prober.app/Contents/Resources/reenumerate -v 0x174c,0x55aa

Press return and you should get output similar to this:

Verbose mode ON
Looking for vid: 0x174c, pid: 0x55aa
Found "ASM105x" @ 0x14200000
Calling USBDeviceReEnumerate
USBDeviceReEnumerate returns 0x00000000

If you don't get more than the first line, it means that you entered the wrong IDs. If you get the full output, the device should have reset - for a disk device this means that it'll disconnect and reconnect as if you had unplugged the cable briefly.

If you invoke the reenumerate command without any arguments, you'll get usage information with more options you could try.